Trait ethers_middleware::gas_oracle::GasOracle [−][src]
pub trait GasOracle: Send + Sync + Debug { fn fetch<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<U256, GasOracleError>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait; }
Expand description
GasOracle is a trait that an underlying gas oracle needs to implement.
Example
use ethers::middleware::{ gas_oracle::{EthGasStation, Etherscan, GasCategory, GasOracle}, }; let eth_gas_station_oracle = EthGasStation::new(Some("my-api-key")); let etherscan_oracle = EthGasStation::new(None).category(GasCategory::SafeLow); let data_1 = eth_gas_station_oracle.fetch().await?; let data_2 = etherscan_oracle.fetch().await?;
Required methods
Makes an asynchronous HTTP query to the underlying GasOracle
Example
use ethers::middleware::{ gas_oracle::{Etherchain, GasCategory, GasOracle}, }; let etherchain_oracle = Etherchain::new().category(GasCategory::Fastest); let data = etherchain_oracle.fetch().await?;