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)
Shane Fontaine
  • 18,036
  • 20
  • 54
  • 82
wardsback
  • 399
  • 1
  • 5
  • 12

3 Answers3

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
        }
    }
};
Miguel Mota
  • 5,143
  • 29
  • 47
0

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

Howard
  • 421
  • 2
  • 6
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

Lauri Peltonen
  • 29,391
  • 3
  • 20
  • 57