0

I am writing test driven smart contracts. There is one smart contract with parameterized constructor. And I am using the require statement in the constructor. I want to catch the error in my test case. The returned error is:

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

According to me it should be related to Revert. Can any one tell me why its showing the error of Gas.

Below is the code:

constructor(
        TwoC _twoc
        ) Ownable() Destructible() payable public {
        require(_twoc != address(0));

    }

Test Case:

it('Initial :: Null-Economy-Address-TestCase', async () => {
    let twoc= await twoc.new();


    await obj.new(null_address);
  • There are few work around, from this message no one can have easily idea of what could be wrong! I would request you to add minimal example so at least we can try it our end. Also, please mention blockchain environment – Div Aug 27 '18 at 7:06
2

The part about gas amount is simply a "best guess". The system is trying to figure out why it fails but it actually doesn't have any idea.

The first part of the error message is more helpful: it fails to store the contract code because it fails to execute the constructor.

It's not uncommon around Ethereum to have misleading error messages. Currently it's just about having enough experience to recognize which (misleading) error message probably means what.

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.