Optimism
Optimism
Optimism
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
eth_chainId returns the EIP-155 chain ID of the network the endpoint is serving — for OP Mainnet, the OP Stack rollup whose gas token is ETH, that value is 0xa (decimal 10). It is the canonical way to confirm a connection is pointed at OP Mainnet and not Ethereum L1 or another Superchain member before you sign anything. Call https://optimism.therpc.io/YOUR_API_KEY and you should always get "0xa" back.
0xa so the user is actually on OP Mainnet and not another Superchain network.eth_blockNumber for a complete "alive and on chain 10" health probe of your endpoint.Este método no acepta parámetros. Pasa un array vacío [].
| Tipo | Descripción |
|---|---|
| string (hex) | Hex-encoded chain ID integer (e.g. "0x1" for Ethereum mainnet). |
Try it live in the Optimism playground.
| Código | Mensaje | Causa |
|---|---|---|
-32603 | Internal error | Node failed to retrieve chain configuration. |
net_version: on OP Mainnet both report 10, but net_version returns a decimal network ID and on some networks the two values diverge — use eth_chainId for EIP-155 logic."0xa", not the number 10 — compare with BigInt(result) === 10n rather than a raw string equality check to avoid "0xa" vs "0x0a" mismatches.