1

Not Able to deploy to Ganache- Local chain, I have tried using func from Web3.eth , tried to import GasNowStrategy, Redownload the ganache as well and also tried to copy exact same code from GIT. Still facing same error This is exact error:

ValueError: Gas estimation failed: 'Error: Transaction's maxFeePerGas (0) is less than the block's baseFeePerGas (527514873) (vm hf=arrowGlacier -> block number=5 hash=0x970ba9015a3e3d50702d030dbda68f954af105f1f7151a86cbb9e1689e276593 hf=arrowGlacier baseFeePerGas=527514873 txs=0 uncles=0 -> tx type=0 hash=0x9d11dbd492c7ba143584b7928637c44e654540e48e513cfdb457230a93334544 nonce=4 value=0 signed=true hf=arrowGlacier gasPrice=0)'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually. enter image description here

3 Answers 3

3

This happens due to EIP-1559, which was added with the London block.

The protocol thus calculates a baseFeePerGas, which is the minimum price every transaction has to pay per unit of gas. On top of that, the EIP-1559 provides two extra parameters, which a user can include in the transaction. Those namely are:

  • maxPriorityFeePerGas. A tip to the miner to incentivize addition of the transaction to the next block.
  • maxFeePerGas. A maximum price that a transactor is willing to pay for the unit of gas.

Thus during the transaction construction process, the condition baseFeePerGas + maxPriorityFeePerGas =< maxFeePerGas has to be satisfied.

However, in your case the above condition does not hold because baseFeePerGas = 527514873 and maxFeePerGas = 0, as stated by the error:

...maxFeePerGas (0) is less than the block's baseFeePerGas (527514873)...

To solve this issue, please consider passing an additional maxFeePerGas parameter to your transaction object, which would at least be equal to the baseFeePerGas.

Note: Make sure that your account balance is sufficient.

1

The Ethereum London fork introduced a block-level base fee. Your transaction must set a gas price equal to or higher than the next block's base fee.

From python web3, you can use Eth.fee_history to get the base fee.

You can also get the base fee from latest block:

block = web3.eth.get_block('latest')
next_gas_price = math.ceil(block.get('baseFeePerGas') * 1.251)
1

Extending on GitHub20292's answer. You need to add maxFeePerGas (JS) or max_fee_per_gas (Python) whenever you're sending or signing a transaction.

Example (for Web.js)

const block = await web3.eth.getBlock('latest');
const next_gas_price = Math.ceil(block.baseFeePerGas);
const signRes = await web3.eth.accounts.signTransaction({
  to: recieverData.address,
  value: web3.utils.toWei(amountToSend.toString(), 'ether'),
  maxFeePerGas: next_gas_price,
  gas: 100000,
}, sendersData.privateKey);

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.