Learn getBlockHeight use cases, code examples, request parameters, response structure, and tips.
getBlockHeight
RPC method is a simple way to query a Solana node for its current block height. The block height represents the number of blocks that have been processed since the genesis block (slot 0).
This method is useful for quickly understanding how far the chain has progressed or for referencing the latest block height at a specific commitment level.
getBlockHeight
can optionally take a configuration object as its first parameter (or be called with no parameters to use defaults):
config
(object, optional): A configuration object with the following fields:
commitment
(string, optional): Specifies the commitment level to use for the query. Defaults to finalized
.
finalized
: The node will query the most recent block confirmed by the supermajority of the cluster as having reached maximum lockout.confirmed
: The node will query the most recent block that has been voted on by a supermajority of the cluster.processed
: The node will query its most recent block. Note that the block may not be complete.minContextSlot
(number, optional): The minimum slot that the request can be evaluated at. This ensures that the block height returned is from a slot equal to or greater than minContextSlot
.finalized
commitment.
commitment
level specified. finalized
gives the most stable height, while processed
might give a more current but potentially transient height.minContextSlot
for Consistency: Use minContextSlot
if you need to ensure the block height is queried from a state that is at least as recent as a specific slot you are tracking.getBlockHeight
can be part of a basic chain health or synchronization check for your application or monitoring system.result
field of the JSON-RPC response will be a single number:
blockHeight
(number): The current block height (u64) of the node according to the specified commitment level.YOUR_API_KEY
with your actual Helius API key in the examples below.