GetBlock
Returns a complete block by slot number, including all transactions and account state changes.
Type: unary
Overview
GetBlock retrieves a full block for a given slot. The response includes all transactions in the block, their statuses, account state changes, and rewards. This is essential for indexing, analytics, and block explorers.
For high-throughput applications, consider using the Subscribe streaming method with block filters instead, as it provides real-time block delivery without polling overhead.
Parameters
| Name | Type | Description |
|---|---|---|
| slot | uint64 | Required. The slot number of the block to retrieve |
| commitment | CommitmentLevel | Optional. The commitment level |
Response
| Field | Type | Description |
|---|---|---|
| slot | uint64 | The slot of this block |
| blockhash | string | The blockhash of this block |
| parent_slot | uint64 | The slot of the parent block |
| parent_blockhash | string | The blockhash of the parent |
| transactions | TransactionInfo[] | All transactions in the block |
| rewards | Reward[] | Block rewards (validator, staking) |
| block_time | int64 | Estimated production time (Unix timestamp) |
| block_height | uint64 | The 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.getBlock({}, (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.getBlock(tonic::Request::new(())).await?;
11 println!("Response: {:?}", response.into_inner());
12
13 Ok(())
14}