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.

jrbedard
  • 524
  • 1
  • 6
  • 15
wonglik
  • 315
  • 2
  • 9
  • 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 03 '16 at 08: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 03 '16 at 09:00
  • Try this: http://ethereum.stackexchange.com/a/11142/5558 – lesyk Jan 05 '17 at 10:11

1 Answers1

3

Running Parity with

--geth

flag fixed the issue.

More here

wonglik
  • 315
  • 2
  • 9