Skip to main content
The SolanaRpcClient interface defines the complete API for interacting with Solana’s JSON-RPC endpoints. It provides type-safe, async methods for querying accounts, transactions, blocks, and network state.

Interface Definition

Package: software.sava.rpc.json.http.client File: SolanaRpcClient.java:35
public interface SolanaRpcClient

Constants

The interface defines important rate limit constants:
MAX_MULTIPLE_ACCOUNTS
int
default:"100"
Maximum number of accounts that can be requested in a single getMultipleAccounts() call
MAX_GET_SIGNATURES
int
default:"1000"
Maximum number of signatures that can be requested in getSignaturesForAddress()
MAX_SIG_STATUS
int
default:"256"
Maximum number of signatures for getSignatureStatuses()
Defined in SolanaRpcClient.java:37-39.

Factory Methods

build()

Create a new builder for configuring the RPC client.
static SolanaRpcClientBuilder build()
Returns: SolanaRpcClientBuilder instance Example:
var client = SolanaRpcClient.build()
    .endpoint(URI.create("https://api.mainnet-beta.solana.com"))
    .defaultCommitment(Commitment.CONFIRMED)
    .requestTimeout(Duration.ofSeconds(10))
    .createClient();
See SolanaRpcClient.java:41-43.

createClient()

Static factory methods for creating clients with various configurations.
static SolanaRpcClient createClient(
    URI endpoint,
    HttpClient httpClient,
    Duration requestTimeout,
    UnaryOperator<HttpRequest.Builder> extendRequest,
    Predicate<HttpResponse<byte[]>> applyResponse,
    Commitment defaultCommitment
)
Multiple overloaded versions available with sensible defaults. See SolanaRpcClient.java:45-82.

Core Properties

endpoint()

Get the RPC endpoint URI.
URI endpoint()

httpClient()

Get the underlying HTTP client.
HttpClient httpClient()

defaultCommitment()

Get the default commitment level for requests.
Commitment defaultCommitment()

Account Methods

getAccountInfo()

Fetch account information with optional custom deserialization.
<T> CompletableFuture<AccountInfo<T>> getAccountInfo(
    PublicKey account,
    BiFunction<PublicKey, byte[], T> factory
)
account
PublicKey
required
The account public key to query
factory
BiFunction<PublicKey, byte[], T>
Function to deserialize account data into type T
AccountInfo<T>
CompletableFuture
Account information with deserialized data
Variants (see SolanaRpcClient.java:102-170):
  • With commitment level
  • With minContextSlot
  • With data slice (length/offset)
  • Raw bytes (using BYTES_IDENTITY)
Example:
// Get account with custom type
var accountInfo = client.getAccountInfo(
    tokenAccount,
    (pubKey, data) -> TokenAccount.deserialize(data)
).join();

// Get raw bytes
var rawAccount = client.getAccountInfo(publicKey).join();

getMultipleAccounts()

Fetch multiple accounts in a single request (max 100).
<T> CompletableFuture<List<AccountInfo<T>>> getMultipleAccounts(
    SequencedCollection<PublicKey> keys,
    BiFunction<PublicKey, byte[], T> factory
)
keys
SequencedCollection<PublicKey>
required
Collection of account public keys (max 100)
factory
BiFunction<PublicKey, byte[], T>
Deserialization factory function
List<AccountInfo<T>>
CompletableFuture
List of account information (skips null entries)
Note: Non-existent accounts are skipped, not returned as null. Use getAccounts() for null preservation. See SolanaRpcClient.java:344-418 for all variants.

getAccounts()

Fetch multiple accounts preserving null entries for non-existent accounts.
<T> CompletableFuture<List<AccountInfo<T>>> getAccounts(
    SequencedCollection<PublicKey> keys,
    BiFunction<PublicKey, byte[], T> factory
)
Similar to getMultipleAccounts() but maintains null entries. See SolanaRpcClient.java:420-494.

getProgramAccounts()

Fetch all accounts owned by a program, with optional filters.
<T> CompletableFuture<List<AccountInfo<T>>> getProgramAccounts(
    PublicKey programId,
    BiFunction<PublicKey, byte[], T> factory
)
programId
PublicKey
required
Program public key
filters
Collection<Filter>
Optional filters (memcmp, dataSize)
factory
BiFunction<PublicKey, byte[], T>
Deserialization factory
List<AccountInfo<T>>
CompletableFuture
All accounts owned by the program
Default timeout: 120 seconds (PROGRAM_ACCOUNTS_TIMEOUT) See SolanaRpcClient.java:496-708 for extensive variants with filters, commitment, data slicing, and custom timeouts.

getBalance()

Get account lamport balance.
CompletableFuture<Lamports> getBalance(PublicKey account)
account
PublicKey
required
Account to query
commitment
Commitment
Optional commitment level
Lamports
CompletableFuture
Account balance with context
See SolanaRpcClient.java:171-173.

Transaction Methods

getTransaction()

Fetch transaction details by signature.
CompletableFuture<Tx> getTransaction(String txSignature)
txSignature
String
required
Transaction signature (base58)
commitment
Commitment
Optional commitment level
maxSupportedTransactionVersion
int
Maximum transaction version (0 for versioned transactions)
Tx
CompletableFuture
Transaction details including metadata
See SolanaRpcClient.java:819-824.

getSignaturesForAddress()

Fetch transaction signatures for an address.
CompletableFuture<List<TxSig>> getSignaturesForAddress(
    PublicKey address,
    int limit
)
address
PublicKey
required
Address to query
limit
int
required
Maximum signatures to return (max 1000)
beforeTxSig
String
Start searching backwards from this signature
untilTxSig
String
Search until this signature
List<TxSig>
CompletableFuture
Transaction signatures with metadata
See SolanaRpcClient.java:722-744.

getSignatureStatuses()

Get status of transaction signatures.
CompletableFuture<Map<String, TxStatus>> getSignatureStatuses(
    SequencedCollection<String> signatures
)
signatures
SequencedCollection<String>
required
Collection of transaction signatures (max 256)
searchTransactionHistory
boolean
default:"false"
Whether to search full transaction history
Map<String, TxStatus>
CompletableFuture
Map of signature to transaction status
See SolanaRpcClient.java:746-758.

sendTransaction()

Send a signed transaction to the cluster.
CompletableFuture<String> sendTransaction(
    Transaction transaction,
    Signer feePayer
)
See SolanaRpcClient.java:824+ (beyond line 824).

Block Methods

getBlock()

Fetch block information.
CompletableFuture<Block> getBlock(long slot)
slot
long
required
Block slot number
blockTxDetails
BlockTxDetails
default:"none"
Transaction detail level (full, signatures, none)
rewards
boolean
default:"true"
Include reward information
maxSupportedTransactionVersion
int
Maximum transaction version to support
Block
CompletableFuture
Block information with transactions
See SolanaRpcClient.java:175-236 for all variants.

getBlockHeight()

Get current block height.
CompletableFuture<BlockHeight> getBlockHeight()
See SolanaRpcClient.java:238-240.

getBlocks()

Get list of confirmed blocks.
CompletableFuture<long[]> getBlocks(long startSlot)
startSlot
long
required
Starting slot
endSlot
long
Ending slot (max 500,000 from start)
long[]
CompletableFuture
Array of block slot numbers
See SolanaRpcClient.java:262-268.

getBlockTime()

Get estimated block production time.
CompletableFuture<Instant> getBlockTime(long slot)
See SolanaRpcClient.java:274.

Network Methods

getHealth()

Check node health status.
CompletableFuture<NodeHealth> getHealth()
See SolanaRpcClient.java:90-100.

getLatestBlockHash()

Get latest blockhash for transaction signing.
CompletableFuture<LatestBlockHash> getLatestBlockHash()
commitment
Commitment
Optional commitment level
LatestBlockHash
CompletableFuture
Latest blockhash with last valid block height
See SolanaRpcClient.java:96-98.

getSlot()

Get current slot.
CompletableFuture<Long> getSlot()
See SolanaRpcClient.java:760-762.

getEpochInfo()

Get information about the current epoch.
CompletableFuture<EpochInfo> getEpochInfo()
See SolanaRpcClient.java:278-280.

getClusterNodes()

Get information about cluster nodes.
CompletableFuture<List<ClusterNode>> getClusterNodes()
See SolanaRpcClient.java:276.

getFeeForMessage()

Get fee for a message.
CompletableFuture<FeeForMessage> getFeeForMessage(String base64Msg)
base64Msg
String
required
Base64-encoded message
FeeForMessage
CompletableFuture
Fee calculation result
See SolanaRpcClient.java:92-94.

Token Methods

getTokenAccountBalance()

Get token account balance.
CompletableFuture<TokenAmount> getTokenAccountBalance(
    PublicKey tokenAccount
)
See SolanaRpcClient.java:778-780.

getTokenAccountsForTokenMintByOwner()

Get all token accounts for a specific mint owned by an address.
CompletableFuture<List<AccountInfo<TokenAccount>>> 
getTokenAccountsForTokenMintByOwner(
    PublicKey owner,
    PublicKey tokenMint
)
See SolanaRpcClient.java:796-801.

Additional Methods

The interface includes many more methods for:
  • Block production: getBlockProduction(), getBlockCommitment()
  • Leader schedule: getLeaderSchedule(), getSlotLeader()
  • Inflation: getInflationGovernor(), getInflationRate(), getInflationReward()
  • Supply: getSupply(), getTokenSupply()
  • Stake: getStakeMinimumDelegation()
  • Performance: getRecentPerformanceSamples(), getRecentPrioritizationFees()
  • Identity: getIdentity(), getGenesisHash()
See the full interface in SolanaRpcClient.java for complete method signatures.

See Also

Build docs developers (and LLMs) love