diff --git a/cast/src/lib.rs b/cast/src/lib.rs index 2a4637a51..8943bd6c9 100644 --- a/cast/src/lib.rs +++ b/cast/src/lib.rs @@ -73,11 +73,12 @@ where args: (&str, Vec), chain: Chain, etherscan_api_key: Option, + block: Option, ) -> Result { let (tx, func) = self .build_tx(from, to, Some(args), None, None, None, chain, etherscan_api_key, false) .await?; - let res = self.provider.call(&tx, None).await?; + let res = self.provider.call(&tx, block).await?; // decode args into tokens let func = func.expect("no valid function signature was provided."); diff --git a/cli/src/cast.rs b/cli/src/cast.rs index 8b58128dd..2ebce7430 100644 --- a/cli/src/cast.rs +++ b/cli/src/cast.rs @@ -139,7 +139,7 @@ async fn main() -> eyre::Result<()> { let provider = Provider::try_from(rpc_url)?; println!("{}", Cast::new(provider).block_number().await?); } - Subcommands::Call { eth, address, sig, args } => { + Subcommands::Call { eth, address, sig, args, block } => { let provider = Provider::try_from(eth.rpc_url()?)?; println!( "{}", @@ -149,7 +149,8 @@ async fn main() -> eyre::Result<()> { address, (&sig, args), eth.chain, - eth.etherscan_api_key + eth.etherscan_api_key, + block ) .await? ); diff --git a/cli/src/opts/cast.rs b/cli/src/opts/cast.rs index 1311d0630..6b145bd25 100644 --- a/cli/src/opts/cast.rs +++ b/cli/src/opts/cast.rs @@ -111,6 +111,8 @@ pub enum Subcommands { address: NameOrAddress, sig: String, args: Vec, + #[clap(long, short, help = "the block you want to query, can also be earliest/latest/pending", parse(try_from_str = parse_block_id))] + block: Option, #[clap(flatten)] eth: EthereumOpts, },