docknetwork / rosetta-api

Substrate/Polkadot Rosetta API Implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Substrate/PolkadotJS Rosetta API

This is Dock's implementation of the Rosetta API for our Subsrate blockchain, written in NodeJS using PolkadotJS. Currently in development but mostly done. Any suggestions or improvements are welcome. This isn't considered production ready yet but you can go ahead and try it.

Prerequisites

Install Yarn or NPM, run the usual yarn install or npm install.

Development

Run yarn dev to run a development instance of the API. Default port is 8080. Check the rosetta-cli configuration files in /rosetta-cli. Rosetta CLI usage is better documented here, but the main files to check are:

  • rosetta-cli/devnode/config.json (connects to local substrate node)
  • rosetta-cli/mainnet/config.json (connects to local mainnet node)
  • rosetta-cli/testnet/config.json (connects to dock testnet directly)

Starting

  • Online mode: yarn start
  • Offline mode: yarn start-offline or add --offline flag in CLI

Starting with Docker

  • Run: docker run -d --network="host" docknetwork/rosetta-api
  • Build: docker build -t docknetwork/rosetta-api .

Adding a custom network

Note the configuration files in the networks directory. To add a custom network, copy one of the files and change the parameters. You will need to also export your chain metadata and ensure its defined in the network configuration. You also need to import the proper types JSON, similar to ./polkadot-types.json. Network configuration files are automatically loaded when the API initializes.

Inspecting/Debugging

We use Rosetta Inspector to check that the API is running properly, you can do that like so using Docker:

docker pull figmentnetworks/rosetta-inspector
docker run --network="host" -p 5555:5555 figmentnetworks/rosetta-inspector -url=http://localhost:8080

Potential improvements

  • Memory caching solution for block/transaction info
  • Write tests

About

Substrate/Polkadot Rosetta API Implementation

License:MIT License


Languages

Language:JavaScript 99.3%Language:Dockerfile 0.7%