Skip to main content

getBlockHeight

Returns the current block height of the node

Common use cases
Transaction confirmation with expiry detectionPoll getBlockHeight during transaction confirmation to detect when current block height exceeds lastValidBlockHeight from getLatestBlockhash. Use height progression rather than wall-clock time to establish timeouts: if height advances but transaction isn't confirmed, check signature status; if height stalls, network may have issues; if height exceeds threshold, transaction has expired and requires new blockhash for retry.
Node synchronization monitoringCompare block heights across multiple RPC endpoints to verify node synchronization status. Healthy nodes should report similar block heights at the same commitment level; large discrepancies indicate synchronization lag or node issues.
Network health and skip rate analysisUse getBlockHeight alongside getSlot to calculate number of skipped slots in a range. Difference between slot number and block height reveals network skip rate, useful for performance analysis, validator health monitoring, and detecting consensus issues.

Parameters

config (object, optional)

Configuration object

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 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": "getBlockHeight",
"params": [
{
"commitment": "finalized"
}
]
}'
Network Selection

Replace mainnet with devnet in the URL to query devnet instead.

Response

{
"jsonrpc": "2.0",
"result": 1233,
"id": 1
}

Response Fields

Return value: u64

Current block height.

FAQ and Troubleshooting

What's the difference between block height and slot number?

Block height counts only produced blocks (skipped slots excluded), while slot number includes all slots whether blocks were produced or not. Block height is always ≤ slot number. Use getBlockHeight for counting actual blocks; use getSlot for slot-based timing or when calling slot-based methods like getBlock.

How do I use block height to detect transaction expiry?

When submitting a transaction, call getLatestBlockhash to obtain lastValidBlockHeight. Poll getBlockHeight during confirmation. If getBlockHeight result exceeds lastValidBlockHeight, the transaction blockhash has expired and transaction will never confirm. Retry with fresh blockhash from new getLatestBlockhash call.

Which commitment level should I use?

Use confirmed for most applications requiring balance between speed and safety. Use processed only for preliminary checks where reverts are acceptable. Use finalized when absolute finality is required (exchanges, irreversible operations), accepting 32-slot delay (~15 seconds).

Can block height decrease?

At processed commitment, block height can theoretically decrease during forks when validator switches to alternate chain. At confirmed and finalized commitments, block height is monotonically increasing and will never decrease.

Why would I use the minContextSlot parameter?

Set minContextSlot when you need block height evaluated at minimum slot level for consistency with other queries. Useful when coordinating multiple RPC calls to ensure they reflect same blockchain state, preventing race conditions from slot progression between calls.

getLatestBlockhash
Provides lastValidBlockHeight used as expiry threshold for transaction confirmation workflows. Call before submitting transactions to obtain expiry boundary, then monitor with getBlockHeight.

getSlot
Returns current slot number including skipped slots. Compare with block height to calculate skip rate. Use getSlot for slot-based timing; use getBlockHeight for counting actual blocks.

getSignatureStatuses
Polled alongside getBlockHeight during transaction confirmation to check both signature status and expiry. Combined polling enables robust confirmation with timeout detection.

getBlockTime
Returns Unix timestamp for a specific slot. Pair with getBlockHeight to correlate block heights with wall-clock time for historical analysis or timestamp-based workflows.

getBlock
Retrieves block data for specific slot. Block height can identify blocks when slot number is unknown; useful for historical queries spanning skipped-slot ranges.

External Resources