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
Block identifier: `{"block_hash": "0x..."}`, `{"block_number": 123456}`, `"latest"`, or `"pending"`
Response Body
Number of transactions in the block
Error Responses
Errors
| Code | Message | Description |
|---|---|---|
| 24 | Block not found | The specified block hash or number does not exist |
Examples
# 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
Related Methods
- starknet_getBlockWithTxs - Get block with full transaction objects
- starknet_getBlockWithTxHashes - Get block with transaction hashes only
- starknet_blockNumber - Get the latest block number
- starknet_getBlockWithReceipts - Get block with transaction receipts
- starknet_blockHashAndNumber - Get latest block hash and number
starknet_estimateMessageFee - Estimate L1-to-L2 Message Fee
Estimate the L2 fee for processing a message sent from Ethereum L1 to Starknet L2. Essential for cross-layer communication and bridge integrations.
starknet_getBlockWithReceipts - Get block I...
Get block information with full transactions and receipts given the block id