Rosetta API
https://github.com/edgeware-network/substrate-rosetta-api
Introduction
Rosetta API is a development tool built by Coinbase that allows blockchains to be more readily compatible with a variety of third-party software, including exchanges (like Coinbase,) wallets, OTC desks, and applications.
In combination with Substrate, which is a flexible, open, interoperable, and future-proof framework for developing blockchains, we have two industry-leading ways of developing and interoperating with blockchain-based platforms. The benefits of this combination allow any Substrate chain to trivially implement compatible tools, such as this repository of Rosetta API.
Prerequisites
Archive Node Access
You will need access to an archive node to be able to query the whole blockchain. You may use publicly available nodes or you can run one locally using the --pruning archive
flag when you start the node. You can also use the --wasm-execution Compiled
flag to speed up synchronization time significantly however, this uses more CPU and RAM, so you should turn it off after sync is complete.
Setting up Rosetta-api
git clone https://github.com/edgeware-network/substrate-rosetta-api
- Edit configuration files appropriately for your chain. These are located in the
networks
folder. The information can be found in the node itself and on subscan or your preferred block explorer. You can also use Polkadot apps. - Add your chains metadata in hexadecimal format in
networks/metadata
. You can get this by using subxt CLI tool it defaults to a node running locally or you can use a different node by indicating the --url.- You can get the metadata by running the command
subxt metadata --format hex
- You can get the metadata by running the command
- Add your chains types. This can be done in one of two ways:
- Add the types manually into the
polkadot-types.json
file. - If your chain uses a node package like Edgeware you add your chain spec to
src/helpers/connections.js
with types inclass SubstrateNetworkConnection
- Add the types manually into the
- Once those are completed run
yarn install
andyarn start
.
Setting up Rosetta-cli
In a separate terminal test with rosetta-cli Once downloaded you will most likely have to set your path for rosetta-cli using this command
export PATH=$PATH:/Users/bin
for example.Once that is set
Use "rosetta-cli [command] --help" for more information about a command.
This is a list of rosetta-cli command examples. Notice that you have to indicate what configuration file you want to us every time.rosetta-cli view:balance '{"address":"ADDRESS-GOES-HERE"}' BLOCK-NUMBER-GOES-HERE --configuration-file ./rosetta-api/rosetta-cli/mainnet/config.json
rosetta-cli view:block BLOCK-NUMBER-GOES-HERE --configuration-file ./Depth-rosetta-api/rosetta-cli/mainnet/config.json
rosetta-cli view:networks --configuration-file ./rosetta-api/rosetta-cli/mainnet/config.json
rosetta-cli check:data --configuration-file ./rosetta-api/rosetta-cli/mainnet/config.json
Try all possible tests with rosetta-cli.
- Now you have a working instance of rosetta-api for your substrate chain. Please feel free to let us know how we can improve it in the future. Our api is your API.
Contact us:
Discord: https://discord.gg/wFbystdrHC
Telegram: https://t.me/heyedgeware