Skip to main content

ChainClient

Trait ChainClient 

Source
pub trait ChainClient: Send + Sync {
    // Required methods
    fn get_head_height<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<u64, TransportError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_block_by_height<'life0, 'async_trait>(
        &'life0 self,
        height: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Option<ChainBlock>, TransportError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn chain_id(&self) -> &str;
    fn chain_family(&self) -> &str;
    fn health_check<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<bool, TransportError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A high-level, chain-agnostic blockchain client.

Provides a minimal set of operations that any blockchain supports. Use this trait when writing chain-agnostic infrastructure (indexers, monitors, dashboards) that needs to work across multiple blockchain families.

For chain-specific operations (e.g. EVM eth_getLogs, Solana getSignaturesForAddress), use the concrete client types directly.

Required Methods§

Source

fn get_head_height<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64, TransportError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the current head height (block number / slot / checkpoint).

Source

fn get_block_by_height<'life0, 'async_trait>( &'life0 self, height: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<ChainBlock>, TransportError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a block by its height.

Returns None if the block does not exist (e.g. future block number).

Source

fn chain_id(&self) -> &str

Return the chain identifier (e.g. "1" for Ethereum mainnet, "mainnet-beta" for Solana).

Source

fn chain_family(&self) -> &str

Return the chain family name (e.g. "evm", "solana", "cosmos").

Source

fn health_check<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<bool, TransportError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Perform a health check against the underlying transport.

Implementors§