2

I am trying to deploy the SimpleToken code from the Open Zeppelin project and seem to always run out of gas when deploying it to either Kovan or Ganache.

I even specified 4700000 gas in the truffle.js file which is the max gas I can provide. There is nothing fancy in the code - its literally copy and paste from Open Zeppelin.

https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/ERC20/StandardToken.sol

and I have all the dependent files as well using the import statements.

Any advise is greatly appreciated!

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x627e13286c9ecbf8f9a0eae53a5e9a0788c9fe42cb6234d9734868a8eb4a70d9
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: The contract code couldn't be stored, please check your gas amount.
    at Object.callback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:328412:46)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:37990:25
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:330356:9
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:176198:11
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:326008:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:329052:7)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176427:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176717:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176872:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:176832:24)

3 Answers 3

5

If anyone else is getting the error:

Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: VM Exception while processing transaction: out of gas

Delete the ./build directory and enable the solc optimizer in truffle.js:

module.exports = {
    networks: {
        development: {
            host: "localhost",
            port: 8545, // Using ganache as development network
            network_id: "*",
            gas: 4698712,
            gasPrice: 25000000000
        }
    },
    solc: {
        optimizer: {
            enabled: true,
            runs: 200
        }
    }
};
3
  • This helped me as well. But where can I find documentation about solc optimizer ? Commented Aug 23, 2018 at 13:48
  • 1
    sorry but where is the ./build directory located?
    – srinivas
    Commented Apr 23, 2020 at 21:20
  • @srinivas at the time of this writing, it was in the truffle project top level directory (where the truffle.js file is)
    – Miguel
    Commented Apr 23, 2020 at 22:10
0

Try setting your gas limit a little lower. I had a similar problem and adjusting to 4612388 seemed to do the trick.

0

I've noticed that the OpenZeppelin files aren't always up-to-date, so they don't always all work together. They can be mostly used as... a guideline of sorts.

But fear not, you are not alone with your error messages. This forum is full of answers to that error message, here are some common ones: Error: The contract code couldn't be stored, please check your gas amount

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.