Ethereum
Ethereum
eth_chainId
eth_chainId reports the EIP-155 chain identifier that the endpoint is serving. For Ethereum mainnet — the ETH network — that value is 0x1, decimal 1. The identifier is baked into every signed transaction so a signature valid on one network can't be replayed on another; checking it before you sign is how a wallet proves it's talking to the right chain rather than Sepolia (0xaa36a7) or Holesky. Call https://ethereum.therpc.io/YOUR_API_KEY with no parameters and you'll get 0x1 back from any healthy mainnet node.
Use cases
- Network guard before signing. Confirm the result is
0x1before submitting, so a user who switched their wallet to a testnet doesn't accidentally fire a mainnet-intended transaction into the void. - Health + identity probe. Pair it with
eth_blockNumberfor a two-call check that the endpoint is both alive and serving chain 1, not some fork. - Pick the right deployment. In a multi-chain app, map the returned ID to the correct contract addresses — your USDC or router on mainnet differs from the one on every testnet.
- Replay protection. The chain ID is the EIP-155 ingredient that stops a mainnet-signed transaction from being rebroadcast on another EVM chain; reading it lets you build that check in explicitly.
Parameters
This method takes no parameters. Pass an empty array [].
Response
| Type | Description |
|---|---|
| string (hex) | Hex-encoded chain ID integer (e.g. "0x1" for Ethereum mainnet). |
Example request
Try it live in the Ethereum playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32603 | Internal error | Node failed to retrieve chain configuration. |
Common pitfalls
eth_chainIdandnet_versionare not interchangeable.net_versionreturns the older network ID as a decimal string; on Ethereum mainnet both happen to be 1, but the chain ID is what EIP-155 signing actually uses, so always sign against this method's value.- The response is a hex string (
"0x1"), not a number. Comparing the raw string against"1"or1will silently fail — normalize withBigInt(result)orparseInt(result, 16)first.
Supported networks
- Mainnet — Chain ID: 1
- Sepolia — Chain ID: 11155111