Last active
September 23, 2019 14:57
-
-
Save Kikimora/0be5cc476cb9e35ec9b66e5ada5faa86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract Lottery { | |
//standard ERC20 staff | |
//TODO: separate ERC20 token from this contract? | |
uint public contestFinishTime; //dec 31 | |
//Lottery starts in OPEN state | |
//then transiton to PICK_WINNER | |
//then to CLOSED | |
enum LotteryStates { | |
OPEN, | |
PICK_WINNER, | |
CLOSED, | |
//... | |
} | |
//Give 5000 tokens to owner | |
function Lottery() public {} | |
//function to withdraw up to 50% of funds | |
function withdraw() payable onlyBy(owner) {} | |
//called by creator to deposit eth without having tokens issued before contestFinishTime. | |
function deposit() payable onlyBy(owner) {} | |
//called by anyone to buy tokens before contestFinishTime | |
function buyTokens() payable atState(LotteryStates.OPEN) {} | |
//called by creator to send ETH to a selected address, this transition contract to WINNER_PICKED state | |
function pickWinner(address winner) onlyBy(owner) atState(LotteryStates.PICK_WINNER) {} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment