eth_chainId - AVAX

Example code for the eth_chainId JSON-RPC method. Complete guide on how to use eth_call JSON-RPC in GetBlock Web3 documentation.

Returns the C-Chain ID. For mainnet the result is 0xa86a (43114); for Fuji testnet it is 0xa869 (43113). Required for EIP-155 signed transactions to prevent cross-chain replay.

Parameters

  • None

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/ext/bc/C/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_chainId",
    "params": [],
    "id": "getblock.io"
}'

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0xa86a"
}

Response Parameters

Field
Type
Description

result

string

Chain ID in hexadecimal (0xa86a = 43114 mainnet, 0xa869 = 43113 Fuji testnet)

Use Cases

  • Constructing EIP-155 signed transactions

  • Validating a wallet is connected to Avalanche C-Chain

  • Multi-chain dApps that branch logic by chain ID

Error Handling

Status Code
Error Message
Cause

404

Not found

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?