Skip to main content

eth_chainId

Overview

The 'eth_chainId' provided is always aligned with the data in the latest recognized head block. This guarantees that users of this RPC method can consistently utilize the fetched data to authenticate transactions based on the head.

If the recognized head block lacks a specified chain ID, the client will interpret calls to 'eth_chainId' as unsupported and will respond with an appropriate error.

For reliable chain identification, it's advised to prioritize 'eth_chainId' over 'net_version'.

Request

curl --request POST \
--url https://ethereum-mainnet-geth-archive.node.coinapi.io \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'X-CoinAPI-Key: 73034021-THIS-IS-SAMPLE-KEY' \
--data '
{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_chainId"
}'

Response

{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1"
}

A hexadecimal of the current chain ID.