C-Chain API
This page is an overview of the C-Chain API associated with AvalancheGo.
Note
Ethereum has its own notion of networkID
and chainID
. These have no relationship to Avalanche's view of networkID and chainID and are purely internal to the C-Chain. On Mainnet, the C-Chain uses 1
and 43114
for these values. On the Fuji Testnet, it uses 1
and 43113
for these values. networkID
and chainID
can also be obtained using the net_version
and eth_chainId
methods.
Ethereum APIs
Endpoints
JSON-RPC Endpoints
To interact with C-Chain via the JSON-RPC endpoint:
To interact with other instances of the EVM via the JSON-RPC endpoint:
where blockchainID
is the ID of the blockchain running the EVM.
WebSocket Endpoints
info
On the public API node, it only supports C-Chain websocket API calls for API methods that don't exist on the C-Chain's HTTP API
To interact with C-Chain via the websocket endpoint:
For example, to interact with the C-Chain's Ethereum APIs via websocket on localhost, you can use:
Tip
On localhost, use ws://
. When using the Public API or another
host that supports encryption, use wss://
.
To interact with other instances of the EVM via the websocket endpoint:
where blockchainID
is the ID of the blockchain running the EVM.
Standard Ethereum APIs
Avalanche offers an API interface identical to Geth's API except that it only supports the following services:
web3_
net_
eth_
personal_
txpool_
debug_
(note: this is turned off on the public API node.)
You can interact with these services the same exact way you'd interact with Geth (see exceptions below). See the Ethereum Wiki's JSON-RPC Documentation and Geth's JSON-RPC Documentation for a full description of this API.
info
For batched requests on the public API node , the maximum number of items is 40.
Exceptions
Starting with release v0.12.2
, eth_getProof
has a different behavior compared to geth:
- On archival nodes (nodes with
pruning-enabled
set tofalse
), queries for state proofs older than 24 hours preceding the last accepted block will be rejected by default. This can be adjusted withhistorical-proof-query-window
, which defines the number of blocks before the last accepted block that can be queried for state proofs. Set this option to0
to accept a state query for any block number. - On pruning nodes (nodes with
pruning-enabled
set totrue
), queries for state proofs outside the 32 block window after the last accepted block are always rejected.
Avalanche - Ethereum APIs
In addition to the standard Ethereum APIs, Avalanche offers eth_baseFee
,
eth_maxPriorityFeePerGas
, and eth_getChainConfig
.
They use the same endpoint as standard Ethereum APIs:
eth_baseFee
Get the base fee for the next block.
Signature:
result
is the hex value of the base fee for the next block.
Example Call:
Example Response:
eth_maxPriorityFeePerGas
Get the priority fee needed to be included in a block.
Signature:
result
is hex value of the priority fee needed to be included in a block.
Example Call:
Example Response:
For more information on dynamic fees see the C-Chain section of the transaction fee documentation.
Admin APIs
The Admin API provides administrative functionality for the EVM.
Endpoint
Methods
admin_startCPUProfiler
Starts a CPU profile that writes to the specified file.
Signature:
Example Call:
admin_stopCPUProfiler
Stops the CPU profile.
Signature:
Example Call:
admin_memoryProfile
Runs a memory profile writing to the specified file.
Signature:
Example Call:
admin_lockProfile
Runs a mutex profile writing to the specified file.
Signature:
Example Call:
admin_setLogLevel
Sets the log level for the EVM.
Signature:
Example Call:
admin_getVMConfig
Returns the current VM configuration.
Signature:
Example Call:
Avalanche-Specific APIs
Endpoint
Methods
avax.getUTXOs
Gets all UTXOs for the specified addresses.
Signature:
Example Call:
avax.issueTx
Issues a transaction to the network.
Signature:
Example Call:
avax.getAtomicTxStatus
Returns the status of the specified atomic transaction.
Signature:
Example Call:
avax.getAtomicTx
Returns the specified atomic transaction.
Signature:
Example Call:
avax.version
Returns the version of the VM.
Signature:
Example Call:
avax.issueBlock
Manually issues a new block.
Signature:
Example Call:
avax.getAcceptedFront
Returns the last accepted block's hash and height.
Signature:
Example Call:
Is this guide helpful?