curl --request POST \
--url https://nd-363-550-219.p2pify.com/942aad90bb6a082676497030b81e40ba \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber",
"params": [
"latest"
]
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
curl --request POST \
--url https://nd-363-550-219.p2pify.com/942aad90bb6a082676497030b81e40ba \
--header 'Content-Type: application/json' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber",
"params": [
"latest"
]
}'
{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}
quantity or tag
— the integer of a block encoded as hexadecimal or the string with:
latest
— the most recent block in the blockchain and the current state of the blockchain at the most recent blockearliest
— the earliest available or genesis blockpending
—the pending state and transactions block. This is the current state of transactions that have been broadcast to the network but have not yet been included in a block.quantity
— an integer value representing how many transactions are included in the block.eth_getBlockTransactionCountByNumber
code examplesconst { Web3 } = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);
async function getTransactionsCount(blockId) {
const count = await web3.eth.getBlockTransactionCount(blockId)
console.log(count);
}
getTransactionsCount('latest')
eth_getBlockTransactionCountByNumber
can be used to analyze how many transactions are included on the Polygon zkEVM blockchain in a certain period. For instance, on average, a new block is generated on the zkEVM mainnet every 3 seconds, resulting in approximately 1,200 blocks per hour. Using a Web3 library, one can inspect the past 1,00 blocks starting from the latest block and use eth_getBlockTransactionCountByNumber
to find the number of transactions in each block to sum them.The block transaction count information
The response is of type object
.