I wrote the following contract :

contract EndowmentRetriever {

    address creator;
    uint contract_creation_value;

    function EndowmentRetriever() public payable {
        creator = msg.sender;
        contract_creation_value = msg.value;

    function getContractCreationValue() constant returns (uint) {                               
        return contract_creation_value;                         

    function sendOneEtherHome() public {                        

    function kill() { 
        if (msg.sender == creator) {

When I am creating a new contract using the following transaction

var EdRet = edRetContract.new({from:web3.eth.accounts[0], data: edRetCompiled.EdRetriever.code, gas: 1000000, value: 3000000000000000000}, function(e, contract){ 
    if(!e) { 
        if(!contract.address) { 
            console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined..."); } 
        else { 
            console.log("Contract mined! Address: " + contract.address); 
            console.log(contract); } 
    else { 
        console.log(e); } 

I am getting the following error message :

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

If I remove the value parameter in the transaction(i.e. the initial endowment to the contract), then the contract got mined. What could be the possible reason.


1 Answer 1


try to send more gas, i propose you to use gas:gasEstimate+30000

 var EdRet = edRetContract.new({from:web3.eth.accounts[0], data: edRetCompiled.EdRetriever.code,
      gas:gasEstimate+30000, value: 3000000000000000000}, function(e, contract){ 
  • already tried this, it is not working, getting the same error.
    – serial007
    Dec 21, 2016 at 11:42
  • are you using parity?
    – Badr Bellaj
    Dec 21, 2016 at 11:58
  • I have been testing your contract and there are some weird things happening, and it's to do with the payable modifier. 1. You cannot send ethers when you are creating the contract, even if you specify the payable modifier. 2. When you have a payable function that modifies the contract_creation_value variable, there will be an exception retrieving the contract_creation_value value. I'll try to investigate further over the next few days. Dec 21, 2016 at 15:26
  • @ Badr Bellaj, I am using geth
    – serial007
    Dec 22, 2016 at 6:03
  • @ BokkaPooBah : regarding your point 1) if I cannot send ether when creating the contract, then how can I make initial endowment.
    – serial007
    Dec 22, 2016 at 6:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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