0

I am trying to test a contract using Hardhat and want to set the gas price to zero. This will make it easier to see if my functions are working correctly, in that I can easily calculate the correct answer to many digits absent gas costs, while adjusting for gas on each transaction is a major pain. I tried to set the gas price to zero in hardhat.config.js, but when I ran npx hardhat test it gave me the error

InvalidInputError: Transaction gasPrice (0) is too low for the next block, which has a baseFeePerGas of 875000000

Is there a way to set the gas price to zero in Hardhat? I am using hardhat 2.14.0.

1
  • Hardhat replicate how the real chain works and there is no way to send a tx with zero gas because that means you are not sending enough eth to do anything, you could try doing a static call instead
    – Julissa DC
    Jul 20, 2023 at 15:03

1 Answer 1

1

If you just have gasPrice: 0 in the config file, it won't work, but I just discovered that if additionally, you set initialBaseFeePerGas: 0, it works.

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.