pub trait GasOracle: Send + Sync + Debug {
    // Required methods
    fn fetch<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<U256, GasOracleError>> + Send + 'async_trait, Global>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn estimate_eip1559_fees<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<(U256, U256), GasOracleError>> + Send + 'async_trait, Global>>
       where 'life0: 'async_trait,
             Self: '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§

fn fetch<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<U256, GasOracleError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, Self: '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());

fn estimate_eip1559_fees<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(U256, U256), GasOracleError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, Self: '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§

§

impl<T> GasOracle for Arc<T, Global>where T: GasOracle + ?Sized, Arc<T, Global>: Send + Sync + Debug,

§

fn fetch<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<U256, GasOracleError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, Arc<T, Global>: 'async_trait,

§

fn estimate_eip1559_fees<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(U256, U256), GasOracleError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, Arc<T, Global>: 'async_trait,

§

impl<'a, T> GasOracle for &'a Twhere T: 'a + GasOracle + ?Sized, &'a T: Send + Sync + Debug,

§

fn fetch<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<U256, GasOracleError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, &'a T: 'async_trait,

§

fn estimate_eip1559_fees<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(U256, U256), GasOracleError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, &'a T: 'async_trait,

§

impl<T> GasOracle for Box<T, Global>where T: GasOracle + ?Sized, Box<T, Global>: Send + Sync + Debug,

§

fn fetch<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<U256, GasOracleError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, Box<T, Global>: 'async_trait,

§

fn estimate_eip1559_fees<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<(U256, U256), GasOracleError>> + Send + 'async_trait, Global>>where 'life0: 'async_trait, Box<T, Global>: 'async_trait,

Implementors§

§

impl GasOracle for BlockNative

§

impl GasOracle for EthGasStation

§

impl GasOracle for Etherchain

§

impl GasOracle for Etherscan

§

impl GasOracle for GasNow

§

impl GasOracle for Median

§

impl GasOracle for Polygon

§

impl<M> GasOracle for ProviderOracle<M>where M: Middleware, <M as Middleware>::Error: 'static,

§

impl<T> GasOracle for Cache<T>where T: GasOracle,