0

I am getting this error:

Error: The contract code couldn't be stored, please check your gas amount.

This is when I am importing one extra contract with the name of TimedCrowdsale from OpenZeppelin. There was no error earlier when I imported and used Crowdsale, MintedCrowdsale and CappedCrowdsale from openzeppelin.

  • 1
    Welcome to StackExchange ajay! What gas value did you put in your truffle configuration file? – Paul Razvan Berg Sep 12 '18 at 17:46
  • hi paul i changed the the gas value to 7492052.still its showing the same message .when i remove the timedtoken the contract runs properly – AVATAR Sep 14 '18 at 7:56
1

That's the thing with putting more and more code in your contract, in this case, by means of inheriting OpenZeppelin awesomely crafted ready solutions: your byte code size grows accordingly.

Here are some ways to check and overcome the problem:

  • check if you really need everything you inherit
  • put a higher gasLimit to your truffle.js config, try gas: 7492052, which is higher than the value in Truffle's defaults, and than in Rinkeby testnet.
  • use optimizer settings to make bytecode slimmer and deploy cheaper
  • if the above doesn't let you deploy and at least see your actual deploy cost, try commenting some functionality out and trying local deploy without something
  • if the steps above show that you really need this much code and more, you can chop it in parts and deploy some of it as libraries or as separated contracts, one addressing another, depending on what fits you best.

Hope it helps, that's basically my own trial-and-error conspectus on the matter.

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.