Ethereum
Prêt à utiliser cela en production ?
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
Ethereum
Le niveau gratuit couvre les projets personnels. Le paiement à l'usage évolue sans carte bancaire.
eth_getUncleCountByBlockHash answers one narrow question about an Ethereum block identified by hash: how many uncles does it reference? You get back a single hex integer rather than full headers, which makes it the cheap probe to run before deciding whether to pull uncle details at all. On the chain's Proof-of-Work history the answer is 0x0, 0x1, or 0x2, since the protocol capped uncles at two per block. From The Merge onward (block 15537393 and up) PoS produces one block per slot with no ommers, so the count is always 0x0. Send the block hash to https://ethereum.therpc.io/YOUR_API_KEY on chain ID 1.
eth_getUncleByBlockHashAndIndex calls on this count: if it comes back 0x0, skip the per-index fetches entirely and save the round trips.| # | Nom | Type | Obligatoire | Description |
|---|---|---|---|---|
| 1 | blockHash | string (hex) | Oui | The hash of the block to count uncles in. |
| Type | Description |
|---|---|
| string (hex) | Hex-encoded uncle count (always "0x0", "0x1", or "0x2" on PoW chains; "0x0" on PoS). |
Try it live in the Ethereum playground.
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | Block hash is malformed. |
0x0, so a non-zero answer is only ever possible for PoW blocks below height 15537393. Treat this method as a historical instrument, not a live network metric.null rather than 0x0. Distinguish the two in your code: null means the block was not found, while 0x0 means a known block with zero uncles.Paramètres
0x-prefixed 32-byte block hash