pub struct SolanaRpcClient { /* private fields */ }Expand description
Blocking Solana JSON-RPC 2.0 client.
Mirrors the Python SolanaNetwork class from coldstar-devsyrem.
Implementations§
Source§impl SolanaRpcClient
impl SolanaRpcClient
Sourcepub fn new(rpc_url: Option<&str>) -> Result<Self>
pub fn new(rpc_url: Option<&str>) -> Result<Self>
Create a new client pointing at rpc_url.
The URL must start with http:// or https://. If None is
passed the default from ColdstarConfig is used.
Sourcepub fn from_config(cfg: &ColdstarConfig) -> Result<Self>
pub fn from_config(cfg: &ColdstarConfig) -> Result<Self>
Build a client from an existing ColdstarConfig.
Sourcepub fn get_balance(&self, pubkey: &str) -> Result<u64>
pub fn get_balance(&self, pubkey: &str) -> Result<u64>
Get SOL balance for pubkey in lamports.
Sourcepub fn get_balance_sol(&self, pubkey: &str) -> Result<f64>
pub fn get_balance_sol(&self, pubkey: &str) -> Result<f64>
Get SOL balance for pubkey in SOL (floating point).
Sourcepub fn get_latest_blockhash(&self) -> Result<String>
pub fn get_latest_blockhash(&self) -> Result<String>
Fetch the latest blockhash and last valid block height.
Sourcepub fn get_latest_blockhash_with_height(&self) -> Result<(String, u64)>
pub fn get_latest_blockhash_with_height(&self) -> Result<(String, u64)>
Fetch the latest blockhash together with the last valid block height.
Sourcepub fn get_minimum_balance_for_rent_exemption(
&self,
data_len: usize,
) -> Result<u64>
pub fn get_minimum_balance_for_rent_exemption( &self, data_len: usize, ) -> Result<u64>
Get the minimum lamport balance required for rent exemption at
data_len bytes of account data.
Sourcepub fn send_transaction(&self, signed_tx_base64: &str) -> Result<String>
pub fn send_transaction(&self, signed_tx_base64: &str) -> Result<String>
Broadcast a signed transaction encoded as base-64.
Returns the transaction signature on success.
Sourcepub fn confirm_transaction(
&self,
signature: &str,
timeout_secs: u64,
) -> Result<bool>
pub fn confirm_transaction( &self, signature: &str, timeout_secs: u64, ) -> Result<bool>
Poll getSignatureStatuses until the transaction reaches
confirmed or finalized, or the timeout elapses.
timeout_secs defaults to 30 if set to 0.
Sourcepub fn request_airdrop(&self, pubkey: &str, lamports: u64) -> Result<String>
pub fn request_airdrop(&self, pubkey: &str, lamports: u64) -> Result<String>
Request an airdrop of lamports to pubkey (devnet/testnet only).
Returns the airdrop transaction signature.
Sourcepub fn get_account_info(&self, pubkey: &str) -> Result<Option<AccountInfo>>
pub fn get_account_info(&self, pubkey: &str) -> Result<Option<AccountInfo>>
Get on-chain account information for pubkey.
Returns None when the account does not exist.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check whether the RPC endpoint is healthy.
Sourcepub fn get_network_info(&self) -> Result<NetworkInfo>
pub fn get_network_info(&self) -> Result<NetworkInfo>
Collect high-level network information (version, slot, epoch).
Sourcepub fn get_transaction_history(
&self,
pubkey: &str,
limit: usize,
) -> Result<Vec<TransactionRecord>>
pub fn get_transaction_history( &self, pubkey: &str, limit: usize, ) -> Result<Vec<TransactionRecord>>
Get recent transaction signatures for pubkey.
Sourcepub fn get_transaction_details(
&self,
signature: &str,
) -> Result<TransactionDetails>
pub fn get_transaction_details( &self, signature: &str, ) -> Result<TransactionDetails>
Get full details for a single transaction by signature.