curl --request POST \
--url https://nd-907-114-772.p2pify.com/b9b0fb92029d58b396139a9e89cf479b \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByHash",
"params": [
"0x2230d083edc1173cbc7a7ab977318d6a8fc53fec6f147efb0c6544a9c4fc18fd"
]
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
curl --request POST \
--url https://nd-907-114-772.p2pify.com/b9b0fb92029d58b396139a9e89cf479b \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByHash",
"params": [
"0x2230d083edc1173cbc7a7ab977318d6a8fc53fec6f147efb0c6544a9c4fc18fd"
]
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
hash
— the block hash of the requested block.quantity
— an integer value representing how many transactions are included in the block.eth_getBlockTransactionCountByHash
code examplesconst { Web3 } = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);
async function getTransactionsCount(blockHash) {
const count = await web3.eth.getBlockTransactionCount(blockHash)
console.log(count);
}
getTransactionsCount('0x41d5e705926b5b3fac109e8962a87da71a61373e43ba05e47c22138cb30b86bd')
eth_getBlockTransactionCountByHash
is a useful tool for analyzing transaction volume on the Cronos blockchain. On average, a new block is generated on the Cronos mainnet every 5 seconds, resulting in approximately 720 blocks per hour. Using a Web3 library, one can inspect the past 720 blocks starting from the latest block, retrieve the hash of each block, and use eth_getBlockTransactionCountByHash
to find the number of transactions in each block.The block information
The response is of type object
.