i'm trying to deploy contracts on private network ganache using ganache application. but it threw an error because of its big size:

"contract x" ran out of gas. Something in the constructor (ex: infinite loop) caused gas estimation to fail. Try:
   * Making your contract constructor more efficient
   * Setting the gas manually in your config or as a deployment parameter
   * Using the solc optimizer settings in 'truffle-config.js'
   * Setting a higher network block limit if you are on a
     private network or test client (like ganache).

i tried to set a higher gas limit on ganache and changed it to 10000000 but still the same ptoblem. enter image description here

truffle network config:

networks: {
     development: {
       host: "",     // Localhost (default: none)
       port: 7545,
       network_id: "*"
  • Well, are you sure the contract constructor code execution can succeed? Commented Jul 22, 2022 at 10:33
  • yes, when i remove some instructions (reduce the size of contract), it works, i think something about contract size that when i exceede it the block limit size reaches. Commented Jul 22, 2022 at 11:16
  • Can you share the contract code? In ethereum there is a limitation of 24kb per transaction.
    – Ismael
    Commented Jul 23, 2022 at 3:33

1 Answer 1


You should be able to solve it by optimizing contract, comment out section in truffle-config.js file and set enable to true:

      settings: {          // See the solidity docs for advice about optimization and evmVersion
   optimizer: {
     enabled: true,
     runs: 200
   evmVersion: "berlin"
  • I don't think optimizing would really help in this case. Generally optimizing makes execution slightly cheaper at the expense of increasing the size of the code - if their issue is that their contract is too large, optimizing wont help, and will likely have the opposite effect
    – natewelch_
    Commented Aug 10, 2022 at 12:42

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.