Blocks Subscription
Streams complete blocks as they are produced, including transactions and account changes.
Type: streaming (via Subscribe)
Overview
The Blocks subscription streams full block data as blocks are produced. Each block update can include transactions, account state changes, rewards, and metadata depending on your filter configuration.
This is the most data-intensive subscription type but provides the most complete view of chain activity. Use the filter options to control which data is included to reduce bandwidth.
Filters
| Name | Type | Description |
|---|---|---|
| account_include | string[] | Include blocks touching these accounts |
| include_transactions | bool | Include transaction data in blocks |
| include_accounts | bool | Include account diffs in blocks |
| include_entries | bool | Include ledger entries |
Update Payload
| Field | Type | Description |
|---|---|---|
| slot | uint64 | The block's slot |
| blockhash | string | The block hash |
| parent_slot | uint64 | Parent slot |
| parent_blockhash | string | Parent block hash |
| transactions | TransactionInfo[] | Transactions in the block |
| block_time | int64 | Estimated production time |
| block_height | uint64 | Block height |
| rewards | Reward[] | Block rewards |
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
10const stream = client.subscribe(new grpc.Metadata());
11
12stream.on('data', (data) => {
13 console.log('Blocks update:', data);
14});
15stream.on('error', (err) => console.error('Error:', err));
16
17// Subscribe to Blocks
18stream.write({
19 accounts: {},
20 slots: {},
21 transactions: {},
22 blocks: {},
23 blocksMeta: {},
24 commitment: 'processed',
25 entry: {}
26});Rust
1use yellowstone_grpc_proto::geyser::geyser_client::GeyserClient;
2use yellowstone_grpc_proto::geyser::SubscribeRequest;
3use tonic::transport::Channel;
4
5#[tokio::main]
6async fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let channel = Channel::from_static("http://[IP_ADDRESS]:[PORT]")
8 .connect().await?;
9 let mut client = GeyserClient::new(channel);
10
11 // Configure your Blocks subscription filters here
12 let request = SubscribeRequest {
13 accounts: Default::default(),
14 slots: Default::default(),
15 transactions: Default::default(),
16 blocks: Default::default(),
17 blocks_meta: Default::default(),
18 commitment: Some(1), // Processed
19 entry: Default::default(),
20 };
21
22 let mut stream = client.subscribe(std::iter::once(request)).await?.into_inner();
23 while let Some(msg) = stream.message().await? {
24 println!("Blocks update: {:?}", msg);
25 }
26 Ok(())
27}