Ethereum
Ethereum
Ethereum
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
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.
0x1 before submitting, so a user who switched their wallet to a testnet doesn't accidentally fire a mainnet-intended transaction into the void.eth_blockNumber for a two-call check that the endpoint is both alive and serving chain 1, not some fork.Este método não aceita parâmetros. Passe um array vazio [].
| Tipo | Descrição |
|---|---|
| string (hex) | Hex-encoded chain ID integer (e.g. "0x1" for Ethereum mainnet). |
Try it live in the Ethereum playground.
| Código | Mensagem | Causa |
|---|---|---|
-32603 | Internal error | Node failed to retrieve chain configuration. |
eth_chainId and net_version are not interchangeable. net_version returns 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."0x1"), not a number. Comparing the raw string against "1" or 1 will silently fail — normalize with BigInt(result) or parseInt(result, 16) first.