Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function DrawWinner() public payable {\
- require(drawParticipants.length == requiredParticipants);
- uint blockNo = block.number - 1;
- uint winnerIndex = uint(block.blockhash(blockNo)) % requiredParticipants;
- // This should never happen
- assert(winnerIndex < drawParticipants.length);
- address winner = drawParticipants[winnerIndex];
- // reset the participants so the game can continue - you can do this in solidity
- drawParticipants.length = 0;
- // Pay the winner
- winner.transfer(this.balance);
- }
Add Comment
Please, Sign In to add comment