Skip to content
Verified contractPartial

LuckyDraw

Address0x9f43fa07a28399f7370efdbbd7dc02e39a715141
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.4.24

 

Same code

3 more contracts

 

Details

Compiler
solc 0.4.24+commit.e67f0147
Language
solidity
Optimization
Yes, 200 runs
License
Not stated
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
8,782,900
Creation transaction
0x000bab048f…cd29bcb6a9

LuckyDraw.sol

// Recovered by EthereumHistory (ethereumhistory.com) -sw
pragma solidity ^0.4.24;

contract LuckyDraw {
    address public admin;
    address[] private players;
    address private winner;

    constructor() public{
        admin = msg.sender;
        winner = address(0x0);
    }

    modifier onlyOwner() {
        require(msg.sender == admin, "Only Admin");
        _;
    }

    function random()
        private
        view
        returns (uint256)
    {
        return uint256(keccak256(abi.encodePacked(block.difficulty, now, players)));
    }

    function add(address _plyrAddr)
        public
    {
        players.push(_plyrAddr);
    }

    function draw()
        public
        returns (address)
    {
        winner =  players[random() % players.length];
        players = new address[](0);
        return winner;
    }

    function getPlayers()
        public
        view
        returns(address[])
    {
        return players;
    }
    function getPlayersCount()
        public
        view
        returns(uint256)
    {
        return players.length;
    }
    function getWinner()
        public
        view
        returns(address)
    {
        return winner;
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.