getBlockHeight
The getBlockHeight method returns the current block height of the node. Block height represents the number of blocks beneath the current block in the ledger, providing a continuous, monotonically increasing counter that tracks blockchain progress independently of slot numbers.
Unlike slot numbers which can have gaps when slots are skipped (due to leader failures or network issues), block height provides a continuous sequence. This makes block height particularly useful for applications that need to track blockchain progress, calculate block intervals, or implement time-based logic. Block height increments by exactly one for each new block, whereas slot numbers might skip values if a validator fails to produce a block during their assigned slot.
This method is commonly used by monitoring tools, analytics platforms, and applications that need to implement block-based timing or synchronization. It's more reliable than slot numbers for measuring blockchain progress over time, as the continuous nature of block height eliminates the complexity of handling skipped slots.
Parameters
parameter | type | description |
|---|---|---|
config | object | Optional configuration object |
config.commitment | string | Level of commitment: 'processed', 'confirmed', or 'finalized' (default: 'finalized') |
config.minContextSlot | number | Optional. Minimum slot that the request can be evaluated at |
Return Object
field | type | description |
|---|---|---|
result | number | The current block height as an integer (u64) |
Request Example
Response Example
Tip: Block height is more reliable than slot number for measuring time elapsed on the blockchain since it's continuous without gaps. Use getBlockHeight for implementing block-based timeouts or intervals, and getSlot when you need the actual slot number for specific operations.