Using getGasPrice in web3js returns the last few blocks median gas price. After EIP-1559, the fees system is divided into Base + Tip.

My question is, what is returned using getGasPrice after EIP1559? Is it the total average Base+Tip value or just one or the other?

  • I'm actually wondering the same thing. I have an application that's been running for some time now fine using the eth.getGasPrice() function. Now suddenly I'm starting to see the following errors: max fee per gas less than block base fee: address {address}, maxFeePerGas: 5000000000 baseFee: 27318189081 (supplied gas 4014405) Commented Oct 21, 2021 at 15:27
  • Did you try updating to the newer versions of web3js? It seems that they've made it compatible now
    – sigmaxf
    Commented Oct 21, 2021 at 17:12
  • I have tried. Unfortunately, there's an outstanding bug with web3 and ganache-cli that prevents me from using it. In case anyone is curious about the bug: github.com/ChainSafe/web3.js/issues/4454 Commented Oct 21, 2021 at 19:02

1 Answer 1


what is returned using getGasPrice after EIP-1559 ? Is it the total average Base+Tip value or just one or the other?

Something similar to pre EIP-1559 for backward compatibility : The base fee + a gas tip estimation, this value is directly usable for legacy transactions.

You can see the go-ethereum implementation of the RPC here where the base fee is explicitely added to a gasTipCap estimation.

You can also see it for yourself by running the following web3 code on mainnet:

const gasPrice = await web3.eth.getGasPrice();
console.log(web3.utils.fromWei(gasPrice, "Gwei"));

// Displays : 30.38 at the time of writing
// Which at block 14448993 is around 25 Gwei of base fee + 5 Gwei of gas tip cap.

I hope that answers your question.

For the error mentioned in the comments : given the code I linked, you may encounter an error as metioned in the comments if the current header cannot be accessed by your provider for any reason :

if head := s.b.CurrentHeader(); head.BaseFee != nil {
        tipcap.Add(tipcap, head.BaseFee)

As it would bypass the addition of the baseFee and probably result in a gasPrice lower than the baseFee itself leading to the rejection of your tx. That's just an idea.

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.