in-solana by Supanode

getBlockHeight — Solana RPC Method

getBlockHeight returns the current block height of the node. Block height counts only the slots where a block was actually produced, starting from zero at genesis.

Parameters

NameTypeRequiredDescription
commitmentstringNoprocessed, confirmed, or finalized. Default: finalized.
minContextSlotnumberNoMinimum slot at which the request can be evaluated.

Request

curl -X POST https://api.mainnet-beta.solana.com \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getBlockHeight",
    "params": []
  }'

TypeScript (@solana/kit)

import { createSolanaRpc } from "@solana/kit";

const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const blockHeight = await rpc.getBlockHeight().send();

console.log(`Current block height: ${blockHeight}`);

Response

{
  "jsonrpc": "2.0",
  "result": 289442880,
  "id": 1
}
FieldTypeDescription
resultu64Current block height — the number of blocks produced since genesis.

Common errors

  • Node behind — if minContextSlot is set higher than the node’s current slot, the request fails with a slot-not-reached error. Remove minContextSlot or wait for the node to catch up.

Performance

getBlockHeight is one of the lightest RPC calls — it returns a single number from the node’s local state. It is safe to poll at high frequency for monitoring or progress tracking.

FAQ

What is the difference between slot and block height? A slot is a scheduled time window (approximately 400ms) for a validator to produce a block. Not every slot produces a block — some are skipped. Block height counts only the slots where a block was successfully produced. Block height is always less than or equal to the slot number.

How fast does block height increase? Solana targets approximately 2.5 blocks per second (400ms per slot). In practice, the rate varies depending on skip rate. Mainnet typically produces around 2 blocks per second.

Can I use block height to estimate time? Roughly, yes. At approximately 2 blocks per second, 1,000 blocks is about 8 minutes. However, the actual rate fluctuates. For precise timestamps, use getBlockTime on a specific slot.

Does block height differ by commitment level? Yes. processed returns the highest block height the node has seen, including optimistically confirmed blocks. finalized returns only fully finalized blocks, which lag behind processed by 32 or more slots.

How is block height useful in practice? Block height is commonly used to set transaction expiration. The lastValidBlockHeight field from getLatestBlockhash gives a block-height deadline beyond which the transaction is dropped if not confirmed.

Parameters

ParameterTypeRequiredDescriptionDefault
commitmentstringNoCommitment level: processed, confirmed, or finalized.finalized
minContextSlotnumberNoMinimum slot at which the request can be evaluated.—

Updated: