Overview
gRPC subscribers extend WebSocket subscribers with gRPC streaming capabilities:- Yellowstone gRPC - Geyser plugin-based streaming
- Laser gRPC - High-performance streaming service
- Lower latency than WebSocket subscriptions
- Higher throughput than polling
- Requires dedicated gRPC infrastructure
GrpcConfigs
Configuration for gRPC connections.Yellowstone Configuration
'yellowstone'
Client type (defaults to yellowstone if not specified)
string
required
gRPC endpoint URL (e.g., ‘https://grpc.example.com:443’)
string
required
Authentication token for the gRPC service
CommitmentLevel
Commitment level for updates (PROCESSED, CONFIRMED, or FINALIZED)
boolean
default:"false"
Whether to enable automatic reconnection on connection loss
object
gRPC channel options for advanced configuration
Laser Configuration
'laser'
required
Must be ‘laser’ for Laser gRPC client
Example Configurations
grpcUserAccountSubscriber
Subscribe to user account updates via gRPC.Constructor
GrpcConfigs
required
gRPC connection configuration
Program
required
Anchor program instance for the Drift protocol
PublicKey
required
Public key of the user account to subscribe to
ResubOpts
Options for automatic resubscription
Example Usage
grpcDriftClientAccountSubscriber
Subscribe to Drift protocol accounts (state, markets, oracles) via gRPC.Constructor
GrpcConfigs
required
gRPC connection configuration
Program
required
Anchor program instance for the Drift protocol
number[]
required
Array of perpetual market indexes to subscribe to
number[]
required
Array of spot market indexes to subscribe to
OracleInfo[]
required
Array of oracle information to subscribe to
boolean
required
Whether to automatically discover and subscribe to all markets
DelistedMarketSetting
required
How to handle delisted markets
ResubOpts
Options for automatic resubscription
Example Usage
grpcAccountSubscriber
Generic gRPC account subscriber for any account type.Creating a Subscriber
GrpcConfigs
required
gRPC connection configuration
string
required
Name of the account type (e.g., ‘state’, ‘market’)
Program
required
Anchor program instance
PublicKey
required
Public key of the account to subscribe to
(buffer: Buffer) => AccountType
Optional custom buffer decoder function
ResubOpts
Options for automatic resubscription
Client
Optional pre-configured gRPC client to reuse
Example Usage
Other gRPC Subscribers
The SDK provides gRPC subscribers for various account types:grpcUserStatsAccountSubscriber
grpcInsuranceFundStakeAccountSubscriber
Performance Characteristics
Latency Comparison
Throughput
gRPC subscribers can handle:- 1000+ updates per second
- Multiple concurrent account streams
- Lower overhead than WebSocket subscriptions
Resource Usage
- Network: Lower bandwidth than polling
- CPU: Moderate (protocol buffer decoding)
- Memory: Similar to WebSocket subscribers
Connection Management
Automatic Reconnection
Enable automatic reconnection on connection loss:Manual Reconnection
Handle reconnection manually:Best Practices
- Use connection pooling - Reuse gRPC clients across multiple subscribers
- Enable reconnection - Set
enableReconnect: truefor production - Monitor connection health - Listen to error events
- Choose appropriate commitment - Use CONFIRMED for balance of speed and safety
- Handle backpressure - Process updates quickly to avoid buffer overflow
- Secure credentials - Store gRPC tokens securely
Advantages Over WebSocket
- Lower latency - Direct streaming from validator
- Higher throughput - More efficient protocol
- Better error handling - Built-in reconnection
- Type safety - Protocol buffer schemas
- Multiplexing - Multiple streams over single connection
Infrastructure Requirements
Running Your Own gRPC Server
To run your own Yellowstone gRPC server:- Set up a Solana validator with Geyser plugin
- Install and configure Yellowstone gRPC plugin
- Configure authentication tokens
- Set up SSL/TLS certificates
- Configure firewall and network access
Using Hosted Services
Alternatively, use hosted gRPC services:- Triton - Managed Yellowstone gRPC infrastructure
- Helius - gRPC streaming service
- Custom providers - Various RPC providers offer gRPC endpoints