eth_getBlockTransactionCountByNumber
Last updated:
`eth_getBlockTransactionCountByNumber` returns how many transactions are contained in a given block, selected by block number (a `0x`-prefixed hex integer) or by one of the named block tags. The count is returned as a `0x`-prefixed hexadecimal string.
Use it when you only need the transaction *count* and not the full block body — for example to size pagination, to detect empty blocks, or to decide whether a heavier `eth_getBlockByNumber` call is worth issuing. If you already have a block hash instead of a number, use the sibling method `eth_getBlockTransactionCountByHash`.
A request for a block that does not exist (e.g. a height beyond the current chain head) returns a `result` of `null` rather than an error.
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_getBlockTransactionCountByNumber","params":[]}'const res = await fetch("https://<your-endpoint>/", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"id": 1,
"method": "eth_getBlockTransactionCountByNumber",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post("https://<your-endpoint>/", json={"id":1,"method":"eth_getBlockTransactionCountByNumber","params":[],"jsonrpc":"2.0"})
print(resp.json()){
"id": 1,
"result": "0x13d",
"jsonrpc": "2.0"
}Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet.
- Credit cost: 1 per call.
FAQ
- What does eth_getBlockTransactionCountByNumber do?
- Returns the number of transactions in the block identified by its number or a block tag.
- How many credits does eth_getBlockTransactionCountByNumber cost?
- eth_getBlockTransactionCountByNumber costs 1 credit(s) per call on Triport by default.
- Is eth_getBlockTransactionCountByNumber available over WebSocket?
- eth_getBlockTransactionCountByNumber is an HTTP JSON-RPC method.