GetBlockHeight

Returns the current block height of the node.

Type: unary

Overview

GetBlockHeight returns the current block height of the connected Solana node. Block height represents the number of confirmed blocks since genesis and is commonly used to track chain progression and determine transaction finality.

This is useful for monitoring network health, implementing block-based timeouts, and coordinating multi-step transaction flows where you need to know the current chain state.

Parameters

NameTypeDescription
commitmentCommitmentLevelOptional. The commitment level: processed, confirmed, or finalized.

Response

FieldTypeDescription
block_heightuint64The current block height

Usage Examples

Node.js

1const grpc = require('@grpc/grpc-js');
2const protoLoader = require('@grpc/proto-loader');
3
4const packageDef = protoLoader.loadSync('geyser.proto', {
5  keepCase: true, longs: String, enums: String, defaults: true, oneofs: true
6});
7const proto = grpc.loadPackageDefinition(packageDef).geyser;
8const client = new proto.Geyser('[IP_ADDRESS]:[PORT]', grpc.credentials.createInsecure());
9
10client.getBlockHeight({}, (err, response) => {
11  if (err) { console.error(err); return; }
12  console.log('Response:', response);
13});

Rust

1use yellowstone_grpc_proto::geyser::geyser_client::GeyserClient;
2use tonic::transport::Channel;
3
4#[tokio::main]
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6    let channel = Channel::from_static("http://[IP_ADDRESS]:[PORT]")
7        .connect().await?;
8    let mut client = GeyserClient::new(channel);
9
10    let response = client.getBlockHeight(tonic::Request::new(())).await?;
11    println!("Response: {:?}", response.into_inner());
12
13    Ok(())
14}