0

I have a solidity contract that compiles ok (0.5.1 compiler version), but it runs out of gas if I deploy the whole of it. If I comment some of the external methods of the contract, it compiles and deploys ok. I think the problem is not in the methods theirselves as I can comment any of them separately and it works.

I'm doing all this with truffle on a local network with ganache:

truffle migrate --network development --reset

The error:

Error:  *** Deployment Failed ***

"PPA" ran out of gas (using a value you set in your network config or deployment parameters.)
   * Block limit:  0x6691b7
   * Gas sent:     6721975

My truffle-config.js:

[...]
module.exports = {
  networks: {
    development: {
      provider: function() {
        return new HDWalletProvider(mnemonic, "http://127.0.0.1:7545")
      },
      network_id: 5777
    }
  },
  compilers: {
    solc: {
      version: "0.5.1"        
    }
  }
};

Any clue what's going on?

2
  • can you share your smart contract? chances are that it is throwing an exception somewhere Jun 1 '20 at 10:53
  • Try it on remix to see how much gas it takes to deploy it Jun 1 '20 at 10:55
0

You can and should define the provided GAS in the truffle-config.json, depending on the limitations of the used blockchain (ganache has the default gas limit of 0x6691b7 or 6721975) and the size of your contract binaries.

Try something like this:

[...]
module.exports = {
    networks: {
        development: {
            provider: function() {
                return new HDWalletProvider(mnemonic, "http://127.0.0.1:7545")
            },
            network_id: 5777,
            gas: 6721975 
        }
    },
    compilers: {
        solc: {
            version: "0.5.1"
    }
    }
};

In the case this does not work, you may increase the GAS limit to ganache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.