Skip to content

Instantly share code, notes, and snippets.

@chetanyachopra
Last active September 8, 2020 06:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
A distributted and open lottery Smart Contract on ethereum which ensures total transparency in Lottery Systems which ensures trust in this Lottery Scheme
pragma solidity ^0.4.17;
contract Lottery {
address public manager;
address[] public players;
function Lottery() public {
manager = msg.sender;
}
function enter() public payable {
require(msg.value > .01 ether);
players.push(msg.sender);
}
function getPlayers() public view returns(address[]) {
return players;
}
function pickWinner() public restricted {
uint index = random() % players.length;
players[index].transfer(address(this).balance);
players = new address[](0);
}
function random() private view returns(uint) {
return uint(keccak256(now, players, block.difficulty));
}
modifier restricted() {
require(msg.sender == manager);
return _;
}
}
@chetanyachopra
Copy link
Author

A decentralized Lottery Scheme where noone controls the Scheme ... it's all about trust in the system.
Redirecting trust from centralized entity to everyone in the system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment