🔵 Base
eth_getBlockTransactionCountByNumber

eth_getBlockTransactionCountByNumber - Base Chain JSON-RPC Method

Overview

The eth_getBlockTransactionCountByNumber method returns the total number of transactions in a specified block on the Base chain, identified by block number or block tag. This method is essential for applications that need to analyze transaction activity at specific points in the Base blockchain.

Returns

QUANTITY - Integer of the number of transactions in the requested block, returned as a hexadecimal value.

Parameters

blockNumber or Tag - Block number as hexadecimal or the string "latest", "earliest", or "pending".

Note: Unlike Ethereum and Arbitrum One chains, the "safe" and "finalized" tags are not available on Base chain. Read more about block parameters (opens in a new tab).

Request

POST https://base-mainnet.chainnodes.org/YOUR-API-KEY

Example

  • HTTPS POST Request with a JSON RPC call in the body
  • Replace YOUR-API-KEY with the API key from your Chainnodes.org Dashboard
  • You can use a different supported network by replacing base-mainnet
curl https://base-mainnet.chainnodes.org/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["0x1029C88"],"id":1}'

Body

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x8c"
}

Common Use Cases

  1. Real-time Analytics: Monitor the most recent blocks on Base for transaction volume trends.
  2. Historical Block Analysis: Compare transaction counts between specific time periods by querying blocks by their numbers.
  3. Dapp Performance Monitoring: Track how busy the Base network was during specific timeframes when your dapp experienced performance changes.
  4. Transaction Batching Strategy: Determine optimal times to submit transactions by analyzing recent block fullness.
  5. Network State Monitoring: Query the pending block to understand current network congestion levels.

Need RPC API keys?

Get 12.5M archival requests for free today.

Block Tag Examples

// Get transaction count for the latest block
{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["latest"],"id":1}
 
// Get transaction count for the earliest block (genesis)
{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["earliest"],"id":1}
 
// Get transaction count for the pending block
{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["pending"],"id":1}

Important Notes

  • The response result is a hexadecimal value that represents the total transaction count.
  • Compared to eth_getBlockTransactionCountByHash, this method allows querying by block number or tag, making it more versatile for certain applications.
  • For the Base chain, this method follows the same specifications as Ethereum but operates on Base's L2 blockchain.
  • When using "pending" as the block tag, the transaction count may vary as transactions are added to or removed from the pending block pool.