Created a little smart contract lottery. Let me know what you guys think. Does the code look good?

aaroneusthgreataaroneusthgreat Member Posts: 1
Here's the contract address.

Here's the code:

contract EtherBuyTheBlock { address owner; address hotAccount = 0xA8Ca03e8BA138769384745456C99Fb86c3DE17d9; string public currentState = ''; /* this function is executed at initialization and sets the owner of the contract */ function mortal() { owner = msg.sender; } /* Function to recover the funds on the contract */ function kill() { if (msg.sender == owner) selfdestruct(owner); } function placeWager() public { if (msg.value >= 0 finney && msg.value < 256 finney) { if (this.balance > 6500 finney) { bool success = msg.sender.send(5 finney); if (success == true) { success = hotAccount.send(1 finney); if (success == true) { currentState = 'You win!'; } } } else { currentState = 'Not a winner, sorry! - Try again later.'; } } } function readMessage() public returns(string) { return currentState; } }

What does everyone think? You can submit between 0 and 256 finney for a wager. I wasn't sure how to reject a transaction if it was outside this state, but it doesn't run the check for the payout without you betting less than 256 finney. I allowed zero for testing purposes, but it really probably would be a waste of time in the real world to put up nothing.
Sign In or Register to comment.