L0vdL0vd

eth_chainId

Returns the chain ID used for signing (EIP-155). Use it to check you are on the right network.

curl https://eth.l0vdinfra.com/YOUR_KEY \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","id":1,"method":"eth_chainId","params":[]}'

Example response

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x1"
}
Params and your endpoint

Parameters

This method takes no parameters.

Returns

string Chain ID, hex: "0x1" for Ethereum mainnet.

When to use it

Confirm which network an endpoint serves before signing or writing data.

How to read the result

Hex chain ID: "0x1" Ethereum, "0xa4b1" Arbitrum One, "0x38" BNB Chain, "0x89" Polygon, "0x2105" Base, "0xa" OP Mainnet, "0xa86a" Avalanche C-Chain.

Tips

  • Check it at startup and refuse to run if it does not match your config.

Related methods