TriportRPC

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

eth_getBlockTransactionCountByNumber return value
FieldType
resultobject

Examples

curl https://triport.io/eth \
  -X POST -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <api-key>' \
  -d '{"id":1,"method":"eth_getBlockTransactionCountByNumber","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_getBlockTransactionCountByNumber",
  "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_getBlockTransactionCountByNumber","params":[],"jsonrpc":"2.0"},
)
print(resp.json())
{
  "id": 1,
  "result": "0x13d",
  "jsonrpc": "2.0"
}

Usage

  1. Transport: HTTP (JSON-RPC).
  2. Networks: mainnet.
  3. 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.