6

I'm just running some tests with massive functions, and I keep running into

InvalidInputError: Transaction gas limit is 30429720 and exceeds block gas limit of 30000000

How do I increase the block gas limit in hardhat?

2 Answers 2

5

If your hardhat.config.js increase the blockGasLimit

module.exports = {
    defaultNetwork: "hardhat",
    networks: {
        hardhat: {
            blockGasLimit: 100000000429720 // whatever you want here
        },
    }
}
1

There is an option like allowUnlimitedContractSize: true,, you might find its usage below. In one place I found Error: cannot estimate gas; transaction may fail or may require manual gas limit might appear by different reasons and cannot estimate gas might throttle the main error -- can not prove it in my experience, when I had increased gas limit the issue was disappeared, but it is important to keep it in mind.

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

const config: HardhatUserConfig = {
  solidity: "0.8.9",
  networks: {
    hardhat: {
      allowUnlimitedContractSize: true,
    }
  }
  
};

export default config;

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.