Skip to main content
Post Closed as "Duplicate" by q9f
Bumped by Community user
Bumped by Community user

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.

Error.

inIn 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 Paritythe Parity client.

thanks

-w

I am trying to create new contract but I get

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

Error.

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) { ....

output is  :

balance: 15.95038514

gasPrice 20000000000

gas Estimate 84251

total: 0.00168502

Any idea what I am doing wrong?

Btw I am running Parity client.

thanks

-w

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.

Source Link
wonglik
  • 315
  • 2
  • 9

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

I am trying to create new contract but I get

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

Error.

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) { ....

output is :

balance: 15.95038514

gasPrice 20000000000

gas Estimate 84251

total: 0.00168502

Any idea what I am doing wrong?

Btw I am running Parity client.

thanks

-w