Categorygithub.com/ava-labs/avalanche-rosetta

# README


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_base_url": "https://api.avax-test.network",
  "mode": "online",
  "listen_addr": "0.0.0.0:8080",
  "genesis_block_hash" :"0x31ced5b9beb7f8782b014660da0cb18cc409f121f408186886e1ca3e8eeca96b",
}

Start the server by running the following command:

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

Configuration

Full configuration example:

{
  "mode": "online",
  "rpc_base_url": "http://localhost:9650",
  "listen_addr": "0.0.0.0:8080",
  "network_name": "Fuji",
  "chain_id": 43113,
  "log_requests": true,
  "genesis_block_hash" :"0x31ced5b9beb7f8782b014660da0cb18cc409f121f408186886e1ca3e8eeca96b",
  "index_unknown_tokens": false,
  "ingestion_mode" : "standard",
  "token_whitelist" : [],
  "bridge_tokens" : [],
  "validate_erc20_whitelist": false
}

Where:

NameTypeDefaultDescription
modestringonlineMode of operations. One of: online, offline
rpc_base_urlstringhttp://localhost:9650Avalanche RPC base url
listen_addrstringhttp://localhost:8080Rosetta server listen address (host/port)
network_namestring-Avalanche network name
chain_idinteger-Avalanche C-Chain ID
genesis_block_hashstring-The block hash for the genesis block
index_unknown_tokensboolfalseEnables ingesting tokens that don't have a public symbol or decimal variable
ingestion_modestringstandardToggles between standard and analytics ingesting modes
token_whitelist[]string[]Enables ingesting for the provided ERC20 contract addresses in standard mode.
bridge_tokens[]string[]Supported Avalanche Bridge tokens. Unwrap function allowed, which initates transfer to ethereum if amount threshold met
validate_erc20_whitelistboolfalseVerifies provided ERC20 contract addresses in standard mode (node must be bootstrapped when rosetta server starts).

The token whitelist only supports tokens that emit evm transfer logs for all minting (from should be 0x000---), burning (to address should be 0x0000) and transfer events are supported. All other tokens will break cause ingestion to fail.

RPC Endpoints

List of all available Rosetta RPC server endpoints

MethodPathStatusDescription
POST/network/listYGet List of Available Networks
POST/network/statusYGet Network Status
POST/network/optionsYGet Network Options
POST/blockYGet a Block
POST/block/transactionYGet a Block Transaction
POST/account/balanceYGet an Account Balance
POST/mempoolYGet All Mempool Transactions counts
POST/mempool/transactionN/AGet a Mempool Transaction
POST/construction/combineYCreate Network Transaction from Signatures
POST/construction/deriveYDerive an AccountIdentifier from a PublicKey
POST/construction/hashYGet the Hash of a Signed Transaction
POST/construction/metadataYGet Transaction Construction Metadata
POST/construction/parseYParse a Transaction
POST/construction/payloadsYGenerate an Unsigned Transaction and Signing Payloads
POST/construction/preprocessYCreate a Request to Fetch Metadata
POST/construction/submitYSubmit a Signed Transaction
POST/callYPerform 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

Note: If you're running arm64 machine(e.g, Mac M1), you may run

make docker-build-arm64

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

Run the construction check for ERC-20s:

make check-testnet-construction-erc20

Rebuild the ContractInfoToken.go autogen file

abigen --abi contractInfo.abi --pkg main --type ContractInfoToken --out client/contractInfoToken.go

License

BSD 3-Clause

# Packages

Package client is a generated GoMock package.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package service is a generated GoMock package.