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
| Method | Description |
|---|---|
| GetLatestBlockhash | Returns the latest blockhash for transaction signing |
| GetBlockHeight | Returns the current block height |
| GetSlot | Returns the current slot |
| GetBlock | Returns full block data for a given slot |
| GetTransaction | Returns transaction details by signature |
| GetVersion | Returns the Geyser plugin version |
| GetGenesisHash | Returns the genesis hash |
| GetFeeForMessage | Returns the fee for a given message |
| IsBlockhashValid | Checks if a blockhash is still valid |
| Subscribe | Opens a bidirectional streaming subscription |
Commitment Levels
All unary methods accept an optional commitment parameter:
| Value | Level | Description |
|---|---|---|
0 | Processed | Earliest. Node has processed but not confirmed the block. |
1 | Confirmed | Supermajority of the cluster has voted on the block. |
2 | Finalized | Block is confirmed and the supermajority has rooted it. |
Quick Example
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const packageDef = protoLoader.loadSync('geyser.proto', {
keepCase: true, longs: String, enums: String, defaults: true, oneofs: true
});
const proto = grpc.loadPackageDefinition(packageDef).geyser;
const client = new proto.Geyser('88.216.36.108:10001', grpc.credentials.createInsecure());
// Get the latest blockhash
client.getLatestBlockhash({ commitment: 1 }, (err, response) => {
if (err) { console.error(err); return; }
console.log('Blockhash:', response.blockhash);
console.log('Last valid block height:', response.last_valid_block_height);
});
// Get current slot
client.getSlot({ commitment: 1 }, (err, response) => {
if (err) { console.error(err); return; }
console.log('Current slot:', response.slot);
});