GetBlock
Returns the complete block data for a given slot number, including every transaction, reward, and piece of metadata the validator produced. This is the gRPC equivalent of the JSON-RPC getBlock method, delivering the same data with dramatically lower latency through the Yellowstone Geyser plugin.
Use this method when you need full block contents for indexing, analytics, or block-explorer functionality. For real-time block delivery without polling, consider using the Subscribe method with a Blocks filter instead.
Type: Unary (request/response)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
slot | uint64 | Yes | The slot number of the block to retrieve |
commitment | CommitmentLevel | No | Commitment level: Processed (0), Confirmed (1), or Finalized (2). Default: Finalized |
Response
| Field | Type | Description |
|---|---|---|
blockhash | string | The blockhash of the returned block |
parent_slot | uint64 | The slot of the parent block |
parent_blockhash | string | The blockhash of the parent block |
transactions | TransactionInfo[] | Array of all transactions in the block, including signatures, messages, and execution metadata |
rewards | Reward[] | Validator and staking rewards distributed in this block |
block_time | int64 | Estimated Unix timestamp when the block was produced |
block_height | uint64 | The block height (not the same as slot) |
Code 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
10// Fetch block at a specific slot with Confirmed commitment
11client.getBlock({ slot: 250000000, commitment: 1 }, (err, response) => {
12 if (err) { console.error('gRPC error:', err); return; }
13 console.log('Blockhash:', response.blockhash);
14 console.log('Parent slot:', response.parent_slot);
15 console.log('Transactions:', response.transactions.length);
16 console.log('Block time:', new Date(response.block_time * 1000).toISOString());
17 console.log('Block height:', response.block_height);
18});Rust
1use yellowstone_grpc_client::GeyserGrpcClient;
2use yellowstone_grpc_proto::prelude::*;
3
4#[tokio::main]
5async fn main() -> anyhow::Result<()> {
6 let mut client = GeyserGrpcClient::build_from_uri("http://[IP_ADDRESS]:[PORT]")
7 .connect()
8 .await?;
9
10 let response = client
11 .get_block(250_000_000, Some(CommitmentLevel::Confirmed as i32))
12 .await?;
13 let block = response.into_inner();
14
15 println!("Blockhash: {}", block.blockhash);
16 println!("Parent slot: {}", block.parent_slot);
17 println!("Transactions: {}", block.transactions.len());
18 println!("Block height: {}", block.block_height);
19
20 Ok(())
21}Example Response
1{
2 "blockhash": "7xkKzR2rL9JsVpHjWnBqoNjBEMpAv3RJRwbqTXmPYrjA",
3 "parent_slot": "249999999",
4 "parent_blockhash": "4Nd6LwMfvFbdFEiXQMfMqrj9cKjEMvkYPGcLaZGh4UbS",
5 "transactions": [
6 {
7 "signature": "5K4...",
8 "is_vote": false,
9 "meta": { "err": null, "fee": "5000", "compute_units_consumed": "150000" }
10 }
11 ],
12 "rewards": [
13 { "pubkey": "Vote111...", "lamports": "5000000", "reward_type": "Voting" }
14 ],
15 "block_time": "1704067200",
16 "block_height": "230000000"
17}