pub struct SolanaClient { /* private fields */ }Expand description
Solana blockchain client.
Supports balance queries via JSON-RPC and optional transaction history via Solscan API.
Implementations§
Source§impl SolanaClient
impl SolanaClient
Sourcepub fn new(config: &ChainsConfig) -> Result<Self>
pub fn new(config: &ChainsConfig) -> Result<Self>
Creates a new Solana client with the given configuration.
§Arguments
config- Chain configuration containing RPC endpoint and API keys
§Returns
Returns a configured SolanaClient instance.
§Examples
use scope::chains::SolanaClient;
use scope::config::ChainsConfig;
let config = ChainsConfig::default();
let client = SolanaClient::new(&config).unwrap();Sourcepub fn with_rpc_url(rpc_url: &str) -> Self
pub fn with_rpc_url(rpc_url: &str) -> Self
Sourcepub fn chain_name(&self) -> &str
pub fn chain_name(&self) -> &str
Returns the chain name.
Sourcepub fn native_token_symbol(&self) -> &str
pub fn native_token_symbol(&self) -> &str
Returns the native token symbol.
Sourcepub async fn get_balance(&self, address: &str) -> Result<Balance>
pub async fn get_balance(&self, address: &str) -> Result<Balance>
Fetches the SOL balance for an address.
§Arguments
address- The Solana address (base58 encoded)
§Returns
Returns a Balance struct with the balance in multiple formats.
§Errors
Returns ScopeError::InvalidAddress if the address format is invalid.
Returns ScopeError::Request if the API request fails.
Sourcepub async fn enrich_balance_usd(&self, balance: &mut Balance)
pub async fn enrich_balance_usd(&self, balance: &mut Balance)
Enriches a balance with a USD value using DexScreener price lookup.
Sourcepub async fn get_token_balances(
&self,
address: &str,
) -> Result<Vec<TokenBalance>>
pub async fn get_token_balances( &self, address: &str, ) -> Result<Vec<TokenBalance>>
Fetches all SPL token balances for an address.
§Arguments
address- The Solana wallet address to query
§Returns
Returns a vector of TokenBalance containing all SPL tokens held by the address.
§Errors
Returns ScopeError::InvalidAddress if the address format is invalid.
Returns ScopeError::Request if the API request fails.
Sourcepub async fn get_transaction(&self, signature: &str) -> Result<Transaction>
pub async fn get_transaction(&self, signature: &str) -> Result<Transaction>
Fetches transaction details by signature.
§Arguments
signature- The transaction signature (base58 encoded)
§Returns
Returns Transaction details.
Sourcepub async fn get_transactions(
&self,
address: &str,
limit: u32,
) -> Result<Vec<Transaction>>
pub async fn get_transactions( &self, address: &str, limit: u32, ) -> Result<Vec<Transaction>>
Fetches recent transactions for an address.
§Arguments
address- The address to querylimit- Maximum number of transactions
§Returns
Returns a vector of Transaction objects.
Trait Implementations§
Source§impl ChainClient for SolanaClient
impl ChainClient for SolanaClient
Source§fn chain_name(&self) -> &str
fn chain_name(&self) -> &str
Source§fn native_token_symbol(&self) -> &str
fn native_token_symbol(&self) -> &str
Source§fn get_balance<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Balance>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_balance<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Balance>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn enrich_balance_usd<'life0, 'life1, 'async_trait>(
&'life0 self,
balance: &'life1 mut Balance,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn enrich_balance_usd<'life0, 'life1, 'async_trait>(
&'life0 self,
balance: &'life1 mut Balance,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_transaction<'life0, 'life1, 'async_trait>(
&'life0 self,
hash: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Transaction>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_transactions<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_transactions<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_block_number<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_block_number<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn get_token_balances<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<TokenBalance>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_token_balances<'life0, 'life1, 'async_trait>(
&'life0 self,
address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<TokenBalance>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_token_info<'life0, 'life1, 'async_trait>(
&'life0 self,
_address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_token_info<'life0, 'life1, 'async_trait>(
&'life0 self,
_address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Token>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_token_holders<'life0, 'life1, 'async_trait>(
&'life0 self,
_address: &'life1 str,
_limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<TokenHolder>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_token_holders<'life0, 'life1, 'async_trait>(
&'life0 self,
_address: &'life1 str,
_limit: u32,
) -> Pin<Box<dyn Future<Output = Result<Vec<TokenHolder>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_token_holder_count<'life0, 'life1, 'async_trait>(
&'life0 self,
_address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_token_holder_count<'life0, 'life1, 'async_trait>(
&'life0 self,
_address: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl Clone for SolanaClient
impl Clone for SolanaClient
Source§fn clone(&self) -> SolanaClient
fn clone(&self) -> SolanaClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SolanaClient
impl Debug for SolanaClient
Auto Trait Implementations§
impl Freeze for SolanaClient
impl !RefUnwindSafe for SolanaClient
impl Send for SolanaClient
impl Sync for SolanaClient
impl Unpin for SolanaClient
impl !UnwindSafe for SolanaClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more