From 5cfe3e080c26e9c090ca3ec483c8516f5d7d1aeb Mon Sep 17 00:00:00 2001 From: monikacode2 <93213339+monikacode2@users.noreply.github.com> Date: Mon, 31 Oct 2022 23:15:33 +0530 Subject: [PATCH] Delete Lottery1.sol --- Lottery1.sol | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 Lottery1.sol diff --git a/Lottery1.sol b/Lottery1.sol deleted file mode 100644 index 4307125b..00000000 --- a/Lottery1.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >0.5.0 <= 0.9.0; - -contract Lottery1{ - address public manager; - address payable[] public players; // we have made payable because anyone of the participant can recieve the winning amount - - constructor() { - manager = msg.sender; - } - - modifier onlyManager { - require(manager == msg.sender,"You are not manager"); - _; - } - - receive() external payable { - players.push(payable(msg.sender)); - - } - - function getBalance() view public onlyManager returns(uint){ - return address(this).balance; - } - - function random()public view returns(uint){ - return uint(keccak256(abi.encodePacked(block.difficulty,block.timestamp,players.length))); - } - - function selectWinner() public onlyManager returns(address){ - require(players.length >= 3); - - address payable winner; - uint r = random(); - uint index = r % players.length; - - winner = payable(players[index]); - winner.transfer(getBalance()); - players = new address payable[](0); // resetting the contract - return winner; - } - -} \ No newline at end of file