Skip to main content

EthereumQueries

Trait EthereumQueries 

Source
pub trait EthereumQueries {
    type Error;

    // Required methods
    fn get_accounts<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + 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, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_balance<'life0, 'life1, 'async_trait>(
        &'life0 self,
        address: &'life1 str,
        block_number: u64,
    ) -> Pin<Box<dyn Future<Output = Result<U256, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn read_events<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        contract_address: &'life1 str,
        event_name_expanded: &'life2 str,
        from_block: u64,
        to_block: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<EthereumEvent>, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn non_executive_call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        contract_address: &'life1 str,
        data: Bytes,
        from: &'life2 str,
        block: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_chain_id<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn is_block_hash_finalized<'life0, 'async_trait>(
        &'life0 self,
        block_hash: B256,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

The basic Ethereum queries that can be used from a smart contract and do not require gas to be executed.

Required Associated Types§

Source

type Error

The error type returned by the queries.

Required Methods§

Source

fn get_accounts<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists all the accounts of the Ethereum node.

Source

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

Gets the latest block number of the Ethereum node.

Source

fn get_balance<'life0, 'life1, 'async_trait>( &'life0 self, address: &'life1 str, block_number: u64, ) -> Pin<Box<dyn Future<Output = Result<U256, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Gets the balance of the specified address at the specified block number. if no block number is specified then the balance of the latest block is returned.

Source

fn read_events<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, contract_address: &'life1 str, event_name_expanded: &'life2 str, from_block: u64, to_block: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<EthereumEvent>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Reads the events of the smart contract.

This is done from a specified contract_address and event_name_expanded. That is one should have MyEvent(type1 indexed,type2) instead of the usual MyEvent(type1,type2)

The from_block is inclusive. The to_block is exclusive (contrary to Ethereum where it is inclusive)

Source

fn non_executive_call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, contract_address: &'life1 str, data: Bytes, from: &'life2 str, block: u64, ) -> Pin<Box<dyn Future<Output = Result<Bytes, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

The operation done with eth_call on Ethereum returns a result but are not committed to the blockchain. This can be useful for example for executing function that are const and allow to inspect the contract without modifying it.

Source

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

Returns the chain ID reported by the connected EVM node.

Source

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

Checks whether a block hash is finalized and canonical on the EVM chain.

Confirms the block exists, is at or below the latest finalized height, and is the canonical block at that height. eth_getBlockByHash also returns orphaned/uncle blocks (with their original, now non-canonical number, which can be at or below the finalized height), so the canonical block at the height must additionally be checked to have this exact hash. Returns Err(BlockNotFound) if the hash does not exist on chain.

Implementors§