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://triport.io/eth \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"eth_getBlockTransactionCountByHash","params":[],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/eth", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "eth_getBlockTransactionCountByHash",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/eth",
headers={"Authorization": "Bearer <api-key>"},
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.