Trait EthApiClient

pub trait EthApiClient<T, B, R, H>: ClientT
where T: RpcObject + Send + Sync + 'static + DeserializeOwned, B: RpcObject + Send + Sync + 'static + DeserializeOwned, R: RpcObject + Send + Sync + 'static + DeserializeOwned, H: RpcObject + Send + Sync + 'static + DeserializeOwned,
{
Show 51 methods // Provided methods fn protocol_version( &self, ) -> impl Future<Output = Result<Uint<64, 1>, Error>> + Send { ... } fn syncing(&self) -> impl Future<Output = Result<SyncStatus, Error>> + Send { ... } fn author(&self) -> impl Future<Output = Result<Address, Error>> + Send { ... } fn accounts( &self, ) -> impl Future<Output = Result<Vec<Address>, Error>> + Send { ... } fn block_number( &self, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send { ... } fn chain_id( &self, ) -> impl Future<Output = Result<Option<Uint<64, 1>>, Error>> + Send { ... } fn block_by_hash( &self, hash: FixedBytes<32>, full: bool, ) -> impl Future<Output = Result<Option<B>, Error>> + Send { ... } fn block_by_number( &self, number: BlockNumberOrTag, full: bool, ) -> impl Future<Output = Result<Option<B>, Error>> + Send { ... } fn block_transaction_count_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<Uint<256, 4>>, Error>> + Send { ... } fn block_transaction_count_by_number( &self, number: BlockNumberOrTag, ) -> impl Future<Output = Result<Option<Uint<256, 4>>, Error>> + Send { ... } fn block_uncles_count_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<Uint<256, 4>>, Error>> + Send { ... } fn block_uncles_count_by_number( &self, number: BlockNumberOrTag, ) -> impl Future<Output = Result<Option<Uint<256, 4>>, Error>> + Send { ... } fn block_receipts( &self, block_id: BlockId, ) -> impl Future<Output = Result<Option<Vec<R>>, Error>> + Send { ... } fn uncle_by_block_hash_and_index( &self, hash: FixedBytes<32>, index: Index, ) -> impl Future<Output = Result<Option<B>, Error>> + Send { ... } fn uncle_by_block_number_and_index( &self, number: BlockNumberOrTag, index: Index, ) -> impl Future<Output = Result<Option<B>, Error>> + Send { ... } fn raw_transaction_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<Bytes>, Error>> + Send { ... } fn transaction_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<T>, Error>> + Send { ... } fn raw_transaction_by_block_hash_and_index( &self, hash: FixedBytes<32>, index: Index, ) -> impl Future<Output = Result<Option<Bytes>, Error>> + Send { ... } fn transaction_by_block_hash_and_index( &self, hash: FixedBytes<32>, index: Index, ) -> impl Future<Output = Result<Option<T>, Error>> + Send { ... } fn raw_transaction_by_block_number_and_index( &self, number: BlockNumberOrTag, index: Index, ) -> impl Future<Output = Result<Option<Bytes>, Error>> + Send { ... } fn transaction_by_block_number_and_index( &self, number: BlockNumberOrTag, index: Index, ) -> impl Future<Output = Result<Option<T>, Error>> + Send { ... } fn transaction_by_sender_and_nonce( &self, address: Address, nonce: Uint<64, 1>, ) -> impl Future<Output = Result<Option<T>, Error>> + Send { ... } fn transaction_receipt( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<R>, Error>> + Send { ... } fn balance( &self, address: Address, block_number: Option<BlockId>, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send { ... } fn storage_at( &self, address: Address, index: JsonStorageKey, block_number: Option<BlockId>, ) -> impl Future<Output = Result<FixedBytes<32>, Error>> + Send { ... } fn transaction_count( &self, address: Address, block_number: Option<BlockId>, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send { ... } fn get_code( &self, address: Address, block_number: Option<BlockId>, ) -> impl Future<Output = Result<Bytes, Error>> + Send { ... } fn header_by_number( &self, hash: BlockNumberOrTag, ) -> impl Future<Output = Result<Option<H>, Error>> + Send { ... } fn header_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<H>, Error>> + Send { ... } fn simulate_v1( &self, opts: SimulatePayload, block_number: Option<BlockId>, ) -> impl Future<Output = Result<Vec<SimulatedBlock<B>>, Error>> + Send { ... } fn call( &self, request: TransactionRequest, block_number: Option<BlockId>, state_overrides: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, block_overrides: Option<Box<BlockOverrides>>, ) -> impl Future<Output = Result<Bytes, Error>> + Send { ... } fn call_many( &self, bundles: Vec<Bundle>, state_context: Option<StateContext>, state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, ) -> impl Future<Output = Result<Vec<Vec<EthCallResponse>>, Error>> + Send { ... } fn create_access_list( &self, request: TransactionRequest, block_number: Option<BlockId>, state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, ) -> impl Future<Output = Result<AccessListResult, Error>> + Send { ... } fn estimate_gas( &self, request: TransactionRequest, block_number: Option<BlockId>, state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send { ... } fn gas_price( &self, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send { ... } fn get_account( &self, address: Address, block: BlockId, ) -> impl Future<Output = Result<Option<TrieAccount>, Error>> + Send { ... } fn max_priority_fee_per_gas( &self, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send { ... } fn blob_base_fee( &self, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send { ... } fn fee_history( &self, block_count: Uint<64, 1>, newest_block: BlockNumberOrTag, reward_percentiles: Option<Vec<f64>>, ) -> impl Future<Output = Result<FeeHistory, Error>> + Send { ... } fn is_mining(&self) -> impl Future<Output = Result<bool, Error>> + Send { ... } fn hashrate( &self, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send { ... } fn get_work(&self) -> impl Future<Output = Result<Work, Error>> + Send { ... } fn submit_hashrate( &self, hashrate: Uint<256, 4>, id: FixedBytes<32>, ) -> impl Future<Output = Result<bool, Error>> + Send { ... } fn submit_work( &self, nonce: FixedBytes<8>, pow_hash: FixedBytes<32>, mix_digest: FixedBytes<32>, ) -> impl Future<Output = Result<bool, Error>> + Send { ... } fn send_transaction( &self, request: TransactionRequest, ) -> impl Future<Output = Result<FixedBytes<32>, Error>> + Send { ... } fn send_raw_transaction( &self, bytes: Bytes, ) -> impl Future<Output = Result<FixedBytes<32>, Error>> + Send { ... } fn sign( &self, address: Address, message: Bytes, ) -> impl Future<Output = Result<Bytes, Error>> + Send { ... } fn sign_transaction( &self, transaction: TransactionRequest, ) -> impl Future<Output = Result<Bytes, Error>> + Send { ... } fn sign_typed_data( &self, address: Address, data: TypedData, ) -> impl Future<Output = Result<Bytes, Error>> + Send { ... } fn get_proof( &self, address: Address, keys: Vec<JsonStorageKey>, block_number: Option<BlockId>, ) -> impl Future<Output = Result<EIP1186AccountProofResponse, Error>> + Send { ... } fn get_account_info( &self, address: Address, block: BlockId, ) -> impl Future<Output = Result<AccountInfo, Error>> + Send { ... }
}
Expand description

Client implementation for the EthApi RPC API.

Provided Methods§

fn protocol_version( &self, ) -> impl Future<Output = Result<Uint<64, 1>, Error>> + Send

Returns the protocol version encoded as a string.

fn syncing(&self) -> impl Future<Output = Result<SyncStatus, Error>> + Send

Returns an object with data about the sync status or false.

fn author(&self) -> impl Future<Output = Result<Address, Error>> + Send

Returns the client coinbase address.

fn accounts(&self) -> impl Future<Output = Result<Vec<Address>, Error>> + Send

Returns a list of addresses owned by client.

fn block_number( &self, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send

Returns the number of most recent block.

fn chain_id( &self, ) -> impl Future<Output = Result<Option<Uint<64, 1>>, Error>> + Send

Returns the chain ID of the current network.

fn block_by_hash( &self, hash: FixedBytes<32>, full: bool, ) -> impl Future<Output = Result<Option<B>, Error>> + Send

Returns information about a block by hash.

fn block_by_number( &self, number: BlockNumberOrTag, full: bool, ) -> impl Future<Output = Result<Option<B>, Error>> + Send

Returns information about a block by number.

fn block_transaction_count_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<Uint<256, 4>>, Error>> + Send

Returns the number of transactions in a block from a block matching the given block hash.

fn block_transaction_count_by_number( &self, number: BlockNumberOrTag, ) -> impl Future<Output = Result<Option<Uint<256, 4>>, Error>> + Send

Returns the number of transactions in a block matching the given block number.

fn block_uncles_count_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<Uint<256, 4>>, Error>> + Send

Returns the number of uncles in a block from a block matching the given block hash.

fn block_uncles_count_by_number( &self, number: BlockNumberOrTag, ) -> impl Future<Output = Result<Option<Uint<256, 4>>, Error>> + Send

Returns the number of uncles in a block with given block number.

fn block_receipts( &self, block_id: BlockId, ) -> impl Future<Output = Result<Option<Vec<R>>, Error>> + Send

Returns all transaction receipts for a given block.

fn uncle_by_block_hash_and_index( &self, hash: FixedBytes<32>, index: Index, ) -> impl Future<Output = Result<Option<B>, Error>> + Send

Returns an uncle block of the given block and index.

fn uncle_by_block_number_and_index( &self, number: BlockNumberOrTag, index: Index, ) -> impl Future<Output = Result<Option<B>, Error>> + Send

Returns an uncle block of the given block and index.

fn raw_transaction_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<Bytes>, Error>> + Send

Returns the EIP-2718 encoded transaction if it exists.

If this is a EIP-4844 transaction that is in the pool it will include the sidecar.

fn transaction_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<T>, Error>> + Send

Returns the information about a transaction requested by transaction hash.

fn raw_transaction_by_block_hash_and_index( &self, hash: FixedBytes<32>, index: Index, ) -> impl Future<Output = Result<Option<Bytes>, Error>> + Send

Returns information about a raw transaction by block hash and transaction index position.

fn transaction_by_block_hash_and_index( &self, hash: FixedBytes<32>, index: Index, ) -> impl Future<Output = Result<Option<T>, Error>> + Send

Returns information about a transaction by block hash and transaction index position.

fn raw_transaction_by_block_number_and_index( &self, number: BlockNumberOrTag, index: Index, ) -> impl Future<Output = Result<Option<Bytes>, Error>> + Send

Returns information about a raw transaction by block number and transaction index position.

fn transaction_by_block_number_and_index( &self, number: BlockNumberOrTag, index: Index, ) -> impl Future<Output = Result<Option<T>, Error>> + Send

Returns information about a transaction by block number and transaction index position.

fn transaction_by_sender_and_nonce( &self, address: Address, nonce: Uint<64, 1>, ) -> impl Future<Output = Result<Option<T>, Error>> + Send

Returns information about a transaction by sender and nonce.

fn transaction_receipt( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<R>, Error>> + Send

Returns the receipt of a transaction by transaction hash.

fn balance( &self, address: Address, block_number: Option<BlockId>, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send

Returns the balance of the account of given address.

fn storage_at( &self, address: Address, index: JsonStorageKey, block_number: Option<BlockId>, ) -> impl Future<Output = Result<FixedBytes<32>, Error>> + Send

Returns the value from a storage position at a given address

fn transaction_count( &self, address: Address, block_number: Option<BlockId>, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send

Returns the number of transactions sent from an address at given block number.

fn get_code( &self, address: Address, block_number: Option<BlockId>, ) -> impl Future<Output = Result<Bytes, Error>> + Send

Returns code at a given address at given block number.

fn header_by_number( &self, hash: BlockNumberOrTag, ) -> impl Future<Output = Result<Option<H>, Error>> + Send

Returns the block’s header at given number.

fn header_by_hash( &self, hash: FixedBytes<32>, ) -> impl Future<Output = Result<Option<H>, Error>> + Send

Returns the block’s header at given hash.

fn simulate_v1( &self, opts: SimulatePayload, block_number: Option<BlockId>, ) -> impl Future<Output = Result<Vec<SimulatedBlock<B>>, Error>> + Send

eth_simulateV1 executes an arbitrary number of transactions on top of the requested state. The transactions are packed into individual blocks. Overrides can be provided.

fn call( &self, request: TransactionRequest, block_number: Option<BlockId>, state_overrides: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, block_overrides: Option<Box<BlockOverrides>>, ) -> impl Future<Output = Result<Bytes, Error>> + Send

Executes a new message call immediately without creating a transaction on the block chain.

fn call_many( &self, bundles: Vec<Bundle>, state_context: Option<StateContext>, state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, ) -> impl Future<Output = Result<Vec<Vec<EthCallResponse>>, Error>> + Send

Simulate arbitrary number of transactions at an arbitrary blockchain index, with the optionality of state overrides

fn create_access_list( &self, request: TransactionRequest, block_number: Option<BlockId>, state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, ) -> impl Future<Output = Result<AccessListResult, Error>> + Send

Generates an access list for a transaction.

This method creates an EIP2930 type accessList based on a given Transaction.

An access list contains all storage slots and addresses touched by the transaction, except for the sender account and the chain’s precompiles.

It returns list of addresses and storage keys used by the transaction, plus the gas consumed when the access list is added. That is, it gives you the list of addresses and storage keys that will be used by that transaction, plus the gas consumed if the access list is included. Like eth_estimateGas, this is an estimation; the list could change when the transaction is actually mined. Adding an accessList to your transaction does not necessary result in lower gas usage compared to a transaction without an access list.

fn estimate_gas( &self, request: TransactionRequest, block_number: Option<BlockId>, state_override: Option<HashMap<Address, AccountOverride, FbBuildHasher<20>>>, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send

Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.

fn gas_price(&self) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send

Returns the current price per gas in wei.

fn get_account( &self, address: Address, block: BlockId, ) -> impl Future<Output = Result<Option<TrieAccount>, Error>> + Send

Returns the account details by specifying an address and a block number/tag

fn max_priority_fee_per_gas( &self, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send

Introduced in EIP-1559, returns suggestion for the priority for dynamic fee transactions.

fn blob_base_fee( &self, ) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send

Introduced in EIP-4844, returns the current blob base fee in wei.

fn fee_history( &self, block_count: Uint<64, 1>, newest_block: BlockNumberOrTag, reward_percentiles: Option<Vec<f64>>, ) -> impl Future<Output = Result<FeeHistory, Error>> + Send

Returns the Transaction fee history

Introduced in EIP-1559 for getting information on the appropriate priority fee to use.

Returns transaction base fee per gas and effective priority fee per gas for the requested/supported block range. The returned Fee history for the returned block range can be a subsection of the requested range if not all blocks are available.

fn is_mining(&self) -> impl Future<Output = Result<bool, Error>> + Send

Returns whether the client is actively mining new blocks.

fn hashrate(&self) -> impl Future<Output = Result<Uint<256, 4>, Error>> + Send

Returns the number of hashes per second that the node is mining with.

fn get_work(&self) -> impl Future<Output = Result<Work, Error>> + Send

Returns the hash of the current block, the seedHash, and the boundary condition to be met (target)

fn submit_hashrate( &self, hashrate: Uint<256, 4>, id: FixedBytes<32>, ) -> impl Future<Output = Result<bool, Error>> + Send

Used for submitting mining hashrate.

Can be used for remote miners to submit their hash rate. It accepts the miner hash rate and an identifier which must be unique between nodes. Returns true if the block was successfully submitted, false otherwise.

fn submit_work( &self, nonce: FixedBytes<8>, pow_hash: FixedBytes<32>, mix_digest: FixedBytes<32>, ) -> impl Future<Output = Result<bool, Error>> + Send

Used for submitting a proof-of-work solution.

fn send_transaction( &self, request: TransactionRequest, ) -> impl Future<Output = Result<FixedBytes<32>, Error>> + Send

Sends transaction; will block waiting for signer to return the transaction hash.

fn send_raw_transaction( &self, bytes: Bytes, ) -> impl Future<Output = Result<FixedBytes<32>, Error>> + Send

Sends signed transaction, returning its hash.

fn sign( &self, address: Address, message: Bytes, ) -> impl Future<Output = Result<Bytes, Error>> + Send

Returns an Ethereum specific signature with: sign(keccak256(“\x19Ethereum Signed Message:\n”

  • len(message) + message))).

fn sign_transaction( &self, transaction: TransactionRequest, ) -> impl Future<Output = Result<Bytes, Error>> + Send

Signs a transaction that can be submitted to the network at a later time using with sendRawTransaction.

fn sign_typed_data( &self, address: Address, data: TypedData, ) -> impl Future<Output = Result<Bytes, Error>> + Send

Signs data via EIP-712.

fn get_proof( &self, address: Address, keys: Vec<JsonStorageKey>, block_number: Option<BlockId>, ) -> impl Future<Output = Result<EIP1186AccountProofResponse, Error>> + Send

Returns the account and storage values of the specified account including the Merkle-proof. This call can be used to verify that the data you are pulling from is not tampered with.

fn get_account_info( &self, address: Address, block: BlockId, ) -> impl Future<Output = Result<AccountInfo, Error>> + Send

Returns the account’s balance, nonce, and code.

This is similar to eth_getAccount but does not return the storage root.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

§

impl<TypeJsonRpseeInternal, T, B, R, H> EthApiClient<T, B, R, H> for TypeJsonRpseeInternal
where T: RpcObject + Send + Sync + 'static + DeserializeOwned, B: RpcObject + Send + Sync + 'static + DeserializeOwned, R: RpcObject + Send + Sync + 'static + DeserializeOwned, H: RpcObject + Send + Sync + 'static + DeserializeOwned, TypeJsonRpseeInternal: ClientT,