|0.4.0||Jun 29, 2023|
|0.1.0||Mar 30, 2023|
#803 in Magic Beans
Rosetta SDK Documentation
The Rosetta SDK is a Rust-based package that implements Coinbase’s Rosetta API specifications. This repo provides a framework for Analog’s connectors — special nodes hosted by time node operators — to simplify their interactions with Analog-connected chains in a manner compliant with the Analog Network’s protocol.
This repo contains the following modules:
rosetta-core. Provides traits and definitions shared by the server and client crates.
rosetta-server. This is a generic implementation of the Rosetta Server. The Rosetta Server is a standalone server that a connector on any Analog-supported chain can connect to and listen to the port specified in the settings.
rosetta-client. This is a standard client that interacts with the Rosetta Server.
rosetta-types. It contains the request and response structs used by the client and server. It is initially autogenerated using the openapi-generator.
rosetta-crypto. It has cryptographic primitives used by the rosetta-client.
rosetta-wallet. This is a command line interface (CLI) built with the rosetta-client.
rosetta-cli. This is a CLI built with the rosetta-client.
rosetta-docker. This is a generic Rosetta Server testing infrastructure.
chains. These are chain-specific client/server components.
To get started with the Rosetta SDK, you must ensure you have installed the latest version of Docker.
Run the following command to download chain-connectors:
$ git clone https://github.com/Analog-Labs/chain-connectors.git
You can also download the latest pre-built Docker image release from GitHub by running the following command:
curl -sSfL https://raw.githubusercontent.com/Analog-Labs/chain-connectors/master/install.sh | sh -s
After cloning this repo, simply run the following command:
Install CLI tools
Install the CLI tools by running the commands below:
cargo install --path rosetta-cli cargo install --path rosetta-wallet
To run any command with rosetta-cli, simply execute the rosetta-cli tool from the command line as follows:
Similarly, to run a command with the rosetta-wallet, simply execute the rosetta-wallet tool from the command line as follows:
Reference wallet implementations
To help you get started with wallets on specific chains, we have developed complete Rosetta API reference implementations for Bitcoin (deprioritized for now), Ethereum, and Substrate-based chains.
We have tested this implementation on an AWS c5.2xlarge instance. This instance type provides 8 vCPUs and 16 GB RAM. To use this repository, you need to fork it and start playing with the code. For example, running these commands will help you learn more about Rosetta API implementation for the Ethereum-based wallets:
rosetta-wallet --chain eth --keyfile /tmp/alice faucet 100000000000000 rosetta-wallet --chain eth --keyfile /tmp/alice balance rosetta-wallet --chain eth --keyfile /tmp/bob account rosetta-wallet --chain eth --keyfile /tmp/alice transfer bob_acc_key 10000000000000 rosetta-wallet --chain eth --keyfile /tmp/bob balance
We have tested this implementation on an AWS c5.2xlarge instance. This instance type provides 8 vCPUs and 16 GB RAM. To use this repository, you need to fork it and start playing with the code. For example, running these commands will help you learn more about Rosetta API implementation for Substrate-based wallets:
rosetta-wallet --chain dot --keyfile /tmp/alice faucet 3000000000000000 rosetta-wallet --chain dot --keyfile /tmp/bob account rosetta-wallet --chain dot --keyfile /tmp/alice transfer bob_acc_key 1500000000000000 rosetta-wallet --chain dot --keyfile /tmp/bob balance
To use this repository, you need to fork it and start playing with the code. For example, running these commands will help you learn more about Rosetta API implementation for Bitcoin wallets:
rosetta-wallet --chain btc --keyfile /tmp/alice faucet 1000 rosetta-wallet --chain btc --keyfile /tmp/bob account rosetta-wallet --chain btc --keyfile /tmp/alice transfer bob_acc_key 1000 rosetta-wallet --chain btc --keyfile /tmp/alice faucet 1 rosetta-wallet --chain btc --keyfile /tmp/bob balance
Reference CLI implementation
To help you get started with rosetta-cli, we have developed a standard indexer endpoint that you can leverage to integrate external blockchains automatically. The indexer endpoint complements the existing Data and Construction API endpoints in Rosetta API specifications, allowing developers to fully support asset integration.
You will need an indexer URL that gets passed with the “—indexer-URL” flag to run an indexer. For example, in a local environment, you can run these commands to use the indexer:
rosetta-cli --chain=btc search --indexer-url=http://localhost:8083 --type=Transfer --success=true rosetta-cli --chain=eth search --indexer-url=http://localhost:8084 --type=Transfer --success=true rosetta-cli --chain=dot search --indexer-url=http://localhost:8085 --type=Transfer --success=true
To launch the Block Explorer in your browser, simply open your browser and point it to: http://rosetta.analog.one:3000
Run local testnet
Running a local testnet with docker compose up initiates a number of containers, including:
- bitcoin: http://127.0.0.1:8080
- ethereum: http://127.0.0.1:8081
- polkadot: http://127.0.0.1:8082
- block explorer: http://127.0.0.1:3000
You can override the default URL in rosetta-cli and rosetta-wallet with the “—URL” flag.
Update AWS deployment
Create a new tag, push to master and use it to create a new github release.
You can contribute to this repo in a number of ways, including: