4

I am trying to create new contract but I get the error:

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

In the script, I have:

var balance =  web3.eth.getBalance(accounts[1])
console.log(balance.toNumber());
console.log('balance: ' + web3.fromWei(balance));

var gasPrice = web3.eth.gasPrice;
console.log('gasPrice '+gasPrice.toString(10));

contractData = web3.eth.contract(abi).new.getData({data: compiled});

var gasEstimate = web3.eth.estimateGas({data: contractData});
console.log('gas Estimate '+gasEstimate);
var total = gasEstimate*gasPrice;

console.log('total: ' + web3.fromWei(total));

web3.eth.contract(abi).new({from:accounts[1],data: compiled,gas:gasEstimate+3000}, function (err, contract) { ....

The output is:

balance: 15.95038514

gasPrice 20000000000

gas Estimate 84251

total: 0.00168502

Any idea what I am doing wrong?

Btw, I am running the Parity client.

  • Have you tried increasing the gas even more? I don't know about Parity, but in python I've had some trouble with gas estimation. An easy check is to set the gas to the gas limit. – 4gn3s Oct 3 '16 at 8:54
  • @4gn3s yep I did. I tried 100k and even more. same thing. Only visible effect is when I try to put to little gas. then it try to put contract in the block but it fails and give up after 50 blocks. And btw it works with testrpc – wonglik Oct 3 '16 at 9:00
  • Try this: ethereum.stackexchange.com/a/11142/5558 – lesyk Jan 5 '17 at 10:11
3

Running Parity with

--geth

flag fixed the issue.

More here

| improve this answer | |
  • 1
    link is broken. – huertanix Jun 14 '17 at 2:20
  • Yeah if anyone could provide an explanation for why the --geth flag is necessary, that would be cool – Lsaether Nov 26 '17 at 1:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.