Last active
September 8, 2020 06:06
-
-
Save chetanyachopra22/eb1723350521440b2009c4f135655cf6 to your computer and use it in GitHub Desktop.
A distributted and open lottery Smart Contract on ethereum which ensures total transparency in Lottery Systems which ensures trust in this Lottery Scheme
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
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 _; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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