I'm taking my first steps in Ethereum development.
What I'm trying to do is write a function that accepts an address and send it 1 ETH. I don't understand how to check if the contract has sufficient funds, tx.origin.balance is in wei format, how can I convert wei into eth.
function refillAccount(address receiver) payable returns(bool isRefilled) {
if (tx.origin.balance < [1 eth]) {
refilledAccounts[receiver] = false;
return false;
}
if ( !refilledAccounts[receiver] ) {
refilledAccounts[receiver] = true;
if( !receiver.send(1 ether) )
throw;
return true;
}
}