Documentation Index
Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
Use this file to discover all available pages before exploring further.
Install
The rpc feature is enabled by default.
Building the client
Here’s a client with every option set:
use orbitflare_sdk::{RpcClientBuilder, RetryPolicy, Result};
use std::time::Duration;
let client = RpcClientBuilder::new()
.url("http://ny.rpc.orbitflare.com")
.fallback_url("http://fra.rpc.orbitflare.com")
.fallback_url("http://ams.rpc.orbitflare.com")
.api_key("ORBIT-XXXXXX-NNNNNN-NNNNNN")
.commitment("confirmed")
.retry(RetryPolicy {
initial_delay: Duration::from_millis(100),
max_delay: Duration::from_secs(30),
multiplier: 2.0,
max_attempts: 5,
})
.timeout(Duration::from_secs(30))
.build()?;
Most of these have sensible defaults. A minimal setup:
let client = RpcClientBuilder::new()
.url("http://ny.rpc.orbitflare.com")
.build()?;
Builder methods
.url(url) - The primary endpoint to send requests to. If not set, the SDK checks the ORBITFLARE_RPC_URL environment variable.
.url("http://ny.rpc.orbitflare.com")
.urls(&[...]) - Set the primary and all fallbacks in one call. The first element is the primary, the rest are fallbacks.
.urls(&["http://ny.rpc.orbitflare.com", "http://fra.rpc.orbitflare.com", "http://ams.rpc.orbitflare.com"])
.fallback_url(url) - Add a single fallback endpoint. Call multiple times to add several. When the primary fails, the SDK tries fallbacks in order.
.fallback_url("http://fra.rpc.orbitflare.com")
.fallback_url("http://ams.rpc.orbitflare.com")
.fallback_urls(&[...]) - Same as fallback_url but takes a slice.
.fallback_urls(&["http://fra.rpc.orbitflare.com", "http://ams.rpc.orbitflare.com"])
.api_key(key) - Your OrbitFlare license key. If not set, the SDK checks ORBITFLARE_LICENSE_KEY from the environment. The key is injected into the URL at request time, never stored in the endpoint.
.api_key("ORBIT-XXXXXX-NNNNNN-NNNNNN")
.commitment(level) - Default commitment level used for all typed helpers. Options: "processed", "confirmed", "finalized". Defaults to "confirmed".
.retry(policy) - Controls how the SDK retries failed requests. initial_delay is the wait before the first retry. multiplier scales the delay on each attempt. max_delay caps the backoff. max_attempts limits total retries per endpoint (0 means infinite). Defaults: 100ms initial, 30s max, 2x multiplier, infinite attempts.
use orbitflare_sdk::RetryPolicy;
use std::time::Duration;
.retry(RetryPolicy {
initial_delay: Duration::from_millis(200),
max_delay: Duration::from_secs(15),
multiplier: 2.0,
max_attempts: 5,
})
.timeout(duration) - HTTP timeout for each individual request. Defaults to 30 seconds.
.timeout(Duration::from_secs(10))
Available RPC methods
get_slot()
Returns the current slot number.
let slot: u64 = client.get_slot().await?;
get_balance(address)
Returns the balance in lamports for an account.
let lamports: u64 = client.get_balance("So11111111111111111111111111111111111111112").await?;
let sol = lamports as f64 / 1_000_000_000.0;
get_account_info(address)
Returns the full account data or None if the account doesn’t exist. Data is base64-encoded.
let account: Option<serde_json::Value> = client.get_account_info("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v").await?;
if let Some(info) = account {
println!("owner: {}", info["owner"]);
println!("lamports: {}", info["lamports"]);
println!("data length: {}", info["data"][0].as_str().unwrap_or("").len());
}
get_multiple_accounts(addresses)
Fetches multiple accounts in one call. Automatically chunks into batches of 100 (Solana’s per-request limit), so you can pass any number of addresses.
let accounts: Vec<Option<serde_json::Value>> = client
.get_multiple_accounts(&["addr1", "addr2", "addr3"])
.await?;
for (i, acct) in accounts.iter().enumerate() {
match acct {
Some(info) => println!("account {i}: {} lamports", info["lamports"]),
None => println!("account {i}: not found"),
}
}
get_latest_blockhash()
Returns the most recent blockhash and the last block height it’s valid for.
let (blockhash, last_valid_block_height): (String, u64) = client.get_latest_blockhash().await?;
get_transaction(signature)
Fetches a confirmed transaction by its signature. Returns the full transaction with metadata.
let tx: serde_json::Value = client.get_transaction("5K8F2j...").await?;
println!("slot: {}", tx["slot"]);
println!("fee: {}", tx["meta"]["fee"]);
get_signatures_for_address(address, limit)
Returns recent transaction signatures for an address, newest first.
let sigs: Vec<serde_json::Value> = client
.get_signatures_for_address("So111...", 10)
.await?;
for sig in &sigs {
println!("{} at slot {}", sig["signature"], sig["slot"]);
}
get_program_accounts(program_id)
Returns all accounts owned by a program. Can return a lot of data.
let accounts: Vec<serde_json::Value> = client
.get_program_accounts("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA")
.await?;
get_recent_prioritization_fees(addresses)
Returns recent priority fees for a set of accounts. Useful for estimating compute unit pricing.
let fees: Vec<serde_json::Value> = client
.get_recent_prioritization_fees(&["6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"])
.await?;
for fee in &fees {
println!("slot {}: {} micro-lamports", fee["slot"], fee["prioritizationFee"]);
}
send_transaction(tx_base64)
Sends a signed transaction to the network. Takes a base64-encoded serialized transaction. Returns the transaction signature.
let signature: String = client.send_transaction(tx_base64).await?;
println!("sent: {signature}");
simulate_transaction(tx_base64)
Simulates a transaction without submitting it. Returns logs, compute units consumed, and any errors.
let result: serde_json::Value = client.simulate_transaction(tx_base64).await?;
if let Some(err) = result["err"].as_str() {
println!("simulation failed: {err}");
} else {
println!("compute units: {}", result["unitsConsumed"]);
}
get_token_accounts_by_owner(owner, mint, program_id)
Returns token accounts for a wallet. Pass either a specific mint or a token program ID. If both are None, defaults to the SPL Token program.
let tokens: Vec<serde_json::Value> = client
.get_token_accounts_by_owner("wallet_address", None, None)
.await?;
for token in &tokens {
let info = &token["account"]["data"]["parsed"]["info"];
println!("mint: {} balance: {}",
info["mint"],
info["tokenAmount"]["uiAmountString"],
);
}
get_transactions_for_address(address, options)
OrbitFlare-specific method that combines getSignaturesForAddress and getTransaction into one call. Returns a GetTransactionsResult with the data array and an optional pagination_token for fetching the next page.
Supports four detail levels (signatures, none, accounts, full), bidirectional sorting, time/slot filtering, status filtering, and token account inclusion.
use orbitflare_sdk::{GetTransactionsOptions, GetTransactionsFilters, RangeFilter};
let result = client.get_transactions_for_address(
"address",
GetTransactionsOptions::new()
.transaction_details("full")
.limit(100)
.sort_order("asc")
.filters(
GetTransactionsFilters::new()
.token_accounts("all")
.status("succeeded")
.block_time(RangeFilter {
gte: Some(1704067200),
lte: Some(1706745600),
..Default::default()
})
),
).await?;
for tx in &result.data {
println!("slot {}", tx["slot"]);
}
if let Some(token) = result.pagination_token {
// fetch next page using .pagination_token(&token)
}
request(method, params)
Call any RPC method by name. The SDK builds the JSON-RPC envelope, handles retry and failover, and returns the result field.
use serde_json::json;
let epoch = client.request("getEpochInfo", json!([])).await?;
let inflation = client.request("getInflationRate", json!([])).await?;
let supply = client.request("getSupply", json!([])).await?;
request_raw(body)
Send a raw JSON-RPC body string. Same retry and failover as everything else.
let result = client
.request_raw(r#"{"jsonrpc":"2.0","id":1,"method":"getHealth","params":[]}"#)
.await?;
Full example
A script that checks the state of the network, fetches a wallet’s SOL balance and token holdings, and looks up recent transactions.
use orbitflare_sdk::{RpcClientBuilder, Result};
#[tokio::main]
async fn main() -> Result<()> {
let client = RpcClientBuilder::new()
.url("http://ny.rpc.orbitflare.com")
.fallback_url("http://fra.rpc.orbitflare.com")
.commitment("confirmed")
.build()?;
let wallet = "CKs1E69a2e9TmH4mKKLrXFF8kD3ZnwKjoEuXa6sz9WqX";
let slot = client.get_slot().await?;
let (blockhash, _) = client.get_latest_blockhash().await?;
println!("network slot: {slot}");
println!("blockhash: {blockhash}");
let balance = client.get_balance(wallet).await?;
println!("\n{wallet}");
println!(" SOL: {:.4}", balance as f64 / 1_000_000_000.0);
let tokens = client.get_token_accounts_by_owner(wallet, None, None).await?;
for token in &tokens {
let info = &token["account"]["data"]["parsed"]["info"];
let mint = info["mint"].as_str().unwrap_or("unknown");
let amount = info["tokenAmount"]["uiAmountString"].as_str().unwrap_or("0");
if amount != "0" {
println!(" {mint}: {amount}");
}
}
let sigs = client.get_signatures_for_address(wallet, 5).await?;
println!("\nrecent transactions:");
for sig in &sigs {
let signature = sig["signature"].as_str().unwrap_or("?");
let slot = sig["slot"].as_u64().unwrap_or(0);
let err = if sig["err"].is_null() { "ok" } else { "failed" };
println!(" {slot} {err} {}", &signature[..20]);
}
let fees = client
.get_recent_prioritization_fees(&[wallet])
.await?;
let avg: f64 = fees.iter()
.filter_map(|f| f["prioritizationFee"].as_f64())
.sum::<f64>() / fees.len().max(1) as f64;
println!("\navg priority fee: {avg:.0} micro-lamports");
Ok(())
}