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_getBlockTransactionCountByHash returns just one number: how many transactions are packed into the block with a given 32-byte hash on Ethereum mainnet. It's the lightweight cousin of eth_getBlockByHash — when all you need is the count, you skip transferring the entire block body. Because you address by hash, the answer is tied to one specific block regardless of any reorg around that height. The result is a hex integer, with 0x0 meaning an empty block (which still happens on Ethereum even though one is proposed every 12-second slot). Call it at https://ethereum.therpc.io/YOUR_API_KEY (chain ID 1, native coin ETH).
| # | Nom | Type | Obligatoire | Description |
|---|---|---|---|---|
| 1 | blockHash | string (hex) | Oui | The hash of the block to count transactions in. |
| Type | Description |
|---|---|
| string (hex) | Hex-encoded transaction count. "0x0" means the block is empty. |
Try it live in the Ethereum playground.
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | Block hash is malformed or not 32 bytes. |
null, not 0x0. Null-check before you parseInt — feeding null to a hex parser is a quiet source of NaN counts.eth_getBlockTransactionCountByNumber does the same job and lets you pass tags like latest or finalized directly.Paramètres
0x-prefixed 32-byte block hash