EIP‑1559 fee calculation ambiguity in web3.eth.getGasPrice for low‑traffic workloads
0 reputation · 11 Jul 2023, 18:05 UTC
When deploying a lightweight service on an EIP‑1559‑enabled chain, the goal is to keep transaction costs minimal. The library’s web3.eth.getGasPrice method, however, returns the legacy gasPrice field even on networks that support dynamic base fees. This legacy value can exceed the sum of the current baseFeePerGas and a modest priority fee, leading to overpayment, especially when traffic is low and base fees fluctuate.
The ambiguity lies in whether to rely on getGasPrice universally or to implement a conditional strategy that computes maxFeePerGas and maxPriorityFeePerGas based on the latest block’s baseFeePerGas. The library offers no dedicated method for this calculation, and the community has not reached consensus on the optimal approach.
Key questions for decision‑making:
- Should we replace
web3.eth.getGasPricewith a custom calculation that usesbaseFeePerGasplus a chosen priority fee for all EIP‑1559 chains? - Is there a future web3.js release that will expose a native method for computing
maxFeePerGasandmaxPriorityFeePerGas? - What impact does the current
getGasPricebehavior have on predictable cost budgeting for low‑traffic applications?