Skip to content

Commit

Permalink
fix: use eth_maxPriorityFeePerGas for determing gas
Browse files Browse the repository at this point in the history
Update `getFeeData` to match the `ethers` algorithm, specifically don't
just assume `1_000_000_000n` as the `maxPriorityFeePerGas`. Instead call
`eth_maxPriorityFeePerGas`, and only fall back to `1_000_000_000n`, if
there is no response.

Fixes #5093
  • Loading branch information
kanej committed May 7, 2024
1 parent c7890f0 commit 5925fe0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/smart-hotels-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@nomicfoundation/hardhat-ethers": patch
---

Leverage `eth_maxPriorityFeePerGas` for the max fee per gas calculation
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,13 @@ export class HardhatEthersProvider implements ethers.Provider {
const latestBlock = await this.getBlock("latest");
const baseFeePerGas = latestBlock?.baseFeePerGas;
if (baseFeePerGas !== undefined && baseFeePerGas !== null) {
maxPriorityFeePerGas = 1_000_000_000n;
try {
maxPriorityFeePerGas = await this._hardhatProvider.send(
"eth_maxPriorityFeePerGas"
);
} catch {}

maxPriorityFeePerGas = maxPriorityFeePerGas ?? 1_000_000_000n;
maxFeePerGas = 2n * baseFeePerGas + maxPriorityFeePerGas;
}

Expand Down

0 comments on commit 5925fe0

Please sign in to comment.