pub trait ChainClient: Send + Sync {
// Required methods
fn chain_name(&self) -> &str;
fn native_token_symbol(&self) -> &str;
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 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 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_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_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_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;
// Provided methods
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_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_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 { ... }
}Expand description
Trait defining common blockchain client operations.
All chain-specific clients must implement this trait to provide a consistent interface for blockchain interactions.
§Core Methods
Every implementation must provide: chain_name, native_token_symbol,
get_balance, get_transaction, get_transactions, get_block_number,
enrich_balance_usd, and get_token_balances.
§Token Explorer Methods
The token-explorer methods (get_token_info, get_token_holders,
get_token_holder_count) have default implementations that return
“not supported” errors or empty results. Only chains with block-explorer
support for these endpoints (currently EVM chains) need to override them.
Required Methods§
Sourcefn chain_name(&self) -> &str
fn chain_name(&self) -> &str
Returns the name of the blockchain network.
Sourcefn native_token_symbol(&self) -> &str
fn native_token_symbol(&self) -> &str
Returns the native token symbol (e.g., “ETH”, “MATIC”).
Sourcefn 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,
Sourcefn 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,
Enriches a balance with USD valuation via DexScreener.
§Arguments
balance- The balance to enrich with a USD value
Sourcefn 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,
Fetches transaction details by hash.
§Arguments
hash- The transaction hash to query
§Returns
Returns Transaction details or an error if not found.
Sourcefn 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,
Fetches recent transactions for an address.
§Arguments
address- The address to querylimit- Maximum number of transactions to return
§Returns
Returns a vector of Transaction objects.
Sourcefn 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,
Fetches the current block number.
Sourcefn 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,
Fetches token balances for an address.
Returns a unified TokenBalance list regardless of chain
(ERC-20, SPL, TRC-20 all map to the same type).
Provided Methods§
Sourcefn 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,
Fetches token information for a contract address.
Default implementation returns “not supported” error. Override in chain clients that support token info lookups.
Sourcefn 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,
Fetches top token holders for a contract address.
Default implementation returns an empty vector. Override in chain clients that support holder lookups.
Sourcefn 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,
Fetches total token holder count for a contract address.
Default implementation returns 0. Override in chain clients that support holder count lookups.