Skip to main content

RobustProvider

Struct RobustProvider 

Source
pub struct RobustProvider<N: Network = Ethereum> { /* private fields */ }
Expand description

Provider wrapper with built-in retry and timeout mechanisms.

This wrapper around Alloy providers automatically handles retries, timeouts, and error logging for RPC calls.

Implementations§

Source§

impl<N: Network> RobustProvider<N>

Source

pub fn primary(&self) -> &RootProvider<N>

Source

pub fn fallback_providers(&self) -> &[RootProvider<N>]

Source

pub fn call_timeout(&self) -> Duration

Source

pub fn max_retries(&self) -> usize

Source

pub fn min_delay(&self) -> Duration

Source

pub async fn get_accounts(&self) -> Result<Vec<Address>, Error>

This is a wrapper function for Provider::get_accounts.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_blob_base_fee(&self) -> Result<u128, Error>

This is a wrapper function for Provider::get_blob_base_fee.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn call(&self, tx: N::TransactionRequest) -> Result<Bytes, Error>

This is a wrapper function for Provider::call.

§Arguments
  • tx - The transaction request to simulate.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn call_many( &self, bundles: &[Bundle], ) -> Result<Vec<Vec<EthCallResponse>>, Error>

This is a wrapper function for Provider::call_many.

§Arguments
  • bundles - A slice of transaction bundles to execute.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_chain_id(&self) -> Result<u64, Error>

This is a wrapper function for Provider::get_chain_id.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_net_version(&self) -> Result<u64, Error>

This is a wrapper function for Provider::get_net_version.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_sha3(&self, data: &[u8]) -> Result<B256, Error>

This is a wrapper function for Provider::get_sha3.

§Arguments
  • data - The data to hash.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn create_access_list( &self, request: &N::TransactionRequest, ) -> Result<AccessListResult, Error>

This is a wrapper function for Provider::create_access_list.

§Arguments
  • request - The transaction request to create an access list for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn estimate_gas( &self, tx: N::TransactionRequest, ) -> Result<u64, Error>

This is a wrapper function for Provider::estimate_gas.

§Arguments
  • tx - The transaction request to estimate gas for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn estimate_eip1559_fees(&self) -> Result<Eip1559Estimation, Error>

This is a wrapper function for Provider::estimate_eip1559_fees.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_fee_history( &self, block_count: u64, last_block: BlockNumberOrTag, reward_percentiles: &[f64], ) -> Result<FeeHistory, Error>

This is a wrapper function for Provider::get_fee_history.

§Arguments
  • block_count - The number of blocks to include in the fee history.
§Arguments
  • last_block - The last block to include in the fee history.
§Arguments
  • reward_percentiles - A list of percentiles to compute reward values for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_gas_price(&self) -> Result<u128, Error>

This is a wrapper function for Provider::get_gas_price.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_max_priority_fee_per_gas(&self) -> Result<u128, Error>

This is a wrapper function for Provider::get_max_priority_fee_per_gas.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_account_info( &self, address: Address, ) -> Result<AccountInfo, Error>

This is a wrapper function for Provider::get_account_info.

§Arguments
  • address - The address for which to get the account info.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_account(&self, address: Address) -> Result<TrieAccount, Error>

This is a wrapper function for Provider::get_account.

§Arguments
  • address - The address to get the account for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_balance(&self, address: Address) -> Result<U256, Error>

This is a wrapper function for Provider::get_balance.

§Arguments
  • address - The address to get the balance for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_block_by_number( &self, number: BlockNumberOrTag, ) -> Result<N::BlockResponse, Error>

This is a wrapper function for Provider::get_block_by_number.

§Arguments
  • number - The block number or tag.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
  • Error::BlockNotFound - if the block is not available. This is verified on Anvil, Reth, and Geth; other clients may surface this condition as Error::RpcError.
Source

pub async fn get_block(&self, id: BlockId) -> Result<N::BlockResponse, Error>

This is a wrapper function for Provider::get_block.

§Arguments
  • id - The block identifier.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
  • Error::BlockNotFound - if the block is not available. This is verified on Anvil, Reth, and Geth; other clients may surface this condition as Error::RpcError.
Source

pub async fn get_block_number(&self) -> Result<BlockNumber, Error>

This is a wrapper function for Provider::get_block_number.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_block_number_by_id( &self, block_id: BlockId, ) -> Result<BlockNumber, Error>

This is a wrapper function for Provider::get_block_number_by_id.

§Arguments
  • block_id - The block identifier to fetch the block number for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
  • Error::BlockNotFound - if the block is not available. This is verified on Anvil, Reth, and Geth; other clients may surface this condition as Error::RpcError.
Source

pub async fn get_block_by_hash( &self, hash: BlockHash, ) -> Result<N::BlockResponse, Error>

This is a wrapper function for Provider::get_block_by_hash.

§Arguments
  • hash - The block hash.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
  • Error::BlockNotFound - if the block is not available. This is verified on Anvil, Reth, and Geth; other clients may surface this condition as Error::RpcError.
Source

pub async fn get_block_receipts( &self, block: BlockId, ) -> Result<Vec<N::ReceiptResponse>, Error>

This is a wrapper function for Provider::get_block_receipts.

§Arguments
  • block - The block identifier (hash, number, or tag).
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
  • Error::BlockNotFound - if the block is not available. This is verified on Anvil, Reth, and Geth; other clients may surface this condition as Error::RpcError.
Source

pub async fn get_block_transaction_count_by_hash( &self, hash: BlockHash, ) -> Result<u64, Error>

This is a wrapper function for Provider::get_block_transaction_count_by_hash.

§Arguments
  • hash - The block hash.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
  • Error::BlockNotFound - if the block is not available. This is verified on Anvil, Reth, and Geth; other clients may surface this condition as Error::RpcError.
Source

pub async fn get_block_transaction_count_by_number( &self, block_number: BlockNumberOrTag, ) -> Result<u64, Error>

This is a wrapper function for Provider::get_block_transaction_count_by_number.

§Arguments
  • block_number - The block number or tag.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
  • Error::BlockNotFound - if the block is not available. This is verified on Anvil, Reth, and Geth; other clients may surface this condition as Error::RpcError.
Source

pub async fn get_logs(&self, filter: &Filter) -> Result<Vec<Log>, Error>

This is a wrapper function for Provider::get_logs.

§Arguments
  • filter - The log filter.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_code_at(&self, address: Address) -> Result<Bytes, Error>

This is a wrapper function for Provider::get_code_at.

§Arguments
  • address - The address to get the code for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_filter_logs(&self, filter_id: U256) -> Result<Vec<Log>, Error>

This is a wrapper function for Provider::get_filter_logs.

§Arguments
  • filter_id - The filter ID to fetch logs for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_filter_changes<R: RpcRecv>( &self, filter_id: U256, ) -> Result<Vec<R>, Error>

This is a wrapper function for Provider::get_filter_changes.

§Arguments
  • filter_id - The filter ID to get changes for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn new_filter(&self, filter: &Filter) -> Result<U256, Error>

This is a wrapper function for Provider::new_filter.

§Arguments
  • filter - The filter to create.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn new_block_filter(&self) -> Result<U256, Error>

This is a wrapper function for Provider::new_block_filter.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn new_pending_transactions_filter( &self, full: bool, ) -> Result<U256, Error>

This is a wrapper function for Provider::new_pending_transactions_filter.

§Arguments
  • full - Whether to include full transaction objects.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn sign_transaction( &self, tx: N::TransactionRequest, ) -> Result<Bytes, Error>

This is a wrapper function for Provider::sign_transaction.

§Arguments
  • tx - The transaction request to sign.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn fill_transaction( &self, tx: N::TransactionRequest, ) -> Result<FillTransaction<N::TxEnvelope>, Error>
where N::TxEnvelope: RpcRecv,

This is a wrapper function for Provider::fill_transaction.

§Arguments
  • tx - The transaction request to fill.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_proof( &self, address: Address, keys: Vec<StorageKey>, ) -> Result<EIP1186AccountProofResponse, Error>

This is a wrapper function for Provider::get_proof.

§Arguments
  • address - The address of the account.
§Arguments
  • keys - A vector of storage keys to include in the proof.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_storage_at( &self, address: Address, key: U256, ) -> Result<StorageValue, Error>

This is a wrapper function for Provider::get_storage_at.

§Arguments
  • address - The address of the storage.
§Arguments
  • key - The position in the storage.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_transaction_by_block_hash_and_index( &self, block_hash: B256, index: usize, ) -> Result<Option<N::TransactionResponse>, Error>

This is a wrapper function for Provider::get_transaction_by_block_hash_and_index.

§Arguments
  • block_hash - The hash of the block.
§Arguments
  • index - The transaction index position.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_transaction_by_block_number_and_index( &self, block_number: BlockNumberOrTag, index: usize, ) -> Result<Option<N::TransactionResponse>, Error>

This is a wrapper function for Provider::get_transaction_by_block_number_and_index.

§Arguments
  • block_number - The block number or tag.
§Arguments
  • index - The transaction index position.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_transaction_by_hash( &self, hash: TxHash, ) -> Result<Option<N::TransactionResponse>, Error>

This is a wrapper function for Provider::get_transaction_by_hash.

§Arguments
  • hash - The transaction hash.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_raw_transaction_by_hash( &self, hash: TxHash, ) -> Result<Option<Bytes>, Error>

This is a wrapper function for Provider::get_raw_transaction_by_hash.

§Arguments
  • hash - The transaction hash.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_transaction_count( &self, address: Address, ) -> Result<u64, Error>

This is a wrapper function for Provider::get_transaction_count.

§Arguments
  • address - The address to get the transaction count for.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_transaction_receipt( &self, hash: TxHash, ) -> Result<Option<N::ReceiptResponse>, Error>

This is a wrapper function for Provider::get_transaction_receipt.

§Arguments
  • hash - The transaction hash.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_uncle_count(&self, block: BlockId) -> Result<u64, Error>

This is a wrapper function for Provider::get_uncle_count.

§Arguments
  • block - The block identifier (hash or number).
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_uncle( &self, tag: BlockId, idx: u64, ) -> Result<Option<N::BlockResponse>, Error>

This is a wrapper function for Provider::get_uncle.

§Arguments
  • tag - The block identifier (hash or number).
§Arguments
  • idx - The uncle index position.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn simulate( &self, request: &SimulatePayload, ) -> Result<Vec<SimulatedBlock<N::BlockResponse>>, Error>

This is a wrapper function for Provider::simulate.

§Arguments
  • request - The simulation request
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn syncing(&self) -> Result<SyncStatus, Error>

This is a wrapper function for Provider::syncing.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn uninstall_filter(&self, id: U256) -> Result<bool, Error>

This is a wrapper function for Provider::uninstall_filter.

§Arguments
  • id - The filter ID to uninstall.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn send_raw_transaction( &self, encoded_tx: &[u8], ) -> Result<PendingTransactionBuilder<N>, Error>

This is a wrapper function for Provider::send_raw_transaction.

§Arguments
  • encoded_tx - The RLP-encoded signed transaction bytes
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn send_raw_transaction_sync( &self, encoded_tx: &[u8], ) -> Result<N::ReceiptResponse, Error>

This is a wrapper function for Provider::send_raw_transaction_sync.

§Arguments
  • encoded_tx - The RLP-encoded signed transaction bytes
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn send_raw_transaction_conditional( &self, encoded_tx: &[u8], conditional: TransactionConditional, ) -> Result<PendingTransactionBuilder<N>, Error>

This is a wrapper function for Provider::send_raw_transaction_conditional.

§Arguments
  • encoded_tx - The RLP-encoded signed transaction bytes
§Arguments
  • conditional - The transaction conditional to apply
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn send_transaction( &self, tx: N::TransactionRequest, ) -> Result<PendingTransactionBuilder<N>, Error>

This is a wrapper function for Provider::send_transaction.

§Arguments
  • tx - The transaction request to send
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn send_tx_envelope( &self, tx: N::TxEnvelope, ) -> Result<PendingTransactionBuilder<N>, Error>
where N::TxEnvelope: Clone,

This is a wrapper function for Provider::send_tx_envelope.

§Arguments
  • tx - The signed transaction envelope to send.
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn send_transaction_sync( &self, tx: N::TransactionRequest, ) -> Result<N::ReceiptResponse, Error>

This is a wrapper function for Provider::send_transaction_sync.

§Arguments
  • tx - The transaction request to send synchronously
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_transaction_by_sender_nonce( &self, sender: Address, nonce: u64, ) -> Result<Option<N::TransactionResponse>, Error>

This is a wrapper function for Provider::get_transaction_by_sender_nonce.

§Arguments
  • sender - The sender address
§Arguments
  • nonce - The nonce of the transaction
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_raw_transaction_by_block_hash_and_index( &self, block_hash: B256, index: usize, ) -> Result<Option<Bytes>, Error>

This is a wrapper function for Provider::get_raw_transaction_by_block_hash_and_index.

§Arguments
  • block_hash - The hash of the block
§Arguments
  • index - The transaction index position
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_raw_transaction_by_block_number_and_index( &self, block_number: BlockNumberOrTag, index: usize, ) -> Result<Option<Bytes>, Error>

This is a wrapper function for Provider::get_raw_transaction_by_block_number_and_index.

§Arguments
  • block_number - The block number or tag
§Arguments
  • index - The transaction index position
§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn get_client_version(&self) -> Result<String, Error>

This is a wrapper function for Provider::get_client_version.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn estimate_eip1559_fees_with( &self, estimator: Eip1559Estimator, ) -> Result<Eip1559Estimation, Error>

Estimates the [EIP-1559] maxFeePerGas and maxPriorityFeePerGas fields using a custom estimator.

§Implementation Note

Unlike most methods in RobustProvider, this method does not wrap the underlying provider’s estimate_eip1559_fees_with call with retry/failover logic. Instead, it implements the estimation logic directly (copied from alloy’s implementation).

Ref https://github.com/alloy-rs/alloy/blob/9a90a57acde7f30787b675815334cf54c6be4ba1/crates/provider/src/provider/trait.rs#L283

Reason: This method accepts an owned, non-cloneable Eip1559Estimator value. The current retry implementation (try_operation_with_failover) requires operations to be retryable across multiple providers, which means closures must be able to run multiple times. This only works with Copy or Clone types. Since Eip1559Estimator consumes itself and cannot be cloned, we cannot use the standard retry wrapper.

There is a pending issue on alloy https://github.com/alloy-rs/alloy/issues/3669 which would allow Eip1559Estimator to implement Clone. If this is merged we can remove this custom impl.

However, the individual RPC calls within this method (get_fee_history and get_block_by_number) do benefit from full retry and failover support, as they use the standard robust wrappers internally.

§Parameters
§Errors
  • Error::RpcError - if the underlying RPC calls fail after exhausting retries on all providers
  • Error::Timeout - if the operation exceeds the configured timeout
  • Error::RpcError with UnsupportedFeature("eip1559") - if the chain doesn’t support EIP-1559 (i.e., the latest block has no base_fee_per_gas)
Source

pub async fn raw_request<P, R>( &self, method: Cow<'static, str>, params: P, ) -> Result<R, Error>
where P: RpcSend, R: RpcRecv,

This is a wrapper function for Provider::raw_request.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn raw_request_dyn( &self, method: Cow<'static, str>, params: &RawValue, ) -> Result<Box<RawValue>, Error>

This is a wrapper function for Provider::raw_request_dyn.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn subscribe_blocks(&self) -> Result<RobustSubscription<N>, Error>

Subscribe to new block headers with automatic failover and reconnection.

Returns a RobustSubscription that automatically:

  • Handles connection errors by switching to fallback providers
  • Detects and recovers from lagged subscriptions
  • Periodically attempts to reconnect to the primary provider

When the http-subscription feature is enabled and allow_http_subscriptions is set to true, HTTP providers can participate in subscriptions via polling.

This is a wrapper function for Provider::subscribe_blocks.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn watch_blocks( &self, ) -> Result<PollerBuilder<(U256,), Vec<BlockHash>>, Error>

This is a wrapper function for Provider::watch_blocks.

§Errors
  • Error::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • Error::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).
Source

pub async fn try_operation_with_failover<T: Debug, F, Fut>( &self, operation: F, ) -> Result<T, FailoverError>
where F: Fn(RootProvider<N>) -> Fut, Fut: Future<Output = Result<T, RpcError<TransportErrorKind>>>,

Execute operation with exponential backoff and a total timeout.

Wraps the retry logic with tokio::time::timeout so the entire operation (including time spent inside the RPC call) cannot exceed call_timeout.

If the timeout is exceeded and fallback providers are available, it will attempt to use each fallback provider in sequence.

§Errors
  • FailoverError::RpcError - if no fallback providers succeeded; contains the last error returned by the last provider attempted on the last retry.
  • FailoverError::Timeout - if the overall operation timeout elapses (i.e. exceeds call_timeout).

Trait Implementations§

Source§

impl<N: Clone + Network> Clone for RobustProvider<N>

Source§

fn clone(&self) -> RobustProvider<N>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<N: Debug + Network> Debug for RobustProvider<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<N: Network> IntoRobustProvider<N> for RobustProvider<N>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more