Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/driver/src/infra/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,10 @@ impl Ethereum {
token::Erc20::new(self, address)
}

/// Estimate gas used by a transaction.
/// Estimate gas used by a transaction with `eth_estimateGas` on the
/// `latest` block. We use the `latest` instead of `pending` to avoid
/// false positive reverts that happen when we re-check the tx on a
/// later block after we already submitted the tx to the mempool.
pub async fn estimate_gas(&self, tx: eth::Tx) -> Result<eth::Gas, Error> {
let tx = TransactionRequest::default()
.from(tx.from)
Expand All @@ -223,7 +226,7 @@ impl Ethereum {
.web3
.provider
.estimate_gas(tx)
.pending()
.latest()
.await
.map_err(Error::Rpc)?
.into();
Expand Down
Loading