GetBlockHeight
Returns the current block height that the node has processed. Block height is a monotonically increasing counter that increments with each new block, unlike slot numbers which can be skipped. This is the gRPC equivalent of the JSON-RPC getBlockHeight method.
Use block height to track chain progression, determine transaction finality windows, and verify that your node is keeping up with the network. Combined with GetLatestBlockhash, it helps you calculate how many blocks remain before a blockhash expires.
Type: Unary (request/response)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
commitment | CommitmentLevel | No | Commitment level: Processed (0), Confirmed (1), or Finalized (2). Default: Finalized |
Response
| Field | Type | Description |
|---|---|---|
block_height | uint64 | The current block height at the requested commitment level |
Code Examples
Node.js
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const packageDef = protoLoader.loadSync('geyser.proto', {
keepCase: true, longs: String, enums: String, defaults: true, oneofs: true
});
const proto = grpc.loadPackageDefinition(packageDef).geyser;
const client = new proto.Geyser('88.216.36.108:10001', grpc.credentials.createInsecure());
// Get block height at Finalized commitment
client.getBlockHeight({ commitment: 2 }, (err, response) => {
if (err) { console.error('gRPC error:', err); return; }
console.log('Current block height:', response.block_height);
});Rust
use yellowstone_grpc_client::GeyserGrpcClient;
use yellowstone_grpc_proto::prelude::*;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut client = GeyserGrpcClient::build_from_uri("http://88.216.36.108:10001")
.connect()
.await?;
let response = client
.get_block_height(Some(CommitmentLevel::Finalized as i32))
.await?;
let result = response.into_inner();
println!("Current block height: {}", result.block_height);
Ok(())
}Example Response
{
"block_height": "230000042"
}