Skip to content

ethers.io's way to calculate maxFeePerGas in getFeeData(), what's the idea behind it? #3601

Answered by ricmoo
astralmaster asked this question in Q&A
Discussion options

You must be logged in to vote

That is the recommends best practice.

During times of congestion, it can increase by 12.5% per block. There is no guarantee you will be included in the next block, so the 2x factor gives some wiggle room.

Its only goal is to ensure your tx is included in a “reasonable amount of time”.

Since the actual fee charged will be protocol-defined by the block’s base fee, you won’t be overcharged. If there is no congestion, the 2x is moot, since you pay the base fee of that block you queried. If it is coming out of a period of congestion, you will pay less.

There may be specific instances where you want finer grained control over the fee, which is why overrides are available as needed, but for the …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by astralmaster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants