Trait ethers_middleware::gas_oracle::GasOracle
source · pub trait GasOracle: Send + Sync + Debug {
// Required methods
fn fetch<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<U256>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn estimate_eip1559_fees<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(U256, U256)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
An Ethereum gas price oracle.
§Example
use ethers_core::types::U256;
use ethers_middleware::gas_oracle::{GasCategory, GasNow, GasOracle};
let oracle = GasNow::default().category(GasCategory::SafeLow);
let gas_price = oracle.fetch().await?;
assert!(gas_price > U256::zero());
Required Methods§
sourcefn fetch<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<U256>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn fetch<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<U256>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Makes an asynchronous HTTP query to the underlying GasOracle
to fetch the current gas
price estimate.
§Example
use ethers_core::types::U256;
use ethers_middleware::gas_oracle::{GasCategory, GasNow, GasOracle};
let oracle = GasNow::default().category(GasCategory::SafeLow);
let gas_price = oracle.fetch().await?;
assert!(gas_price > U256::zero());
sourcefn estimate_eip1559_fees<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(U256, U256)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn estimate_eip1559_fees<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(U256, U256)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Makes an asynchronous HTTP query to the underlying GasOracle
to fetch the current max
gas fee and priority gas fee estimates.
§Example
use ethers_core::types::U256;
use ethers_middleware::gas_oracle::{GasCategory, GasNow, GasOracle};
let oracle = GasNow::default().category(GasCategory::SafeLow);
let (max_fee, priority_fee) = oracle.estimate_eip1559_fees().await?;
assert!(max_fee > U256::zero());
assert!(priority_fee > U256::zero());
Implementations on Foreign Types§
source§impl<'a, T: 'a + GasOracle + ?Sized> GasOracle for &'a T
impl<'a, T: 'a + GasOracle + ?Sized> GasOracle for &'a T
fn fetch<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<U256>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn estimate_eip1559_fees<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(U256, U256)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§impl<T: GasOracle + ?Sized> GasOracle for Box<T>
impl<T: GasOracle + ?Sized> GasOracle for Box<T>
fn fetch<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<U256>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn estimate_eip1559_fees<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(U256, U256)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§impl<T: GasOracle + ?Sized> GasOracle for Arc<T>
impl<T: GasOracle + ?Sized> GasOracle for Arc<T>
fn fetch<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<U256>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn estimate_eip1559_fees<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<(U256, U256)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Implementors§
impl GasOracle for BlockNative
impl GasOracle for EthGasStation
impl GasOracle for Etherchain
impl GasOracle for Etherscan
Available on crate feature
etherscan
only.