Skip to main content
The RPC module provides strongly-typed response objects for all Solana JSON-RPC methods.

Common Response Types

Context

Package: software.sava.rpc.json.http.response File: Context.java Provides slot context for RPC responses.
public record Context(long slot)
slot
long
Slot at which the data was queried
Used in most RPC responses to indicate the slot context.

Account Responses

AccountInfo

Package: software.sava.rpc.json.http.response File: AccountInfo.java:20 Generic account information with typed data.
public record AccountInfo<T>(
    PublicKey pubKey,
    Context context,
    boolean executable,
    long lamports,
    PublicKey owner,
    BigInteger rentEpoch,
    int space,
    T data
) implements DecimalIntegerAmount
pubKey
PublicKey
Account public key
context
Context
Slot context when data was fetched
executable
boolean
Whether the account is executable (program)
lamports
long
Account balance in lamports
owner
PublicKey
Program that owns this account
rentEpoch
BigInteger
Epoch at which rent is due
space
int
Data size in bytes
data
T
Account data (generic type based on factory function)
See AccountInfo.java:20-27.

BYTES_IDENTITY

Default factory for raw byte data.
static BiFunction<PublicKey, byte[], byte[]> BYTES_IDENTITY
Example:
// Get account as raw bytes
var accountInfo = client.getAccountInfo(
    publicKey,
    AccountInfo.BYTES_IDENTITY
).join();

byte[] data = accountInfo.data();
See AccountInfo.java:29.

Lamports

Package: software.sava.rpc.json.http.response File: Lamports.java Balance response with context.
public record Lamports(Context context, long lamports)
context
Context
Slot context
lamports
long
Account balance in lamports
Example:
var balance = client.getBalance(publicKey).join();
System.out.println("Balance: " + balance.lamports() + " lamports");
System.out.println("At slot: " + balance.context().slot());

AccountLamports

Package: software.sava.rpc.json.http.response File: AccountLamports.java Account balance with public key (used in getLargestAccounts).
public record AccountLamports(PublicKey pubKey, long lamports)

Transaction Responses

Tx

Package: software.sava.rpc.json.http.response File: Tx.java:11 Full transaction information.
public record Tx(
    int slot,
    OptionalLong blockTime,
    TxMeta meta,
    byte[] data,
    int version
)
slot
int
Slot in which transaction was processed
blockTime
OptionalLong
Estimated block time (Unix timestamp)
meta
TxMeta
Transaction metadata including fees and status
data
byte[]
Raw transaction data (base64 decoded)
version
int
Transaction version (0 for versioned, negative for legacy)
See Tx.java:11-15.

isLegacy()

Check if transaction is legacy format.
boolean isLegacy()
Returns: true if version < 0 See Tx.java:17-19.

TxStatus

Package: software.sava.rpc.json.http.response File: TxStatus.java:13 Transaction confirmation status.
public record TxStatus(
    Context context,
    long slot,
    OptionalInt confirmations,
    TransactionError error,
    Commitment confirmationStatus
)
context
Context
Slot context
slot
long
Slot where transaction was processed
confirmations
OptionalInt
Number of confirmations (empty if rooted)
error
TransactionError
Error if transaction failed, null if successful
confirmationStatus
Commitment
Confirmation level (PROCESSED, CONFIRMED, FINALIZED)
See TxStatus.java:13-17. Example:
var statuses = client.getSignatureStatuses(List.of(txSig)).join();
var status = statuses.get(txSig);

if (status.error() == null) {
    System.out.println("Success! Status: " + status.confirmationStatus());
} else {
    System.err.println("Failed: " + status.error());
}

TxSig

Package: software.sava.rpc.json.http.response File: TxSig.java Transaction signature with metadata.
public record TxSig(
    String signature,
    long slot,
    Long blockTime,
    TransactionError err,
    String memo,
    Commitment confirmationStatus
)
Returned by getSignaturesForAddress().

TxResult

Package: software.sava.rpc.json.http.response File: TxResult.java WebSocket transaction result.
public record TxResult(
    Context context,
    TransactionError error
)
Used in WebSocket signature subscriptions.

TxLogs

Package: software.sava.rpc.json.http.response File: TxLogs.java Transaction logs from WebSocket subscription.
public record TxLogs(
    String signature,
    TransactionError error,
    List<String> logs
)

Block Responses

Block

Package: software.sava.rpc.json.http.response File: Block.java:12 Complete block information.
public record Block(
    long blockHeight,
    long blockTime,
    String blockHash,
    String previousBlockHash,
    long parentSlot,
    List<TxReward> rewards,
    List<String> signatures,
    List<BlockTx> transactions
)
blockHeight
long
Block height
blockTime
long
Unix timestamp
blockHash
String
Blockhash (base58)
previousBlockHash
String
Previous block’s hash
parentSlot
long
Parent slot number
rewards
List<TxReward>
Block rewards
signatures
List<String>
Transaction signatures (if BlockTxDetails.signatures)
transactions
List<BlockTx>
Transaction details (if BlockTxDetails.full)
See Block.java:12-19.

BlockHeight

Package: software.sava.rpc.json.http.response File: BlockHeight.java Current block height with context.
public record BlockHeight(Context context, long blockHeight)

LatestBlockHash

Package: software.sava.rpc.json.http.response File: LatestBlockHash.java:8 Latest blockhash for transaction signing.
public record LatestBlockHash(
    Context context,
    String blockHash,
    long lastValidBlockHeight
)
context
Context
Slot context
blockHash
String
Recent blockhash (base58)
lastValidBlockHeight
long
Block height after which this blockhash is no longer valid
See LatestBlockHash.java:8. Example:
var blockHash = client.getLatestBlockHash().join();

var transaction = Transaction.builder()
    .recentBlockHash(blockHash.blockHash())
    .build();

// Transaction valid until this block height
long validUntil = blockHash.lastValidBlockHeight();

Network State Responses

EpochInfo

Package: software.sava.rpc.json.http.response File: EpochInfo.java Current epoch information.
public record EpochInfo(
    long absoluteSlot,
    long blockHeight,
    long epoch,
    long slotIndex,
    long slotsInEpoch,
    long transactionCount
)
absoluteSlot
long
Current absolute slot
blockHeight
long
Current block height
epoch
long
Current epoch number
slotIndex
long
Slot within current epoch
slotsInEpoch
long
Total slots in this epoch
transactionCount
long
Total transactions processed

NodeHealth

Package: software.sava.rpc.json.http.response File: NodeHealth.java Node health status.
public record NodeHealth(String status)
Example:
var health = client.getHealth().join();
if ("ok".equals(health.status())) {
    System.out.println("Node is healthy");
}

ClusterNode

Package: software.sava.rpc.json.http.response File: ClusterNode.java Cluster node information.
public record ClusterNode(
    PublicKey pubkey,
    String gossip,
    String tpu,
    String rpc,
    String version,
    Long featureSet,
    int shredVersion
)

Identity

Package: software.sava.rpc.json.http.response File: Identity.java Node identity.
public record Identity(PublicKey identity)

Token Responses

TokenAmount

Package: software.sava.rpc.json.http.response File: TokenAmount.java Token balance with decimals.
public record TokenAmount(
    Context context,
    String amount,
    int decimals,
    String uiAmountString
)
context
Context
Slot context
amount
String
Raw token amount (no decimals)
decimals
int
Number of decimal places
uiAmountString
String
UI-friendly amount with decimals
Example:
var tokenBalance = client.getTokenAccountBalance(tokenAccount).join();
System.out.println("Balance: " + tokenBalance.uiAmountString());
System.out.println("Raw: " + tokenBalance.amount());
System.out.println("Decimals: " + tokenBalance.decimals());

AccountTokenAmount

Package: software.sava.rpc.json.http.response File: AccountTokenAmount.java Token account with balance.
public record AccountTokenAmount(
    PublicKey address,
    String amount,
    int decimals,
    String uiAmountString
)
Used by getTokenLargestAccounts().

Performance Responses

PerfSample

Package: software.sava.rpc.json.http.response File: PerfSample.java Performance sample data.
public record PerfSample(
    long slot,
    long numTransactions,
    long numSlots,
    long samplePeriodSecs
)

PrioritizationFee

Package: software.sava.rpc.json.http.response File: PrioritizationFee.java Recent prioritization fee.
public record PrioritizationFee(
    long slot,
    long prioritizationFee
)
Example:
var fees = client.getRecentPrioritizationFees().join();
for (var fee : fees) {
    System.out.println("Slot " + fee.slot() + ": " + fee.prioritizationFee());
}

Additional Response Types

The module includes many more response types:
  • Supply: Supply - Total token supply information
  • Inflation: InflationGovernor, InflationRate, InflationReward
  • Stake: StakeState
  • Block Production: BlockProduction, BlockCommitment
  • Slots: ProcessedSlot, HighestSnapshotSlot
  • Version: Version - RPC API version
  • Voting: VoteAccount, VoteAccounts
  • Fee: FeeForMessage, FeeCalculator

Usage Patterns

Generic Account Deserialization

public record MyAccount(PublicKey owner, long amount) {
    static final BiFunction<PublicKey, byte[], MyAccount> FACTORY = 
        (pubKey, data) -> {
            // Deserialize data into MyAccount
            var owner = PublicKey.readPubKey(data, 0);
            var amount = ByteUtils.readLong(data, 32);
            return new MyAccount(owner, amount);
        };
}

// Use factory with getAccountInfo
var accountInfo = client.getAccountInfo(
    publicKey,
    MyAccount.FACTORY
).join();

MyAccount myAccount = accountInfo.data();
System.out.println("Owner: " + myAccount.owner());
System.out.println("Amount: " + myAccount.amount());

Handling Optional Values

var tx = client.getTransaction(txSig).join();

// Handle optional block time
tx.blockTime().ifPresent(time -> {
    System.out.println("Block time: " + Instant.ofEpochSecond(time));
});

// Handle transaction errors
var status = client.getSignatureStatuses(List.of(txSig)).join().get(txSig);
if (status.error() != null) {
    System.err.println("Transaction failed: " + status.error());
} else {
    System.out.println("Transaction succeeded");
}

Working with Context

var balance = client.getBalance(publicKey).join();

System.out.println("Balance: " + balance.lamports());
System.out.println("Queried at slot: " + balance.context().slot());

// Compare contexts for consistency
var account = client.getAccountInfo(publicKey).join();
if (account.context().slot() == balance.context().slot()) {
    System.out.println("Data from same slot");
}

See Also

Build docs developers (and LLMs) love