diff --git a/crates/contract/src/call.rs b/crates/contract/src/call.rs index 7341273cc7c..8ea9ce6c358 100644 --- a/crates/contract/src/call.rs +++ b/crates/contract/src/call.rs @@ -417,8 +417,13 @@ impl, D: CallDecoder, N: Network> CallBu } /// Returns the estimated gas cost for the underlying transaction to be executed + /// If [`state overrides`](Self::state) are set, they will be applied to the gas estimation. pub async fn estimate_gas(&self) -> Result { - self.provider.estimate_gas(&self.request).block(self.block).await.map_err(Into::into) + let mut estimate = self.provider.estimate_gas(&self.request); + if let Some(state) = &self.state { + estimate = estimate.overrides(state); + } + estimate.block(self.block).await.map_err(Into::into) } /// Queries the blockchain via an `eth_call` without submitting a transaction to the network.