Optimism
Optimism
Optimism
El plan gratuito cubre proyectos personales. El pago por uso escala sin necesidad de tarjeta.
eth_getBalance returns the ETH balance of an account on OP Mainnet at a specified block — ETH is the native gas token of this OP Stack rollup. The value comes back as hex-encoded wei, so it reflects the bridged ETH an address holds on L2, not on Ethereum L1. Query https://optimism.therpc.io/YOUR_API_KEY (chain ID 10, 0xa) with an address and a block tag such as latest or finalized.
latest to detect incoming ETH payments on the rollup as blocks land every ~2 seconds.| # | Nombre | Tipo | Requerido | Descripción |
|---|---|---|---|---|
| 1 | address | string (hex) | Sí | The account address to query. |
| 2 | blockTag | string | No | Block at which to read the balance.Predeterminado: latest |
| Tipo | Descripción |
|---|---|
| string (hex) | Hex-encoded balance in wei. Convert with BigInt(value); divide by 10n**18n to get the chain's base unit. |
Try it live in the Optimism playground.
| Código | Mensaje | Causa |
|---|---|---|
-32602 | Invalid params | Address is malformed, missing 0x prefix, or block tag is unrecognised. |
-32000 | Missing trie node | Queried a historical block that the node has pruned (non-archive node). |
Number() — an OP Mainnet balance above 2^53 wei loses precision; always use BigInt(value) and divide by 10n**18n for whole ETH.latest reflects unfinalized L2 state; for a system of record that must survive a reorg before L1 settlement, read at finalized instead.eth_call the token contract's balanceOf.Parámetros
0x-prefixed 20-byte address
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"