Integrate an Exchange with Avalanche C-Chain


The objective of this document is to provide a brief overview of how to integrate with the EVM-Compatible Avalanche C-Chain. For teams that already support ETH, supporting the C-Chain is as straightforward as spinning up an Avalanche node (which has the same API as go-ethereum) and populating Avalanche’s ChainID (43114) when constructing transactions.

Additionally, Ava Labs maintains an implementation of the Rosetta API for the C-Chain called avalanche-rosetta. You can learn more about this standardized integration path on the attached Rosetta API website.

Integration using EVM Endpoints

Running Avalanche node

If you want to build your node form source or include it in a docker image, reference the AvalancheGo GitHub repository. To quickly get up and running, you can use the node installation script that automates installing and updating avalanchego node as a systemd service on Linux, using prebuilt binaries.

Configuring Avalanche node

All command line options available are described here, along with their default values.

You can supply options on the command line, or use the config file, which can be easier to work with when a lot of custom options are configured. Use —config-file=config.json option, and then provide a complete configuration in the config.json file, for example:

"coreth-config": {
"snowman-api-enabled": false,
"coreth-admin-api-enabled": false,
"net-api-enabled": true,
"eth-api-enabled": true,
"personal-api-enabled": false,
"tx-pool-api-enabled": true,
"debug-api-enabled": true,
"web3-api-enabled": true,
"local-txs-enabled": true

Interacting with the C-Chain

Interacting with the C-Chain is identical to interacting with go-ethereum. You can find the reference material for C-Chain API here.

Please note that personal_ namespace is turned off by default. To turn it on, you need to pass the appropriate command line switch to your node, like in the above config example.

Integration using Rosetta

Rosetta is an open-source specification and set of tools that makes integrating with different blockchain networks easier by presenting the same set of APIs for every network. The Rosetta API is made up of 2 core components, the Data API and the Construction API. Together, these APIs allow for anyone to read and write to blockchains in a standard format over a standard communication protocol. The specifications for these APIs can be found in the rosetta-specifications repository.

You can find the Rosetta server implementation for Avalanche C-Chain here, all you need to do is install and run the server with proper configuration. It comes with a Dockerfile that packages both the server and the Avalanche client. Detailed instructions can be found in the linked repository.

Constructing transactions

Avalanche C-Chain transactions are identical to standard EVM transactions with 2 exceptions:

  • They must be signed with Avalanche’s ChainID (43114).

  • The gas price is fixed to 225 Gwei.

For development purposes, Avalanche supports all the popular tooling for Ethereum, so developers familiar with Ethereum and Solidity can feel right at home. We have tutorials and repositories for several popular development environments:

Ingesting On-Chain Data

You can use any standard way of ingesting on-chain data you use for Ethereum network.

Determining Finality

Avalanche consensus provides fast and irreversible finality with 1-2 seconds. To query the most up-to-date finalized block, query any value (i.e. block, balance, state, etc) with the latest parameter. If you query above the last finalized block (i.e. eth_blockNumber returns 10 and you query 11), an error will be thrown indicating that unfinalized data cannot be queried (as of [email protected]).

(Optional) Custom Golang SDK

If you plan on extracting data from the C-Chain into your own systems using golang, we recommend using our custom ethclient. The standard go-ethereum Ethereum client does not compute block hashes correctly (when you call block.Hash()) because it doesn't take into account the added [ExtDataHash]( header field in Avalanche C-Chain blocks, which is used move AVAX between chains (X-Chain and P-Chain). You can read more about our multi-chain abstraction here (out of scope for a normal C-Chain integration).

If you plan on reading JSON responses directly or use web3.js (doesn't recompute hash received over the wire) to extract on-chain transaction data/logs/receipts, you shouldn't have any issues!


If you have any problems or questions, reach out either directly to our developers, or on our public Discord server.