Skip to content

Commit

Permalink
Seth: gas-price
Browse files Browse the repository at this point in the history
  • Loading branch information
Anish-Agnihotri committed Sep 20, 2021
1 parent a2b43af commit 8efb216
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dapptools/src/seth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ async fn main() -> eyre::Result<()> {
let provider = Provider::try_from(rpc_url)?;
println!("{}", Seth::new(provider).base_fee(block.unwrap_or(BlockId::Number(Latest))).await?);
}
Subcommands::GasPrice { rpc_url } => {
let provider = Provider::try_from(rpc_url)?;
println!("{}", Seth::new(provider).gas_price().await?);
}
Subcommands::Keccak { data } => {
println!("{}", SimpleSeth::keccak(&data));
}
Expand Down
6 changes: 6 additions & 0 deletions dapptools/src/seth_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ pub enum Subcommands {
#[structopt(short, long, env = "ETH_RPC_URL")]
rpc_url: String,
},
#[structopt(name = "gas-price")]
#[structopt(about = "current gas price of target chain")]
GasPrice {
#[structopt(short, long, env = "ETH_RPC_URL")]
rpc_url: String,
},
#[structopt(name = "keccak")]
#[structopt(about = "Keccak-256 hash arbitrary data")]
Keccak { data: String },
Expand Down
4 changes: 4 additions & 0 deletions seth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ where
pub async fn block_number(&self) -> Result<U64> {
Ok(self.provider.get_block_number().await?)
}

pub async fn gas_price(&self) -> Result<U256> {
Ok(self.provider.get_gas_price().await?)
}
}

pub struct SimpleSeth;
Expand Down

0 comments on commit 8efb216

Please sign in to comment.