eth_getBlockTransactionCountByHash
Last updated:
`eth_getBlockTransactionCountByHash` looks up a block by its 32-byte hash and returns how many transactions that block contains, encoded as a `0x`-prefixed hexadecimal string.
Use it when you already hold a block hash — for example from a log, a receipt, or an `eth_getBlockByHash` response — and you only need the transaction count rather than the full block body. Pairing the count with `eth_getTransactionByBlockHashAndIndex` lets you page through a block's transactions by index without downloading the entire block.
If no block matches the supplied hash (e.g. it belongs to an orphaned/uncle block, or the node has not yet seen it), the method returns `null` instead of an error. Always check for `null` before parsing the result as a number.
Parameters
This method takes no parameters.
Returns
| Field | Type |
|---|---|
| result | object |
Examples
curl https://<your-endpoint>/ \
-X POST -H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockTransactionCountByHash","params":[]}'const res = await fetch("https://<your-endpoint>/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"id": 1,
"method": "eth_getBlockTransactionCountByHash",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"eth_getBlockTransactionCountByHash","params":[],"jsonrpc":"2.0"})
print(resp.json())Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet.
- Credit cost: 1 per call.
FAQ
- What does eth_getBlockTransactionCountByHash do?
- Returns the number of transactions in the block identified by its block hash.
- How many credits does eth_getBlockTransactionCountByHash cost?
- eth_getBlockTransactionCountByHash costs 1 credit(s) per call on Triport by default.
- Is eth_getBlockTransactionCountByHash available over WebSocket?
- eth_getBlockTransactionCountByHash is an HTTP JSON-RPC method.