eth_getBlockTransactionCountByNumber - Arbitrum
Example code for the eth_getBlockTransactionCountByNumber JSON RPC method. Сomplete guide on how to use eth_getBlockTransactionCountByNumber JSON RPC in GetBlock Web3 documentation.
This method returns the number of transactions in a block identified by its block number.
Parameters
block_number
string
yes
Block number in hex format, or a keyword such as latest, earliest, or pending.
Request
curl --location 'https://go.getblock.us/<ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber ",
"params": [
"latest"
],
"id": "getblock.io"
}'import axios from 'axios'
let data = JSON.stringify({
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber",
"params": [
"latest"
],
"id": "getblock.io"
};
let config = {
method: "post",
maxBodyLength: Infinity,
url: "https://go.getblock.us/<ACCESS_TOKEN>",
headers: {
"Content-Type": "application/json",
},
data: data,
};
axios
.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x8"
}Reponse Parameter Definition
result
string (hex)
Number of transactions in the specified block. Returns null if the block does not exist.
Use case
The eth_getBlockTransactionCountByNumber is used to:
Calculating chain throughput by measuring transactions per block
Building analytics dashboards that monitor block activity in real time
Lightweight block scanning without fetching full block data
Detecting unusually busy or empty blocks
Supporting explorers and monitoring tools that show activity patterns
Error handling
403
Forbidden
Missing or invalid ACCESS_TOKEN.
-32602
Invalid argument
The block hash isn't accurate or incomplete or keyword missing
Integration with Web3
The eth_getBlockTransactionCountByNumber can help developers:
Track live activity on the chain
Build explorers and dashboards without fetching heavy block objects
Detect transaction spikes for alerts and monitoring
Estimate network load to optimize dapp behavior
Streamline backend indexing by filtering blocks based on transaction count
Last updated
Was this helpful?