Guest User

Untitled

a guest
May 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. function DrawWinner() public payable {\
  2. require(drawParticipants.length == requiredParticipants);
  3.  
  4. uint blockNo = block.number - 1;
  5. uint winnerIndex = uint(block.blockhash(blockNo)) % requiredParticipants;
  6.  
  7. // This should never happen
  8. assert(winnerIndex < drawParticipants.length);
  9. address winner = drawParticipants[winnerIndex];
  10.  
  11. // reset the participants so the game can continue - you can do this in solidity
  12. drawParticipants.length = 0;
  13.  
  14. // Pay the winner
  15. winner.transfer(this.balance);
  16.  
  17. }
Add Comment
Please, Sign In to add comment