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 {
creator.send(1000000000000000000);
}
function kill() {
if (msg.sender == creator) {
suicide(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.