Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

"Error: The contract code couldn't be stored, please check your gas amount." on any constructor error #522

Closed
maraoz opened this issue Jul 30, 2017 · 11 comments

Comments

@maraoz
Copy link

maraoz commented Jul 30, 2017

Any error instantiating a contract results in the above message. I remember truffle used to report stuff like: "contract is abstract" or "constructor threw"

@illuzen
Copy link

illuzen commented Oct 21, 2017

Related, probably not the same, I frequently find that I have to rm -r build/ to get this error to go away.

@dwalintukan
Copy link

I received this just now when copying my token code into another project. I didn't receive any sort of warning about any constructor error.

My token code's Ownable contract constructor is:

function Ownable() public {
    owner = msg.sender;
  }

While the contract I imported my token code to has this Ownable constructor:

function Ownable(address _owner) public validAddress(_owner) {
        owner = _owner;
    }

So I had to satisfy the constructor with the new Ownable param. But truffle did not warn of anything with this. It just gave me this error which was not very descriptive of the actual issue:

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:329221:46)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:39618:25
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:331159:9
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:175492:11
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:314196:9
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:329855:7)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:70159:18)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:70449:12)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:70604:12)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:70564:24)

@illuzen
Copy link

illuzen commented Dec 2, 2017

Could be contract name collision. Check your abstract contract names and see if they collide with anything. :?

@pawel-n
Copy link

pawel-n commented Dec 2, 2017

What me doing wring was modify array in constructor. I did this:
tiers[0] = Tier(2500000 * 10**18, 0, 0.0007 * 10**18);.
Contact was deployed when I moved this line to setup method :)

@jtakalai
Copy link
Contributor

I had this problem, and solved it by pasting the flattened code into Remix that then gave a better error description: I had an interface in the contract that I had not implemented correctly (wrong function signature). Trying to deploy an "abstract contract" gives this error, but a much better error would be what Remix gives: "This contract does not implement all functions and thus cannot be created."

@stale
Copy link

stale bot commented Nov 17, 2018

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

@stale stale bot added the stale label Nov 17, 2018
@jtakalai
Copy link
Contributor

Probably still valid though

@stale
Copy link

stale bot commented Nov 22, 2018

Thanks for your response! This issue is no longer considered stale and someone from the Truffle team will try to respond as soon as they can.

@stale stale bot removed the stale label Nov 22, 2018
@gnidan
Copy link
Contributor

gnidan commented Jan 9, 2019

Thanks for the explanation @jtakalai. We will look into improving the error messaging for that situation.

@stale
Copy link

stale bot commented May 9, 2019

Thank you for raising this issue! It has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you would like to keep this issue open, please respond with information about the current state of this problem.

@stale stale bot added the stale label May 9, 2019
@stale
Copy link

stale bot commented May 23, 2019

There has been no new activity on this issue since it was marked as stale 7 days ago, so it is being automatically closed. If you'd like help with this or a different problem, please open a new issue. Thanks!

@stale stale bot closed this as completed May 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants