4

Truffle v4 used to deploy the contract successfully, but Truffle v5 truffle migrate command fails.

My process to deploy:

1) delete buidl/ folder

2) truffle compile

3) truffle migrate

Truffle v5

The error I get is:

Error:  *** Deployment Failed ***
"ContractName" 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.js'
* Setting a higher network block limit if you are on a
 private network or test client (like ganache).

at C:\Users\dziug\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-deployer\src\deployment.js:364:1
at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.0.0 (core: 5.0.0)
Node v10.4.0

My truffle-config.js looks like this:

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*',
  compilers: {
    solc: { 
      version: "^0.4.24",
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  }

Then I installed truffle v4 and tried to migrate the same contract:

1) npm uninstall -g truffle

2) npm install -g truffle@4.1.15

3) delete buidl/ folder

4) truffle compile

5) truffle migrate

And it works. I can deploy it on the rinkeby too.

Remix doesn't deploy it with

javascript VM: "creation of ContractName errored: transaction execution failed"

However, I can deploy it to Rinkeby through Remix

I need this contract to be deployed with truffle v5, because I will develop Solidity 0.5.* contracts that will communicate with the one I am trying to deploy right now, otherwise I won't be able to test with javascript.

The contract I am trying to deploy is: https://github.com/cryptocopycats/awesome-cryptokitties/tree/master/contracts

with couple fixes and additions. Contract starts from KittyCore.sol

3

Check @goodvibration answer. It should work in most instances.

I don't recommend the answer that I will share below, it will ignore the EIP-170, hopefully there is a better answer

I was only able to make it migrate using: ganache-cli --gasLimit=0x1fffffffffffff --allowUnlimitedContractSize -e 1000000000

--allowUnlimitedContractSize: "Allows unlimited contract sizes while debugging. By enabling this flag, the check within the EVM for contract size limit of 24KB (see EIP-170) is bypassed. Enabling this flag will cause ganache-cli to behave differently than production environments."

-e {number}: gives that much ether to all 10 accounts

My truffle-config.js looks like this:

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*',
      gas: 0x1fffffffffffff
    },
  }
}
0

Your truffle-config.js file is not correct. Have a look at: https://github.com/trufflesuite/truffle/releases/tag/v5.0.0-beta.0#bring-your-own-compiler

For the correct format for the truffle-config.js file.

  • Instead of saying that the config file is not correct, it would be way more useful if you pointed out what is wrong with it, and provide a fix, instead of referring to a fairly broad documentation where it's hard to figure out what's wrong with it. – Victor Grau Serrat Jan 29 at 3:55
  • I didn't mean to be unhelpful, your truffle-config.js file doesn't seem to be correct. I was just speaking plainly. The documentation is the best place to check, and the correct format is right at the top. Specifically: It's not a valid javascript object for one thing (6 open curly braces, 3 close curly braces) and it should have a format like this: module.exports = { networks: { ... etc ... }, compilers: { solc: { version: <string> // ex: "0.4.20". (Default: Truffle's installed solc) } } }; – Dennison Bertram Jan 30 at 19:09
0

I think the problem is in your config:

module.exports = {
  networks: {
    development: {
      host: 'localhost',
      port: 8545,
      network_id: '*',
  compilers: {
    solc: { 
      version: "^0.4.24", // this line
      optimizer: {
        enabled: true,
        runs: 200
      }
    }
  }

If you want to use v5, you have to change to appropriate solc version, like 0.5.0

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.