I understand that after EIP-1559 implementation, the fee structure changes to now have max priority fee and max fee instead of single gas price.

The question is though what could be the best strategy to estimate these? In legacy transactions, we could have used web3.eth.getGasPrice() and use the value as gas price for transactions.

Secondly, as per notes on EIP-1559; we can use the escalator mechanism to increase priority fee as the block count increases for my transaction. This looks awesome as this can avoid all the hassle of re-attempting the transactions when the gas price has increased. How can we actually apply escalator mechanism to web3 transactions?

1 Answer 1


Let's quickly understand how the fee is changed in EIP-1559.

  1. Base Fee: Base fee is determined by the network itself.
  2. Max Priority Fee: Optional. Determined by the user and paid directly to the miner.
  3. Max Fee Per Gas: This is the absolute maximum fee you want to pay per unit of gas.

In the EIP-1559 transaction; we supply maxFeePerGas and maxPriorityFeePerGas. The base fee is automatically calculated by the network.

Now the base fee can increase/decrease but we have already supplied the max fee we want to pay in maxFeePerGas. So if baseFee increases in the next block, the priority fee can be adjusted to make sure the total fee never crosses the max fee.

Base Fee + Priority Fee <= Max Fee

Now about calculating the fee;

we need to get the base fee from the blockchain node and we can then decide how much max fee we want to make. Ideally, if you want your transaction to be valid even after 6 blocks (assuming the base Fee increases to a maximum per block); you can use given formulae to calculate the max fee.

Max Fee = (2 * base fee) + Priority fee

So in terms of how do we get each field:

baseFee = await (web3.eth.getBlock("pending")).baseFeePerGas
priorityFee = choose yourself
MaxFee = (2 * baseFee) + priorityFee
  • Will add details later when will have some extra time on the base fee increases and how other calculations are done in detail. Nov 11, 2021 at 18:44
  • So, how do I determine what is the current viable "priorityFee" on the market? Some posts mention using getFeeHistory method with some magic numbers like web3.eth.getFeeHistory(1, "latest", [25, 50, 75]), but in my practice the "Normal" 50 seems to often be impractical during gas spikes as transaction stays pending for days...
    – Klesun
    Mar 30, 2023 at 23:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.