eth_getBlockTransactionCountByHash | Cronos

Cronos API method that returns the number of transactions in a block specified by block hash. This information can be useful for analytics purposes.

👍

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • hash — the block hash of the requested block.

Response

  • quantity — an integer value representing how many transactions are included in the block.

eth_getBlockTransactionCountByHash code examples

const { 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')
const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

const getTransactionsCount = async (blockHash) => {
    const count = await provider.send("eth_getBlockTransactionCountByHash", [blockHash]);
    console.log(count);
   };

   getTransactionsCount('0x41d5e705926b5b3fac109e8962a87da71a61373e43ba05e47c22138cb30b86bd');
from web3 import Web3  
node_url = "CHAINSTACK_NODE_URL" 

web3 = Web3(Web3.HTTPProvider(node_url)) 
print(web3.eth.get_block_transaction_count("0x41d5e705926b5b3fac109e8962a87da71a61373e43ba05e47c22138cb30b86bd"))

Use case

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.

Try the eth_getBlockTransactionCountByHash RPC method yourself

Language
Click Try It! to start a request and see the response here!