Polygon
Polygon
Polygon
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
eth_getBalance returns the native-token balance of an account at a chosen block — on Polygon PoS that is the account's MATIC balance, the token used to pay gas. You can read the current balance with latest or look back at any historical block, which is handy for accounting and audits. The value comes back as hex wei (18 decimals). Query https://polygon.therpc.io/YOUR_API_KEY (chain ID 137, 0x89) with an address and a block tag to get it.
polygonscan.com for accounting or forensic reconciliation.| # | Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|---|
| 1 | address | string (hex) | Ja | The account address to query. |
| 2 | blockTag | string | Nein | Block at which to read the balance.Standard: latest |
| Typ | Beschreibung |
|---|---|
| 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 Polygon playground.
| Code | Meldung | Ursache |
|---|---|---|
-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 — a MATIC balance in wei easily exceeds 2^53 and loses precision. Use BigInt(value) and divide by 10n**18n for whole MATIC.latest can still be reorged on Polygon before its Heimdall checkpoint lands on Ethereum; for a system of record read finalized instead.0xc2132D05D31c914a87C6611C10748AEb04B58e8F) you must eth_call balanceOf on the token contract.Parameter
0x-prefixed 20-byte address
hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"