POST
/
6df1a1b3061097e66349993a96b8e535
curl --request POST \
  --url https://aurora-mainnet.core.chainstack.com/6df1a1b3061097e66349993a96b8e535 \
  --header 'Content-Type: application/json' \
  --data '{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "eth_getBlockTransactionCountByNumber",
  "params": [
    "latest"
  ]
}'
{
  "jsonrpc": "<string>",
  "id": 123,
  "result": "<string>"
}

Aurora API method that returns the number of transactions in a block specified by block number or tag. 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

  • 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 block. A chain reorganization is to be expected.
    • safe—the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or severe propagation latency.
    • finalized—the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, requiring burning at least 1/3 of the staked amount.
    • earliest — the earliest available or genesis block.
    • pending—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.

Response

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

eth_getBlockTransactionCountByNumber code examples

const { 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')

Use case

eth_getBlockTransactionCountByNumber can be used to analyze how many transactions are included on the Aurora blockchain in a certain period. For instance, on average, a new block is generated on the Aurora mainnet every 1.3 seconds, resulting in approximately 2769 blocks per hour. Using a Web3 library, one can inspect the past 2769 blocks starting from the latest block and use eth_getBlockTransactionCountByNumber to find the number of transactions in each block to sum them.

Body

application/json
id
integer
default:1
jsonrpc
string
default:2.0
method
string
default:eth_getBlockTransactionCountByNumber
params
string[]

The block number or tag.

Response

200 - application/json
The block transaction count information
jsonrpc
string
id
integer
result
string