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: ' + 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
    Commented Oct 3, 2016 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
    Commented Oct 3, 2016 at 9:00
  • Try this: ethereum.stackexchange.com/a/11142/5558
    – lesyk
    Commented Jan 5, 2017 at 10:11

1 Answer 1


Running Parity with


flag fixed the issue.

More here

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

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