sava-rpc module provides a complete implementation for interacting with Solana’s JSON-RPC API and WebSocket subscriptions. It handles HTTP communication, request/response serialization, and real-time data streaming.
Features
- HTTP RPC Client: Full implementation of Solana JSON-RPC methods
- WebSocket Subscriptions: Real-time account, program, and transaction updates
- Type Safety: Strongly-typed request and response objects
- Async Operations: CompletableFuture-based API for non-blocking operations
- Configurable: Builder pattern for client configuration
- Performance: Optimized JSON parsing with systems.comodal.json_iterator
Exported Packages
The module exports the following packages (frommodule-info.java:8-13):
Dependencies
Required modules:java.net.http- HTTP client functionalitysystems.comodal.json_iterator- High-performance JSON parsing (transitive)software.sava.core- Core types and utilities (transitive)
Quick Start
API Reference
SolanaRpcClient
Main RPC client interface with all JSON-RPC methods
HTTP Client
HTTP implementation and builder configuration
WebSocket Client
Real-time subscriptions for accounts and programs
Request Types
Commitment levels, filters, and request options
Response Types
Account info, transactions, blocks, and more
Commitment Levels
Understanding PROCESSED, CONFIRMED, and FINALIZED
Architecture
Client Hierarchy
Request Flow
- Method Call → Client method (e.g.,
getAccountInfo()) - JSON Construction → Build JSON-RPC request payload
- HTTP Request → Send POST request to endpoint
- Response Parsing → Parse JSON response with custom parsers
- Type Conversion → Convert to strongly-typed response objects
- CompletableFuture → Return async result to caller
Common Patterns
Generic Account Factory
Commitment Levels
Batch Operations
Performance Considerations
Request Timeouts
- Default: 8 seconds (
DEFAULT_REQUEST_TIMEOUT) - Program Accounts: 120 seconds (
PROGRAM_ACCOUNTS_TIMEOUT) - Configurable via
SolanaRpcClientBuilder.requestTimeout()
Rate Limits
The client enforces Solana RPC limits:MAX_MULTIPLE_ACCOUNTS = 100- Maximum accounts pergetMultipleAccountscallMAX_GET_SIGNATURES = 1000- Maximum signatures pergetSignaturesForAddresscallMAX_SIG_STATUS = 256- Maximum signatures pergetSignatureStatusescall
SolanaRpcClient.java:37-39.
Error Handling
Next Steps
- Explore the SolanaRpcClient interface for all available methods
- Learn about Commitment Levels for transaction finality
- Set up WebSocket subscriptions for real-time updates