Docs

starknet_getBlockTransactionCount - Get Block Transaction Count

Get the number of transactions in a Starknet block by block ID. Useful for block analysis, throughput monitoring, and indexing pipelines.

Returns the number of transactions in a specific Starknet block. The block can be identified by hash, number, or the "latest" / "pending" tags.

Overview

This method provides a lightweight way to query block activity without fetching full block data. It is commonly used in monitoring dashboards, indexing pipelines, and throughput analysis tools. Starknet processes batches of transactions into blocks that are then proven and submitted to Ethereum L1, so transaction count per block is a useful metric for understanding network load.

Starknet blocks can contain various transaction types including INVOKE, DECLARE, DEPLOY_ACCOUNT, and L1_HANDLER transactions. This method counts all transaction types in the block.

Request Parameters

Request
block_idobject | string

Block identifier: `{"block_hash": "0x..."}`, `{"block_number": 123456}`, `"latest"`, or `"pending"`

Response Body

Response
resultinteger

Number of transactions in the block

Error Responses

Errors
Error 1
Error 2
Error 3
Error 4

Errors

CodeMessageDescription
24Block not foundThe specified block hash or number does not exist

Examples

Bash
# Get transaction count for a specific block number
curl -X POST https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "starknet_getBlockTransactionCount",
    "params": [{"block_number": 800000}],
    "id": 1
  }'

# Get transaction count for the latest block
curl -X POST https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "starknet_getBlockTransactionCount",
    "params": ["latest"],
    "id": 1
  }'

# Get transaction count by block hash
curl -X POST https://api-starknet-mainnet.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "starknet_getBlockTransactionCount",
    "params": [
      {"block_hash": "0x07d328a71faf48c5c3857e99f20a77b18522480956d1cd5bff1ff2df3c8b427b"}
    ],
    "id": 1
  }'

Use Cases

  • Throughput Monitoring - Track Starknet network activity and transaction volume over time
  • Block Explorer - Display transaction counts in block list views without fetching full block data
  • Indexing Pipelines - Pre-allocate resources or decide batch sizes based on block transaction counts
  • Network Health - Detect anomalous blocks (empty or unusually large) for alerting
  • Analytics Dashboards - Calculate average transactions per block for network performance metrics