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§

source

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());
source

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
where &'a T: Send + Sync + Debug,

source§

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

source§

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>
where Box<T>: Send + Sync + Debug,

source§

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

source§

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>
where Arc<T>: Send + Sync + Debug,

source§

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

source§

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§