Base
Base
Base
O plano gratuito cobre projetos pessoais. O pay-as-you-go escala sem cartão de crédito.
eth_getBalance returns the native-token balance of an account at a specified block. On Base — Coinbase's OP Stack rollup — the native token is ETH, so this gives you an address's ETH holdings in wei. Query it at https://base.therpc.io/YOUR_API_KEY (chain ID 8453), passing the address and a block tag; the node reads state at that block and returns a hex-encoded wei value you convert with BigInt. It is the standard way to check what an account can spend on gas or transfers across the Base ecosystem.
| # | Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|---|
| 1 | address | string (hex) | Sim | The account address to query. |
| 2 | blockTag | string | Não | Block at which to read the balance.Padrão: latest |
| Tipo | Descrição |
|---|---|
| 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 Base playground.
| Código | Mensagem | 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() on the raw hex wei value — balances above 2^53 lose precision; always use BigInt(value) and divide by 10n**18n for whole ETH."latest" can still be reorged; for a system of record use "finalized", which reflects state anchored back to Ethereum L1.eth_call to the token contract's balanceOf.Parâmetros
0x-prefixed 20-byte address
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"