Polygon

Polygon

eth_chainId

eth_chainId returns the EIP-155 chain ID of the network the endpoint is serving. It's the canonical "which chain am I on?" check — wallets, signers, and bridge contracts all rely on it to prevent replay attacks across chains.

Why it matters

EIP-155 mixes the chain ID into transaction signatures. Two chains with the same nonce + same sender address are forced to produce different signatures, so a transaction signed for Ethereum mainnet (chain ID 1) is invalid on Polygon (chain ID 137). Treat eth_chainId as a precondition for any write path:

const id = await provider.send('eth_chainId', []);
if (BigInt(id) !== 1n) throw new Error('Expected Ethereum mainnet');

Parameters

None.

Response shape

A hex-encoded integer:

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

0x1 = Ethereum mainnet · 0x38 = BSC · 0x89 = Polygon · 0xa4b1 = Arbitrum One · 0x2105 = Base.

See also

  • net_version — older, less-reliable alternative. Some chains return the chain ID; others return a network ID. Prefer eth_chainId.
  • eth_blockNumber — combine the two for a full "alive + on the right chain" probe.
curl https://polygon.therpc.io \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.