Ethereum
eth_getBlockTransactionCountByHash
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).
Use cases
- Cheap fullness check. See how busy a block was without paying to download its transaction list — handy when scanning many blocks.
- Indexer reconciliation. After ingesting a block, compare the count you stored against this method's answer to confirm you didn't drop a transaction.
- Throughput sampling. Run it across a set of known block hashes to chart transactions-per-block and, given the 12-second slot cadence, infer rough TPS over a stretch of the chain.
Parameters
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | blockHash | string (hex) | Yes | The hash of the block to count transactions in. |
Response
| Type | Description |
|---|---|
| string (hex) | Hex-encoded transaction count. "0x0" means the block is empty. |
Example request
Try it live in the Ethereum playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | Block hash is malformed or not 32 bytes. |
Common pitfalls
- An unknown hash yields
null, not0x0. Null-check before youparseInt— feedingnullto a hex parser is a quiet source ofNaNcounts. - If you already hold a height and don't need a hash to pin a specific block across reorgs,
eth_getBlockTransactionCountByNumberdoes the same job and lets you pass tags likelatestorfinalizeddirectly.
Supported networks
- Mainnet — Chain ID: 1
- Sepolia — Chain ID: 11155111
See also
Parameters
0x-prefixed 32-byte block hash