gRPC Unary Methods

Standard request/response methods available alongside streaming subscriptions. These provide the same data as their JSON-RPC equivalents but with significantly lower latency through the Yellowstone Geyser plugin.

Available Methods

MethodDescription
GetLatestBlockhashReturns the latest blockhash for transaction signing
GetBlockHeightReturns the current block height
GetSlotReturns the current slot
GetBlockReturns full block data for a given slot
GetTransactionReturns transaction details by signature
GetVersionReturns the Geyser plugin version
GetGenesisHashReturns the genesis hash
GetFeeForMessageReturns the fee for a given message
IsBlockhashValidChecks if a blockhash is still valid
SubscribeOpens a bidirectional streaming subscription

Commitment Levels

All unary methods accept an optional commitment parameter:

ValueLevelDescription
0ProcessedFastest. Node has processed but not confirmed the block.
1ConfirmedSupermajority of the cluster has voted on the block.
2FinalizedBlock is confirmed and the supermajority has rooted it.

Quick Example

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// Get the latest blockhash
11client.getLatestBlockhash({ commitment: 1 }, (err, response) => {
12  if (err) { console.error(err); return; }
13  console.log('Blockhash:', response.blockhash);
14  console.log('Last valid block height:', response.last_valid_block_height);
15});
16
17// Get current slot
18client.getSlot({ commitment: 1 }, (err, response) => {
19  if (err) { console.error(err); return; }
20  console.log('Current slot:', response.slot);
21});