Skip to main content
Monad API method that returns the number of transactions in a block matching the given block number. This method allows you to quickly check the transaction count for any block by its number.
Get you own node endpoint todayStart 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

  • quantity|tag — the block number as a hexadecimal string, or one of the following block tags:
    • latest — the most recent block in the canonical chain
    • earliest — the genesis block
    • pending — the pending state/transactions

Response

  • result — the number of transactions in the block, encoded as hexadecimal.

eth_getBlockTransactionCountByNumber code examples

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("CHAINSTACK_NODE_URL");

async function getBlockTransactionCount() {
  const blockNumber = "latest"; // Or use hex like "0x1234"
  const count = await provider.send("eth_getBlockTransactionCountByNumber", [blockNumber]);
  console.log(`Transaction count: ${parseInt(count, 16)}`);
}

getBlockTransactionCount();

Use case

A practical use case for eth_getBlockTransactionCountByNumber is analyzing network throughput over time by sampling transaction counts across multiple blocks, which helps understand network congestion patterns.