pub trait ProviderExt: Sealed {
type Error: Debug;
// Required methods
fn try_connect<'life0, 'async_trait>(
url: &'life0 str,
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Error>> + Send + 'async_trait>>
where Self: Sized + 'async_trait,
'life0: 'async_trait;
fn set_chain(&mut self, chain: impl Into<Chain>) -> &mut Self;
// Provided methods
fn connect<'life0, 'async_trait>(
url: &'life0 str,
) -> Pin<Box<dyn Future<Output = Self> + Send + 'async_trait>>
where Self: Sized + Send + 'async_trait,
'life0: 'async_trait { ... }
fn for_chain(self, chain: impl Into<Chain>) -> Self
where Self: Sized { ... }
}
Expand description
Extension trait for Provider
Note: this is currently sealed until https://github.com/gakonst/ethers-rs/pull/1267 is finalized
§Example
Automatically configure poll interval via eth_getChainId
Note that this will send an RPC to retrieve the chain id.
let http_provider = Provider::<Http>::connect("https://eth.llamarpc.com").await;
This is essentially short for
use std::convert::TryFrom;
use ethers_core::types::Chain;
use ethers_providers::{Http, Provider, ProviderExt};
let http_provider = Provider::<Http>::try_from("https://eth.llamarpc.com").unwrap().set_chain(Chain::Mainnet);
Required Associated Types§
Required Methods§
Provided Methods§
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.