Skip to content

uname0x96/avalanche-rosetta

 
 

Repository files navigation


Avalanche Rosetta

Rosetta server implementation for Avalanche C-Chain.

Requirements

In order to run the Avalanche Rosetta server you will need access to Avalanche services via RPC. More info in available APIs found here.

See AvalancheGo documentation on how to run the chain node locally. If you don't run the Avalanche node yourself you might use the hosted API provided by Ava Labs.

Installation

Clone repository, then build the rosetta server by running the following commands:

make setup
make build

If successful, you will have rosetta-server binary in your current directory.

Usage

Before you start running the server you need to create a configuration file:

{
  "rpc_endpoint": "https://api.avax-test.network",
  "mode": "online",
  "listen_addr": "0.0.0.0:8080"
}

Start the server by running the following command:

./rosetta-server -config=./config.json

Configuration

Full configuration example:

{
  "mode": "online",
  "rpc_endpoint": "http://localhost:9650",
  "listen_addr": "0.0.0.0:8080",
  "network_name": "Fuji",
  "chain_id": 43113,
  "log_requests": true
}

Where:

Name Type Default Description
mode string online Mode of operations. One of: online, offline
rpc_endpoint string http://localhost:9650 Avalanche RPC endpoint
listen_addr string http://localhost:8080 Rosetta server listen address (host/port)
network_name string - Avalanche network name
chain_id integer - Avalanche C-Chain ID
log_requests bool false Enable request body logging

RPC Endpoints

List of all available Rosetta RPC server endpoints

Method Path Status Description
POST /network/list Y Get List of Available Networks
POST /network/status Y Get Network Status
POST /network/options Y Get Network Options
POST /block Y Get a Block
POST /block/transaction Y Get a Block Transaction
POST /account/balance Y Get an Account Balance
POST /mempool Y Get All Mempool Transactions counts
POST /mempool/transaction N/A Get a Mempool Transaction
POST /construction/combine Y Create Network Transaction from Signatures
POST /construction/derive Y Derive an AccountIdentifier from a PublicKey
POST /construction/hash Y Get the Hash of a Signed Transaction
POST /construction/metadata Y Get Transaction Construction Metadata
POST /construction/parse Y Parse a Transaction
POST /construction/payloads Y Generate an Unsigned Transaction and Signing Payloads
POST /construction/preprocess Y Create a Request to Fetch Metadata
POST /construction/submit Y Submit a Signed Transaction
POST /call Y Perform a Blockchain Call

Development

Available commands:

  • make build - Build the development version of the binary
  • make test - Run the test suite
  • make dist - Build distribution binaries
  • make docker-build - Build a Docker image
  • make docker-push - Push a Docker image to the registry
  • make run-testnet - Run node and rosetta testnet server
  • make run-testnet-offline - Run node and rosetta testnet server
  • make run-mainnet - Run node and rosetta mainnet server
  • make run-mainnet-offline - Run node and rosetta mainnet server

Testing Rosetta

Rosetta implementaion could be testing using the Rosetta CLI.

Before we can start the service, we need to build the docker image:

make docker-build

Next, start the Testnet service by running:

make run-testnet

Wait until the node is done bootstrapping, then start the data check:

make check-testnet-data

Run the construction check:

make check-testnet-construction

License

BSD 3-Clause

About

Rosetta server for Avalanche (C-Chain)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 93.6%
  • Makefile 2.7%
  • Dockerfile 2.1%
  • Shell 1.6%