curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber",
"params": [
"latest"
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}curl --request POST \
--url https://rpc.testnet.tempo.xyz/ \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber",
"params": [
"latest"
],
"id": 1
}
'{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}blockNumber — the block number (hex) or tag (latest, earliest, pending)result — the number of transactions in the block encoded as hexadecimaleth_getBlockTransactionCountByNumber code examplesconst ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);
const getTransactionCount = async (blockNumber) => {
const count = await provider.send("eth_getBlockTransactionCountByNumber", [blockNumber]);
console.log(`Block ${blockNumber}: ${parseInt(count, 16)} transactions`);
};
// Get transaction count for latest block
getTransactionCount("latest");
// Get transaction count for a specific block
getTransactionCount("0x564000");
Was this page helpful?