1
Sale.new({ from: state.account, value: value, gas: 4000000 }).then((instance) => {
  // do something with instance
}).catch((err) => {
  alert(err)
})

When the above code runs I sometimes receive this error: The contract code couldn't be stored, please check your gas amount.

The contract I am trying to create is almost exactly the same as the safe remote payment contract in the solidity docs with maybe just a few more lines.

The weird thing is that the contract actuallygets created and I can see the successful transaction in MetaMask and the Ether is subtracted from my account. I can even then use Sale.at(<new contract address>) to interact with the created contract. I've been testing in the Ropsten network.

1

One thing you didn't mention here is that previously this worked fine, but about a week ago this stopped working.

This makes me think it's a bug with MetaMask, and I'm sorry we haven't gotten to figure it out yet: https://github.com/MetaMask/metamask-plugin/issues/1361

1

This feels like one of those very broad errors. I encountered it when I added a function argument without updating my ABI file (I keep function definitions and functions in separate files) - this led to the function definition being inconsistent with the implementation.

Hope that helps someone.

  • This was my problem with this error message. I had added a function to the abstract contract, but not to the implemented contract. – mkaj Jul 23 '17 at 2:55
0

you got the error after the exception thrown in the constructor.

i think there is something wrong with this snippet :

  function Purchase() payable {
        seller = msg.sender;
        value = msg.value / 2;
        if (2 * value != msg.value) throw;
    }

it's likely to throw an exception while 2*value==msg.value.

  • Why is it likely to throw an exception? And it this throws then shouldn't the transaction be rolled back? Why does it get created successfully? – Wilfred May 1 '17 at 16:01
  • what's value you send in the creation transaction? – Badr Bellaj May 1 '17 at 17:50
  • The user will type in something like 0.1. Which is then ran through web3.toWei(web3.toBigNumber(0.1).times(2), 'ether') So I would think that the constructor should be able to divide the value sent equally into 2 parts because it was multiplied by 2 before being sent. – Wilfred May 1 '17 at 17:58

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.