0

i'm trying to run truffle migrate and it gives me always this error. Error: The contract code couldn't be stored, please check your gas amount.

 MBP-de-Alicia-2:smartContracts alicialombarte$ truffle migrate
Using network 'development'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x7291b9d65712a87c6c9937fc7c6bc110398d718d49ca18cb8399ecdaf04f6a7f
  Migrations: 0xef1878e96466e0c68d47f8124cd7518f694256a7
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying idFactory...
  ... 0x0e1b9dbb9f4a2d12c1e57757b13ffce046ff32a719643fe0cf671542cce4898b
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/webpack:/~/web3/lib/web3/contract.js:147:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:142:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:89:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-core/~/truffle-migrate/index.js:225:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)

Does anyone know why? i'm using Ganache CLI v6.0.3 (ganache-core: 2.0.2) Thanks !

EDIT. here is my truffle.js

module.exports = {
  networks: {
    development: {
        host: "localhost",
        port: 8545,
        network_id: "5777" // Match any network id
      }
  }
};
| improve this question | | | | |
  • Is it a big contract? Have you specified gas in truffle.js ? – Lauri Peltonen May 29 '18 at 15:16
  • Hi Lauri, it's not a big contract, just 30 lines. i've added the truffle.js to the question. – Alicia May 29 '18 at 15:21
  • Does your contract use a library like SafeMath and it is not linked? Does your contract implements an interface or inherits from a contract and you missed to implement a method or changed the signature of the method? – Ismael May 29 '18 at 16:37
0

You could try specifying the gas amount directly in truffle.js. I have this:

development: {
            host: "localhost",
            port: 8545,
            gas: 5600000,
            gasPrice: 10000000000,
            network_id: "*" // Match any network id
        }

One options is also to specify gas limits in the migration scripts for the deployment but as far as I've understood, that either has no effect or it's not recommended.

| improve this answer | | | | |
  • Now it says: Error: Exceeds block gas limit. MBP-de-Alicia-2:a alicialombarte$ truffle migrate Using network 'development'. Running migration: 1_initial_migration.js Deploying Migrations... ... undefined Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: Exceeds block gas limit – Alicia May 29 '18 at 15:25
  • Try a smaller gas amount – Lauri Peltonen May 29 '18 at 15:27
  • It doesn't matter the amount i try, it keeps returning the same error – Alicia May 29 '18 at 15:35

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.