I'm trying to deploy the following simple contract to a private Ethereum chain using Geth 1.5.4-stable-b70acf3c:
pragma solidity ^0.4.0;
contract Faucet {
address owner;
uint256 sendAmount;
function Faucet() {
owner = msg.sender;
sendAmount = 1000000000000000000;
}
function getBalance() returns (uint) {
return this.balance;
}
function getWei() returns (bool) {
return msg.sender.send(sendAmount);
}
function sendWei(address toWhom) returns (bool) {
return toWhom.send(sendAmount);
}
function getSendAmount() returns (uint256) {
return sendAmount;
}
function killMe() returns (bool) {
if (msg.sender == owner) {
suicide(owner);
return true;
}
}
function () payable {}
}
Here are the commands I run in Geth console to deploy the contract:
> var faucetSource = "pragma solidity ^0.4.0; contract Faucet { address owner; uint256 sendAmount; function Faucet() { owner = msg.sender; sendAmount = 1000000000000000000; } function getBalance() returns (uint) { return this.balance; } function getWei() returns (bool) { return msg.sender.send(sendAmount); } function sendWei(address toWhom) returns (bool) { return toWhom.send(sendAmount); } function getSendAmount() returns (uint256) { return sendAmount; } function killMe() returns (bool) { if (msg.sender == owner) { suicide(owner); return true; } } function () payable {} }"
> var faucetCompiled = eth.compile.solidity(faucetSource)
> var faucetContract = eth.contract(faucetCompiled.Faucet.info.abiDefinition);
> var faucetInstanceTransaction = faucetContract.new({from:eth.coinbase, data:faucetCompiled.Faucet.code, value:1000000000000000000, gas:1000000}, function(err, contract){if(err){console.error(err);}else{console.log(contract.address);}});
And here is what I'm getting:
undefined
undefined
> Error: The contract code couldn't be stored, please check your gas amount.
I double checked and eth.coinbase is unlocked, and it has ether:
> web3.fromWei(eth.getBalance(eth.coinbase), 'ether');
8279.53125
Any idea of what's going wrong and how to troubleshoot that kind of issue?