getTransactionCount
Returns the current Transaction count from the ledger
Common use cases
| Network activity monitoring | Track cumulative transaction throughput by polling at intervals to verify the ledger is processing transactions and measure network activity over time. |
| Load balancer health checks | Verify RPC node liveness by confirming transaction count increases between requests, indicating the node is synced and processing ledger updates. |
| Transactions per block calculation | Combine with getBlockHeight at matching commitment levels to derive average transactions per block by dividing transaction count by block height. |
Parameters
config (object, optional)
Configuration object containing the following fields:
Fields:
commitment(string): The commitment describes how finalized a block is at that point in time. See Configuring State Commitment.minContextSlot(number): The minimum slot that the request can be evaluated at
Request
- cURL
- JavaScript
- Python
curl https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "getTransactionCount",
"params": [
{
"commitment": "finalized"
}
]
}'
// Using fetch
const response = await fetch('https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"jsonrpc": "2.0",
"id": 1,
"method": "getTransactionCount",
"params": [
{
"commitment": "finalized"
}
]
})
});
const data = await response.json();
console.log(data);
import requests
import json
url = 'https://solana-mainnet.api.syndica.io/api-key/YOUR_API_KEY'
headers = {'Content-Type': 'application/json'}
data = {
"jsonrpc": "2.0",
"id": 1,
"method": "getTransactionCount",
"params": [
{
"commitment": "finalized"
}
]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Replace mainnet with devnet in the URL to query devnet instead.
Response
{
"jsonrpc": "2.0",
"result": 268,
"id": 1
}
Response Fields
Return value: u64
The current Transaction count from the ledger
FAQ and Troubleshooting
Why does getTransactionCount sometimes return smaller numbers than previous calls?
You're hitting different RPC nodes with varying sync states. Use minContextSlot to ensure the RPC has caught up to at least a specific slot.
Does getTransactionCount return transactions for a specific slot?
No, it returns the cumulative total of all transactions processed since genesis. For per-slot counts, poll at each slot and calculate the difference.
What does the minContextSlot parameter do?
It ensures the RPC node has caught up to at least that slot before responding. It doesn't filter transactions by slot—the method always returns the cumulative total at the specified commitment level.
How do I calculate transactions per block?
Call getTransactionCount and getBlockHeight with the same commitment level, then divide transaction count by block height for the average.
Related Methods
getBlockHeight
Returns current block height at specified commitment. Pair with getTransactionCount to calculate average transactions per block by dividing counts.
getSlot
Returns current slot number at specified commitment. Use as minContextSlot parameter to ensure RPC sync state when querying transaction count.
getHealth
Returns node health status (ok or error). Combine with increasing transaction counts to verify node is both healthy and actively syncing.
External Resources
- Solana Official Documentation
- Solana Architecture: Transaction Processing - Official overview of how Solana processes transactions, providing context for interpreting transaction counts and ledger state.