ETH Price: $3,926.89 (+1.00%)

Contract

0x8Ee5b95C5676224bDb70115996F8674024355590
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Purchase Tickets118266442021-02-10 4:37:111402 days ago1612931831IN
0x8Ee5b95C...024355590
0 ETH0.01272421105
Purchase Tickets118188992021-02-08 23:58:261403 days ago1612828706IN
0x8Ee5b95C...024355590
0 ETH0.01678264111
Purchase Tickets118167982021-02-08 16:08:151404 days ago1612800495IN
0x8Ee5b95C...024355590
0 ETH0.0453657300
Purchase Tickets118167742021-02-08 16:04:181404 days ago1612800258IN
0x8Ee5b95C...024355590
0 ETH0.04852974321
Purchase Tickets118154822021-02-08 11:12:031404 days ago1612782723IN
0x8Ee5b95C...024355590
0 ETH0.01526948101
Purchase Tickets118144652021-02-08 7:35:411404 days ago1612769741IN
0x8Ee5b95C...024355590
0 ETH0.01632776108
Purchase Tickets118142992021-02-08 6:59:301404 days ago1612767570IN
0x8Ee5b95C...024355590
0 ETH0.01723486114
Purchase Tickets118141642021-02-08 6:29:161404 days ago1612765756IN
0x8Ee5b95C...024355590
0 ETH0.01542066102
Purchase Tickets118128022021-02-08 1:21:211404 days ago1612747281IN
0x8Ee5b95C...024355590
0 ETH0.0151171100
Purchase Tickets118109962021-02-07 18:44:121405 days ago1612723452IN
0x8Ee5b95C...024355590
0 ETH0.02675939177
Purchase Tickets118061442021-02-07 0:54:551405 days ago1612659295IN
0x8Ee5b95C...024355590
0 ETH0.01587673105
Purchase Tickets118020732021-02-06 9:56:221406 days ago1612605382IN
0x8Ee5b95C...024355590
0 ETH0.01593341117
Purchase Tickets118006622021-02-06 4:46:311406 days ago1612586791IN
0x8Ee5b95C...024355590
0 ETH0.01770379130.0000016
Purchase Tickets117989072021-02-05 22:17:051406 days ago1612563425IN
0x8Ee5b95C...024355590
0 ETH0.02267745150
Purchase Tickets117938272021-02-05 3:22:081407 days ago1612495328IN
0x8Ee5b95C...024355590
0 ETH0.03356262222
Purchase Tickets117882802021-02-04 7:02:321408 days ago1612422152IN
0x8Ee5b95C...024355590
0 ETH0.0151183100
Purchase Tickets117859112021-02-03 22:14:391408 days ago1612390479IN
0x8Ee5b95C...024355590
0 ETH0.0176816116.955
Purchase Tickets117811372021-02-03 4:28:351409 days ago1612326515IN
0x8Ee5b95C...024355590
0 ETH0.01947416143
Purchase Tickets117778852021-02-02 16:27:181410 days ago1612283238IN
0x8Ee5b95C...024355590
0 ETH0.01239782
Purchase Tickets117778302021-02-02 16:18:181410 days ago1612282698IN
0x8Ee5b95C...024355590
0 ETH0.03976112263
Purchase Tickets117751912021-02-02 6:23:331410 days ago1612247013IN
0x8Ee5b95C...024355590
0 ETH0.01783959118
Purchase Tickets117751262021-02-02 6:09:161410 days ago1612246156IN
0x8Ee5b95C...024355590
0 ETH0.0136053990
Purchase Tickets117739522021-02-02 1:55:231410 days ago1612230923IN
0x8Ee5b95C...024355590
0 ETH0.02086325138
Purchase Tickets117738152021-02-02 1:24:341410 days ago1612229074IN
0x8Ee5b95C...024355590
0 ETH0.02343336155
Purchase Tickets117732872021-02-01 23:29:061410 days ago1612222146IN
0x8Ee5b95C...024355590
0 ETH0.0266082176
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Lottery

Compiler Version
v0.5.17+commit.d19bba13

Optimization Enabled:
Yes with 999999 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity)

/**
 *Submitted for verification at Etherscan.io on 2021-01-30
*/

// SPDX-License-Identifier: Apache2.0

pragma solidity ^0.5.0;


// 
/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMathChainlink {
  /**
    * @dev Returns the addition of two unsigned integers, reverting on
    * overflow.
    *
    * Counterpart to Solidity's `+` operator.
    *
    * Requirements:
    * - Addition cannot overflow.
    */
  function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    require(c >= a, "SafeMath: addition overflow");

    return c;
  }

  /**
    * @dev Returns the subtraction of two unsigned integers, reverting on
    * overflow (when the result is negative).
    *
    * Counterpart to Solidity's `-` operator.
    *
    * Requirements:
    * - Subtraction cannot overflow.
    */
  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    require(b <= a, "SafeMath: subtraction overflow");
    uint256 c = a - b;

    return c;
  }

  /**
    * @dev Returns the multiplication of two unsigned integers, reverting on
    * overflow.
    *
    * Counterpart to Solidity's `*` operator.
    *
    * Requirements:
    * - Multiplication cannot overflow.
    */
  function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
    // benefit is lost if 'b' is also tested.
    // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
    if (a == 0) {
      return 0;
    }

    uint256 c = a * b;
    require(c / a == b, "SafeMath: multiplication overflow");

    return c;
  }

  /**
    * @dev Returns the integer division of two unsigned integers. Reverts on
    * division by zero. The result is rounded towards zero.
    *
    * Counterpart to Solidity's `/` operator. Note: this function uses a
    * `revert` opcode (which leaves remaining gas untouched) while Solidity
    * uses an invalid opcode to revert (consuming all remaining gas).
    *
    * Requirements:
    * - The divisor cannot be zero.
    */
  function div(uint256 a, uint256 b) internal pure returns (uint256) {
    // Solidity only automatically asserts when dividing by 0
    require(b > 0, "SafeMath: division by zero");
    uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold

    return c;
  }

  /**
    * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
    * Reverts when dividing by zero.
    *
    * Counterpart to Solidity's `%` operator. This function uses a `revert`
    * opcode (which leaves remaining gas untouched) while Solidity uses an
    * invalid opcode to revert (consuming all remaining gas).
    *
    * Requirements:
    * - The divisor cannot be zero.
    */
  function mod(uint256 a, uint256 b) internal pure returns (uint256) {
    require(b != 0, "SafeMath: modulo by zero");
    return a % b;
  }
}

// 
interface LinkTokenInterface {
  function allowance(address owner, address spender) external view returns (uint256 remaining);
  function approve(address spender, uint256 value) external returns (bool success);
  function balanceOf(address owner) external view returns (uint256 balance);
  function decimals() external view returns (uint8 decimalPlaces);
  function decreaseApproval(address spender, uint256 addedValue) external returns (bool success);
  function increaseApproval(address spender, uint256 subtractedValue) external;
  function name() external view returns (string memory tokenName);
  function symbol() external view returns (string memory tokenSymbol);
  function totalSupply() external view returns (uint256 totalTokensIssued);
  function transfer(address to, uint256 value) external returns (bool success);
  function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool success);
  function transferFrom(address from, address to, uint256 value) external returns (bool success);
}

// 
contract VRFRequestIDBase {

  /**
   * @notice returns the seed which is actually input to the VRF coordinator
   *
   * @dev To prevent repetition of VRF output due to repetition of the
   * @dev user-supplied seed, that seed is combined in a hash with the
   * @dev user-specific nonce, and the address of the consuming contract. The
   * @dev risk of repetition is mostly mitigated by inclusion of a blockhash in
   * @dev the final seed, but the nonce does protect against repetition in
   * @dev requests which are included in a single block.
   *
   * @param _userSeed VRF seed input provided by user
   * @param _requester Address of the requesting contract
   * @param _nonce User-specific nonce at the time of the request
   */
  function makeVRFInputSeed(bytes32 _keyHash, uint256 _userSeed,
    address _requester, uint256 _nonce)
    internal pure returns (uint256)
  {
    return  uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce)));
  }

  /**
   * @notice Returns the id for this request
   * @param _keyHash The serviceAgreement ID to be used for this request
   * @param _vRFInputSeed The seed to be passed directly to the VRF
   * @return The id for this request
   *
   * @dev Note that _vRFInputSeed is not the seed passed by the consuming
   * @dev contract, but the one generated by makeVRFInputSeed
   */
  function makeRequestId(
    bytes32 _keyHash, uint256 _vRFInputSeed) internal pure returns (bytes32) {
    return keccak256(abi.encodePacked(_keyHash, _vRFInputSeed));
  }
}

// 
/** ****************************************************************************
 * @notice Interface for contracts using VRF randomness
 * *****************************************************************************
 * @dev PURPOSE
 *
 * @dev Reggie the Random Oracle (not his real job) wants to provide randomness
 * @dev to Vera the verifier in such a way that Vera can be sure he's not
 * @dev making his output up to suit himself. Reggie provides Vera a public key
 * @dev to which he knows the secret key. Each time Vera provides a seed to
 * @dev Reggie, he gives back a value which is computed completely
 * @dev deterministically from the seed and the secret key.
 *
 * @dev Reggie provides a proof by which Vera can verify that the output was
 * @dev correctly computed once Reggie tells it to her, but without that proof,
 * @dev the output is indistinguishable to her from a uniform random sample
 * @dev from the output space.
 *
 * @dev The purpose of this contract is to make it easy for unrelated contracts
 * @dev to talk to Vera the verifier about the work Reggie is doing, to provide
 * @dev simple access to a verifiable source of randomness.
 * *****************************************************************************
 * @dev USAGE
 *
 * @dev Calling contracts must inherit from VRFConsumerBase, and can
 * @dev initialize VRFConsumerBase's attributes in their constructor as
 * @dev shown:
 *
 * @dev   contract VRFConsumer {
 * @dev     constuctor(<other arguments>, address _vrfCoordinator, address _link)
 * @dev       VRFConsumerBase(_vrfCoordinator, _link) public {
 * @dev         <initialization with other arguments goes here>
 * @dev       }
 * @dev   }
 *
 * @dev The oracle will have given you an ID for the VRF keypair they have
 * @dev committed to (let's call it keyHash), and have told you the minimum LINK
 * @dev price for VRF service. Make sure your contract has sufficient LINK, and
 * @dev call requestRandomness(keyHash, fee, seed), where seed is the input you
 * @dev want to generate randomness from.
 *
 * @dev Once the VRFCoordinator has received and validated the oracle's response
 * @dev to your request, it will call your contract's fulfillRandomness method.
 *
 * @dev The randomness argument to fulfillRandomness is the actual random value
 * @dev generated from your seed.
 *
 * @dev The requestId argument is generated from the keyHash and the seed by
 * @dev makeRequestId(keyHash, seed). If your contract could have concurrent
 * @dev requests open, you can use the requestId to track which seed is
 * @dev associated with which randomness. See VRFRequestIDBase.sol for more
 * @dev details. (See "SECURITY CONSIDERATIONS" for principles to keep in mind,
 * @dev if your contract could have multiple requests in flight simultaneously.)
 *
 * @dev Colliding `requestId`s are cryptographically impossible as long as seeds
 * @dev differ. (Which is critical to making unpredictable randomness! See the
 * @dev next section.)
 *
 * *****************************************************************************
 * @dev SECURITY CONSIDERATIONS
 *
 * @dev A method with the ability to call your fulfillRandomness method directly
 * @dev could spoof a VRF response with any random value, so it's critical that
 * @dev it cannot be directly called by anything other than this base contract
 * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method).
 *
 * @dev For your users to trust that your contract's random behavior is free
 * @dev from malicious interference, it's best if you can write it so that all
 * @dev behaviors implied by a VRF response are executed *during* your
 * @dev fulfillRandomness method. If your contract must store the response (or
 * @dev anything derived from it) and use it later, you must ensure that any
 * @dev user-significant behavior which depends on that stored value cannot be
 * @dev manipulated by a subsequent VRF request.
 *
 * @dev Similarly, both miners and the VRF oracle itself have some influence
 * @dev over the order in which VRF responses appear on the blockchain, so if
 * @dev your contract could have multiple VRF requests in flight simultaneously,
 * @dev you must ensure that the order in which the VRF responses arrive cannot
 * @dev be used to manipulate your contract's user-significant behavior.
 *
 * @dev Since the ultimate input to the VRF is mixed with the block hash of the
 * @dev block in which the request is made, user-provided seeds have no impact
 * @dev on its economic security properties. They are only included for API
 * @dev compatability with previous versions of this contract.
 *
 * @dev Since the block hash of the block which contains the requestRandomness
 * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful
 * @dev miner could, in principle, fork the blockchain to evict the block
 * @dev containing the request, forcing the request to be included in a
 * @dev different block with a different hash, and therefore a different input
 * @dev to the VRF. However, such an attack would incur a substantial economic
 * @dev cost. This cost scales with the number of blocks the VRF oracle waits
 * @dev until it calls responds to a request.
 */
contract VRFConsumerBase is VRFRequestIDBase {

  using SafeMathChainlink for uint256;

  /**
   * @notice fulfillRandomness handles the VRF response. Your contract must
   * @notice implement it. See "SECURITY CONSIDERATIONS" above for important
   * @notice principles to keep in mind when implementing your fulfillRandomness
   * @notice method.
   *
   * @dev VRFConsumerBase expects its subcontracts to have a method with this
   * @dev signature, and will call it once it has verified the proof
   * @dev associated with the randomness. (It is triggered via a call to
   * @dev rawFulfillRandomness, below.)
   *
   * @param requestId The Id initially returned by requestRandomness
   * @param randomness the VRF output
   */
  function fulfillRandomness(bytes32 requestId, uint256 randomness)
    internal;

  /**
   * @notice requestRandomness initiates a request for VRF output given _seed
   *
   * @dev The fulfillRandomness method receives the output, once it's provided
   * @dev by the Oracle, and verified by the vrfCoordinator.
   *
   * @dev The _keyHash must already be registered with the VRFCoordinator, and
   * @dev the _fee must exceed the fee specified during registration of the
   * @dev _keyHash.
   *
   * @dev The _seed parameter is vestigial, and is kept only for API
   * @dev compatibility with older versions. It can't *hurt* to mix in some of
   * @dev your own randomness, here, but it's not necessary because the VRF
   * @dev oracle will mix the hash of the block containing your request into the
   * @dev VRF seed it ultimately uses.
   *
   * @param _keyHash ID of public key against which randomness is generated
   * @param _fee The amount of LINK to send with the request
   * @param _seed seed mixed into the input of the VRF.
   *
   * @return requestId unique ID for this request
   *
   * @dev The returned requestId can be used to distinguish responses to
   * @dev concurrent requests. It is passed as the first argument to
   * @dev fulfillRandomness.
   */
  function requestRandomness(bytes32 _keyHash, uint256 _fee, uint256 _seed)
    internal returns (bytes32 requestId)
  {
    LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, _seed));
    // This is the seed passed to VRFCoordinator. The oracle will mix this with
    // the hash of the block containing this request to obtain the seed/input
    // which is finally passed to the VRF cryptographic machinery.
    uint256 vRFSeed  = makeVRFInputSeed(_keyHash, _seed, address(this), nonces[_keyHash]);
    // nonces[_keyHash] must stay in sync with
    // VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
    // successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
    // This provides protection against the user repeating their input seed,
    // which would result in a predictable/duplicate output, if multiple such
    // requests appeared in the same block.
    nonces[_keyHash] = nonces[_keyHash].add(1);
    return makeRequestId(_keyHash, vRFSeed);
  }

  LinkTokenInterface internal LINK;
  address private vrfCoordinator;

  // Nonces for each VRF key from which randomness has been requested.
  //
  // Must stay in sync with VRFCoordinator[_keyHash][this]
  mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces;

  /**
   * @param _vrfCoordinator address of VRFCoordinator contract
   * @param _link address of LINK token contract
   *
   * @dev https://docs.chain.link/docs/link-token-contracts
   */
  constructor(address _vrfCoordinator, address _link) public {
    vrfCoordinator = _vrfCoordinator;
    LINK = LinkTokenInterface(_link);
  }

  // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
  // proof. rawFulfillRandomness then calls fulfillRandomness, after validating
  // the origin of the call
  function rawFulfillRandomness(bytes32 requestId, uint256 randomness) external {
    require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill");
    fulfillRandomness(requestId, randomness);
  }
}

interface ILotteryDao {
    enum Era {
        EXPANSION,
        NEUTRAL,
        DEBT
    }

    function treasury() external view returns (address);
    function dollar() external view returns (address);
    function era() external view returns (Era, uint256);
    function epoch() external view returns (uint256);

    function requestDAI(address recipient, uint256 amount) external;
}

interface ILottery {
    function newGame(uint256[] calldata prizes) external;
}

/**
 * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
 * the optional functions; to access them see {ERC20Detailed}.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract Lottery is ILottery, VRFConsumerBase {
    using SafeMathChainlink for uint256;

    struct Purchase {
        uint256 ticketStart;
        uint256 ticketEnd;
    }

    struct Game {
        uint256 issuedTickets;
        uint256 totalPurchases;
        bool winnersExtracted;
        bool ongoing;
        address[] winners;
        uint256[] winningTickets;
        uint256[] prizes;
        bool[] rewardsRedeemed;

        mapping(address => uint256[]) players;
        mapping(uint256 => Purchase) purchases;
    }
    
    struct LinkVRF {
        bytes32 keyHash;
        uint256 fee;
    }

    ILotteryDao public dao;

    LinkVRF private link;

    uint256 public gameLength;
    mapping(uint256 => Game) public games;

    constructor()
        VRFConsumerBase(
            0xf0d54349aDdcf704F77AE15b96510dEA15cb7952, // VRF Coordinator
            0x514910771AF9Ca656af840dff83E8264EcF986CA  // LINK Token
        ) public
    {
        dao = ILotteryDao(0x0aF9087FE3e8e834F3339FE4bEE87705e84Fd488);
        link.fee = 2e18;
        link.keyHash = 0xAA77729D3466CA35AE8D28B3BBAC7CC36A5031EFDC430821C02BC31A238AF445;
    }

    event GameStarted(uint256 indexed gameIndex, uint256[] prizes);
    event TicketsPurchase(address indexed sender, uint256 indexed purchaseId, uint256 indexed lotteryId, uint256 ticketStart, uint256 ticketEnd);
    event LotteryEnded(uint256 indexed lotteryId);
    event WinningTicketsSorted(uint256 indexed lotteryId, uint256[] winningTickets);
    event RewardRedeemed(address indexed recipient, uint256 indexed lotteryId, uint256 reward);

    modifier onlyDAO() {
        require(msg.sender == address(dao), "Lottery: sender isn't the DAO");
        _;
    }

    function gameIndex() public view returns (uint256) {
        return gameLength.sub(1);
    }

    function treasury() public view returns (address) {
        return dao.treasury();
    }

    function dollar() public view returns (IERC20) {
        return IERC20(dao.dollar());
    }

    function getWinners(uint256 gameIndex) external view returns(address[] memory) {
        return games[gameIndex].winners;
    }

    function getWinningTickets(uint256 gameIndex) external view returns(uint256[] memory) {
        return games[gameIndex].winningTickets;
    }

    function getPrizes(uint256 gameIndex) external view returns(uint256[] memory) {
        return games[gameIndex].prizes;
    }

    function getIssuedTickets(uint256 gameIndex) external view returns (uint256) {
        return games[gameIndex].issuedTickets;
    }

    function getRedeemedPrizes(uint256 gameIndex) external view returns(bool[] memory) {
        return games[gameIndex].rewardsRedeemed;
    }

    function isOngoing(uint256 gameIndex) external view returns(bool) {
        return games[gameIndex].ongoing;
    }

    function areWinnersExtracted(uint256 gameIndex) external view returns(bool) {
        return games[gameIndex].winnersExtracted;
    }

    function getTotalPurchases(uint256 gameIndex) external view returns(uint256) {
        return games[gameIndex].totalPurchases;
    }

    function getPlayerPurchaseIndexes(uint256 gameIndex, address player) external view returns(uint256[] memory) {
        return games[gameIndex].players[player];
    }

    function getPurchase(uint256 gameIndex, uint256 purchaseIndex) external view returns(uint256, uint256) {
        return (games[gameIndex].purchases[purchaseIndex].ticketStart, games[gameIndex].purchases[purchaseIndex].ticketEnd);
    }

    function newGame(uint256[] calldata prizes) external onlyDAO {   
        require(LINK.balanceOf(address(this)) >= link.fee, "Lottery: Insufficient link balance");

        if (gameLength > 0)
            require(games[gameIndex()].winnersExtracted, "Lottery: can't start a new lottery before the winner is extracted");

        games[gameLength].ongoing = true;
        games[gameLength].prizes = prizes;
        games[gameLength].winners = new address[](prizes.length);
        games[gameLength].rewardsRedeemed = new bool[](prizes.length);

        emit GameStarted(gameLength, prizes);

        gameLength++;
    }

    function changeChainlinkData(bytes32 keyHash, uint256 fee) external onlyDAO {
        link.keyHash = keyHash;
        link.fee = fee;
    }

    function purchaseTickets(uint256 amount) external {
        require(amount >= 10e18, "Lottery: Insufficient purchase amount");

        uint256 finalizedAmount = amount.sub(amount % 10e18);

        Game storage game = games[gameIndex()];

        require(game.ongoing, "Lottery: No ongoing game");

        dollar().transferFrom(msg.sender, treasury(), finalizedAmount);

        uint256 newTickets = finalizedAmount.div(10e18);

        Purchase memory purchase = Purchase(
            game.issuedTickets,
            game.issuedTickets.add(newTickets) - 1
        );

        game.players[msg.sender].push(game.totalPurchases);
        game.purchases[game.totalPurchases] = purchase;

        game.issuedTickets = game.issuedTickets.add(newTickets);

        emit TicketsPurchase(msg.sender, game.totalPurchases, gameIndex(), purchase.ticketStart, purchase.ticketEnd);

        game.totalPurchases += 1;
    }

    function extractWinner() external {
        Game storage game = games[gameIndex()];
        require(game.ongoing, "Lottery: winner already extracted");

        (ILotteryDao.Era era, uint256 start) = dao.era();
        require(era == ILotteryDao.Era.EXPANSION && dao.epoch() >= start + 3, "Lottery: Can only extract during expansion");

        game.ongoing = false;

        requestRandomness(link.keyHash, link.fee, uint256(keccak256(abi.encodePacked(block.number, block.difficulty, now))));

        emit LotteryEnded(gameIndex());
    }

    function redeemReward(uint256 gameIndex, uint256 purchaseIndex, uint256 winningTicket) external {
        Game storage game = games[gameIndex];

        require(game.winnersExtracted, "Lottery: winner hasn't been extracted yet");
        
        bool found;
        uint256 index;
        for (uint256 i = 0; i < game.winningTickets.length; i++) {
            if (winningTicket == game.winningTickets[i]) {
                found = true;
                index = i;
                break;
            }
        }

        require(found, "Lottery: winning ticket not found");
        require(!game.rewardsRedeemed[index], "Lottery: Reward already redeemed");

        game.rewardsRedeemed[index] = true;

        Purchase storage purchase = game.purchases[game.players[msg.sender][purchaseIndex]];

        require(purchase.ticketStart <= winningTicket && purchase.ticketEnd >= winningTicket, "Lottery: purchase doesn't contain the winning ticket");

        dao.requestDAI(msg.sender, game.prizes[index]);

        game.winners[index] = msg.sender;

        emit RewardRedeemed(msg.sender, gameIndex, game.prizes[index]);
    }

    /**
     * Callback function used by VRF Coordinator
     */
    function fulfillRandomness(bytes32 requestId, uint256 randomness) internal {
        Game storage game = games[gameIndex()];
        
        for (uint256 i = 0; i < game.prizes.length; i++) {
            game.winningTickets.push(uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty, randomness, game.prizes[i]))) % game.issuedTickets);
        }

        game.winnersExtracted = true;

        emit WinningTicketsSorted(gameIndex(), game.winningTickets);
    }

}

Contract Security Audit

Contract ABI

[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"gameIndex","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"prizes","type":"uint256[]"}],"name":"GameStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"}],"name":"LotteryEnded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardRedeemed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"uint256","name":"purchaseId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ticketStart","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ticketEnd","type":"uint256"}],"name":"TicketsPurchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"winningTickets","type":"uint256[]"}],"name":"WinningTicketsSorted","type":"event"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"}],"name":"areWinnersExtracted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"keyHash","type":"bytes32"},{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"changeChainlinkData","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"dao","outputs":[{"internalType":"contract ILotteryDao","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dollar","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"extractWinner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"gameIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"gameLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"games","outputs":[{"internalType":"uint256","name":"issuedTickets","type":"uint256"},{"internalType":"uint256","name":"totalPurchases","type":"uint256"},{"internalType":"bool","name":"winnersExtracted","type":"bool"},{"internalType":"bool","name":"ongoing","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"}],"name":"getIssuedTickets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"},{"internalType":"address","name":"player","type":"address"}],"name":"getPlayerPurchaseIndexes","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"}],"name":"getPrizes","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"},{"internalType":"uint256","name":"purchaseIndex","type":"uint256"}],"name":"getPurchase","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"}],"name":"getRedeemedPrizes","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"}],"name":"getTotalPurchases","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"}],"name":"getWinners","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"}],"name":"getWinningTickets","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"}],"name":"isOngoing","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256[]","name":"prizes","type":"uint256[]"}],"name":"newGame","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"purchaseTickets","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"requestId","type":"bytes32"},{"internalType":"uint256","name":"randomness","type":"uint256"}],"name":"rawFulfillRandomness","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"gameIndex","type":"uint256"},{"internalType":"uint256","name":"purchaseIndex","type":"uint256"},{"internalType":"uint256","name":"winningTicket","type":"uint256"}],"name":"redeemReward","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50600180546001600160a01b031990811673f0d54349addcf704f77ae15b96510dea15cb79521790915560008054821673514910771af9ca656af840dff83e8264ecf986ca17905560038054909116730af9087fe3e8e834f3339fe4bee87705e84fd488179055671bc16d674ec800006005557faa77729d3466ca35ae8d28b3bbac7cc36a5031efdc430821c02bc31a238af4456004556120b9806100b66000396000f3fe608060405234801561001057600080fd5b50600436106101825760003560e01c80636b1426a4116100d8578063a12776001161008c578063d219ab9311610066578063d219ab93146104ae578063d48b6519146104d1578063fbde5b64146104ee57610182565b8063a127760014610457578063b289790914610474578063cc3077951461049157610182565b806394985ddd116100bd57806394985ddd146103fa57806395ecc6421461041d5780639c1aa9061461043a57610182565b80636b1426a41461035457806387ac1738146103c157610182565b80634162169f1161013a5780635654a341116101145780635654a3411461031b578063603397011461032357806361d027b31461034c57610182565b80634162169f146102da57806351adeb571461030b578063559e051c1461031357610182565b80632d8309ce1161016b5780632d8309ce1461023e57806330af118f1461026f5780633bc701841461029e57610182565b8063117a5b901461018757806325c587ba146101cc575b600080fd5b6101a46004803603602081101561019d57600080fd5b50356104f6565b6040805194855260208501939093529015158383015215156060830152519081900360800190f35b61023c600480360360208110156101e257600080fd5b8101906020810181356401000000008111156101fd57600080fd5b82018360208201111561020f57600080fd5b8035906020019184602083028401116401000000008311171561023157600080fd5b509092509050610523565b005b61025b6004803603602081101561025457600080fd5b50356108b1565b604080519115158252519081900360200190f35b61028c6004803603602081101561028557600080fd5b50356108c9565b60408051918252519081900360200190f35b6102c1600480360360408110156102b457600080fd5b50803590602001356108de565b6040805192835260208301919091528051918290030190f35b6102e2610907565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6102e2610923565b61023c6109c0565b61028c610c94565b61023c6004803603606081101561033957600080fd5b5080359060208101359060400135610cb0565b6102e26110f2565b6103716004803603602081101561036a57600080fd5b503561115d565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103ad578181015183820152602001610395565b505050509050019250505060405180910390f35b610371600480360360408110156103d757600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff166111d9565b61023c6004803603604081101561041057600080fd5b508035906020013561125c565b61025b6004803603602081101561043357600080fd5b50356112f0565b6103716004803603602081101561045057600080fd5b503561130d565b61023c6004803603602081101561046d57600080fd5b5035611371565b61028c6004803603602081101561048a57600080fd5b5035611685565b610371600480360360208110156104a757600080fd5b5035611697565b61023c600480360360408110156104c457600080fd5b50803590602001356116fa565b610371600480360360208110156104e757600080fd5b503561178b565b61028c61180e565b60076020526000908152604090208054600182015460029092015490919060ff8082169161010090041684565b60035473ffffffffffffffffffffffffffffffffffffffff1633146105a957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4c6f74746572793a2073656e6465722069736e2774207468652044414f000000604482015290519081900360640190fd5b600554600054604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b15801561061d57600080fd5b505afa158015610631573d6000803e3d6000fd5b505050506040513d602081101561064757600080fd5b505110156106a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611fa06022913960400191505060405180910390fd5b6006541561072057600760006106b4610c94565b815260208101919091526040016000206002015460ff16610720576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260418152602001806120106041913960600191505060405180910390fd5b6006805460009081526007602052604080822060020180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790559154815220610773906005018383611d15565b5060408051828152602080840282010190915281801561079d578160200160208202803883390190505b5060076000600654815260200190815260200160002060030190805190602001906107c9929190611d60565b506040805182815260208084028201019091528180156107f3578160200160208202803883390190505b50600760006006548152602001908152602001600020600601908051906020019061081f929190611de6565b506006547f02ca28e00b0d423635119d8448efbdbf793112c49ef9146701594803621e4c60838360405180806020018281038252848482818152602001925060200280828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039550909350505050a25050600680546001019055565b60009081526007602052604090206002015460ff1690565b60009081526007602052604090206001015490565b600091825260076020908152604080842092845260089092019052902080546001909101549091565b60035473ffffffffffffffffffffffffffffffffffffffff1681565b600354604080517f51adeb57000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff16916351adeb57916004808301926020929190829003018186803b15801561098e57600080fd5b505afa1580156109a2573d6000803e3d6000fd5b505050506040513d60208110156109b857600080fd5b505190505b90565b6000600760006109ce610c94565b815260200190815260200160002090508060020160019054906101000a900460ff16610a45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611f7f6021913960400191505060405180910390fd5b600354604080517f143e55e00000000000000000000000000000000000000000000000000000000081528151600093849373ffffffffffffffffffffffffffffffffffffffff9091169263143e55e09260048083019392829003018186803b158015610ab057600080fd5b505afa158015610ac4573d6000803e3d6000fd5b505050506040513d6040811015610ada57600080fd5b50805160209091015190925090506000826002811115610af657fe5b148015610b99575080600301600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663900cf0cf6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6a57600080fd5b505afa158015610b7e573d6000803e3d6000fd5b505050506040513d6020811015610b9457600080fd5b505110155b610bee576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180611f55602a913960400191505060405180910390fd5b6002830180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905560045460055460408051436020808301919091524482840152426060808401919091528351808403909101815260809092019092528051910120610c5d929190611814565b50610c66610c94565b6040517fe28742282056724e602056f6aa9ca3b96df0f2aaced985aacac5b0a789a40a1d90600090a2505050565b600654600090610cab90600163ffffffff6119b116565b905090565b6000838152600760205260409020600281015460ff16610d1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180611fe76029913960400191505060405180910390fd5b600080805b6004840154811015610d6157836004018181548110610d3b57fe5b9060005260206000200154851415610d595760019250809150610d61565b600101610d20565b5081610db8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611f346021913960400191505060405180910390fd5b826006018181548110610dc757fe5b90600052602060002090602091828204019190069054906101000a900460ff1615610e5357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4c6f74746572793a2052657761726420616c72656164792072656465656d6564604482015290519081900360640190fd5b6001836006018281548110610e6457fe5b90600052602060002090602091828204019190066101000a81548160ff02191690831515021790555060008360080160008560070160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208881548110610ee157fe5b90600052602060002001548152602001908152602001600020905084816000015411158015610f14575084816001015410155b610f69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806120516034913960400191505060405180910390fd5b60035460058501805473ffffffffffffffffffffffffffffffffffffffff9092169163887f048591339186908110610f9d57fe5b90600052602060002001546040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561101157600080fd5b505af1158015611025573d6000803e3d6000fd5b505050503384600301838154811061103957fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550863373ffffffffffffffffffffffffffffffffffffffff167fc37465ff193f774057dca6e5213393c0be6539811e14d27361449666b618ecff8660050185815481106110c957fe5b90600052602060002001546040518082815260200191505060405180910390a350505050505050565b600354604080517f61d027b3000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff16916361d027b3916004808301926020929190829003018186803b15801561098e57600080fd5b6000818152600760209081526040918290206003018054835181840281018401909452808452606093928301828280156111cd57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111a2575b50505050509050919050565b600082815260076020818152604080842073ffffffffffffffffffffffffffffffffffffffff86168552909201815291819020805482518185028101850190935280835260609383018282801561124f57602002820191906000526020600020905b81548152602001906001019080831161123b575b5050505050905092915050565b60015473ffffffffffffffffffffffffffffffffffffffff1633146112e257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c00604482015290519081900360640190fd5b6112ec8282611a28565b5050565b600090815260076020526040902060020154610100900460ff1690565b6000818152600760209081526040918290206004018054835181840281018401909452808452606093928301828280156111cd57602002820191906000526020600020905b8154815260200190600101908083116113525750505050509050919050565b678ac7230489e800008110156113d2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611fc26025913960400191505060405180910390fd5b60006113e882678ac7230489e8000081066119b1565b90506000600760006113f8610c94565b815260200190815260200160002090508060020160019054906101000a900460ff1661148557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c6f74746572793a204e6f206f6e676f696e672067616d650000000000000000604482015290519081900360640190fd5b61148d610923565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd336114b16110f2565b856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561154e57600080fd5b505af1158015611562573d6000803e3d6000fd5b505050506040513d602081101561157857600080fd5b506000905061159583678ac7230489e8000063ffffffff611b9616565b905061159f611e87565b60408051808201909152835480825260208201906001906115c6908663ffffffff611c1a16565b039052336000908152600785016020908152604080832060018089018054835480840185559387528587209093019290925590548452600888018352922083518155908301519101558354909150611624908363ffffffff611c1a16565b835561162e610c94565b600184015482516020808501516040805193845291830152805133927fe25b826e385a21bf44519825fa8153950e87a186aceff90a03a8661244e6a91e92908290030190a450506001908101805490910190555050565b60009081526007602052604090205490565b6000818152600760209081526040918290206005018054835181840281018401909452808452606093928301828280156111cd57602002820191906000526020600020908154815260200190600101908083116113525750505050509050919050565b60035473ffffffffffffffffffffffffffffffffffffffff16331461178057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4c6f74746572793a2073656e6465722069736e2774207468652044414f000000604482015290519081900360640190fd5b600491909155600555565b6000818152600760209081526040918290206006018054835181840281018401909452808452606093928301828280156111cd57602002820191906000526020600020906000905b825461010083900a900460ff1615158152602060019283018181049485019490930390920291018084116117d3575094979650505050505050565b60065481565b600080546001546040805160208082018990528183018790528251808303840181526060808401948590527f4000aea00000000000000000000000000000000000000000000000000000000090945273ffffffffffffffffffffffffffffffffffffffff94851660648401818152608485018b905260a48501958652825160c486015282519690971696634000aea09691958b9593949193909260e4909101918501908083838d5b838110156118d45781810151838201526020016118bc565b50505050905090810190601f1680156119015780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b15801561192257600080fd5b505af1158015611936573d6000803e3d6000fd5b505050506040513d602081101561194c57600080fd5b505060008481526002602052604081205461196c90869085903090611c95565b60008681526002602052604090205490915061198f90600163ffffffff611c1a16565b6000868152600260205260409020556119a88582611ce9565b95945050505050565b600082821115611a2257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600060076000611a36610c94565b8152602001908152602001600020905060008090505b6005820154811015611ae357816004018260000154424486866005018681548110611a7357fe5b9060005260206000200154604051602001808581526020018481526020018381526020018281526020019450505050506040516020818303038152906040528051906020012060001c81611ac357fe5b825460018181018555600094855260209094209290910691015501611a4c565b506002810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055611b19610c94565b7f67560e56104b874db7f297ada01f454fb5f0b88aa913609c1683b918113943ef8260040160405180806020018281038252838181548152602001915080548015611b8357602002820191906000526020600020905b815481526020019060010190808311611b6f575b50509250505060405180910390a2505050565b6000808211611c0657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481611c1157fe5b04949350505050565b600082820183811015611c8e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b604080516020808201969096528082019490945273ffffffffffffffffffffffffffffffffffffffff9290921660608401526080808401919091528151808403909101815260a09092019052805191012090565b604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b828054828255906000526020600020908101928215611d50579160200282015b82811115611d50578235825591602001919060010190611d35565b50611d5c929150611ea1565b5090565b828054828255906000526020600020908101928215611dda579160200282015b82811115611dda57825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909116178255602090920191600190910190611d80565b50611d5c929150611ebb565b82805482825590600052602060002090601f01602090048101928215611e7b5791602002820160005b83821115611e4c57835183826101000a81548160ff0219169083151502179055509260200192600101602081600001049283019260010302611e0f565b8015611e795782816101000a81549060ff0219169055600101602081600001049283019260010302611e4c565b505b50611d5c929150611ef7565b604051806040016040528060008152602001600081525090565b6109bd91905b80821115611d5c5760008155600101611ea7565b6109bd91905b80821115611d5c5780547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155600101611ec1565b6109bd91905b80821115611d5c5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168155600101611efd56fe4c6f74746572793a2077696e6e696e67207469636b6574206e6f7420666f756e644c6f74746572793a2043616e206f6e6c79206578747261637420647572696e6720657870616e73696f6e4c6f74746572793a2077696e6e657220616c7265616479206578747261637465644c6f74746572793a20496e73756666696369656e74206c696e6b2062616c616e63654c6f74746572793a20496e73756666696369656e7420707572636861736520616d6f756e744c6f74746572793a2077696e6e6572206861736e2774206265656e20657874726163746564207965744c6f74746572793a2063616e27742073746172742061206e6577206c6f7474657279206265666f7265207468652077696e6e6572206973206578747261637465644c6f74746572793a20707572636861736520646f65736e277420636f6e7461696e207468652077696e6e696e67207469636b6574a265627a7a723158201119f3f65366f45b32aa08de17a7876238dcbc196018d3976d488f6c174a074b64736f6c63430005110032

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101825760003560e01c80636b1426a4116100d8578063a12776001161008c578063d219ab9311610066578063d219ab93146104ae578063d48b6519146104d1578063fbde5b64146104ee57610182565b8063a127760014610457578063b289790914610474578063cc3077951461049157610182565b806394985ddd116100bd57806394985ddd146103fa57806395ecc6421461041d5780639c1aa9061461043a57610182565b80636b1426a41461035457806387ac1738146103c157610182565b80634162169f1161013a5780635654a341116101145780635654a3411461031b578063603397011461032357806361d027b31461034c57610182565b80634162169f146102da57806351adeb571461030b578063559e051c1461031357610182565b80632d8309ce1161016b5780632d8309ce1461023e57806330af118f1461026f5780633bc701841461029e57610182565b8063117a5b901461018757806325c587ba146101cc575b600080fd5b6101a46004803603602081101561019d57600080fd5b50356104f6565b6040805194855260208501939093529015158383015215156060830152519081900360800190f35b61023c600480360360208110156101e257600080fd5b8101906020810181356401000000008111156101fd57600080fd5b82018360208201111561020f57600080fd5b8035906020019184602083028401116401000000008311171561023157600080fd5b509092509050610523565b005b61025b6004803603602081101561025457600080fd5b50356108b1565b604080519115158252519081900360200190f35b61028c6004803603602081101561028557600080fd5b50356108c9565b60408051918252519081900360200190f35b6102c1600480360360408110156102b457600080fd5b50803590602001356108de565b6040805192835260208301919091528051918290030190f35b6102e2610907565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b6102e2610923565b61023c6109c0565b61028c610c94565b61023c6004803603606081101561033957600080fd5b5080359060208101359060400135610cb0565b6102e26110f2565b6103716004803603602081101561036a57600080fd5b503561115d565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156103ad578181015183820152602001610395565b505050509050019250505060405180910390f35b610371600480360360408110156103d757600080fd5b508035906020013573ffffffffffffffffffffffffffffffffffffffff166111d9565b61023c6004803603604081101561041057600080fd5b508035906020013561125c565b61025b6004803603602081101561043357600080fd5b50356112f0565b6103716004803603602081101561045057600080fd5b503561130d565b61023c6004803603602081101561046d57600080fd5b5035611371565b61028c6004803603602081101561048a57600080fd5b5035611685565b610371600480360360208110156104a757600080fd5b5035611697565b61023c600480360360408110156104c457600080fd5b50803590602001356116fa565b610371600480360360208110156104e757600080fd5b503561178b565b61028c61180e565b60076020526000908152604090208054600182015460029092015490919060ff8082169161010090041684565b60035473ffffffffffffffffffffffffffffffffffffffff1633146105a957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4c6f74746572793a2073656e6465722069736e2774207468652044414f000000604482015290519081900360640190fd5b600554600054604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b15801561061d57600080fd5b505afa158015610631573d6000803e3d6000fd5b505050506040513d602081101561064757600080fd5b505110156106a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526022815260200180611fa06022913960400191505060405180910390fd5b6006541561072057600760006106b4610c94565b815260208101919091526040016000206002015460ff16610720576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260418152602001806120106041913960600191505060405180910390fd5b6006805460009081526007602052604080822060020180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790559154815220610773906005018383611d15565b5060408051828152602080840282010190915281801561079d578160200160208202803883390190505b5060076000600654815260200190815260200160002060030190805190602001906107c9929190611d60565b506040805182815260208084028201019091528180156107f3578160200160208202803883390190505b50600760006006548152602001908152602001600020600601908051906020019061081f929190611de6565b506006547f02ca28e00b0d423635119d8448efbdbf793112c49ef9146701594803621e4c60838360405180806020018281038252848482818152602001925060200280828437600083820152604051601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018290039550909350505050a25050600680546001019055565b60009081526007602052604090206002015460ff1690565b60009081526007602052604090206001015490565b600091825260076020908152604080842092845260089092019052902080546001909101549091565b60035473ffffffffffffffffffffffffffffffffffffffff1681565b600354604080517f51adeb57000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff16916351adeb57916004808301926020929190829003018186803b15801561098e57600080fd5b505afa1580156109a2573d6000803e3d6000fd5b505050506040513d60208110156109b857600080fd5b505190505b90565b6000600760006109ce610c94565b815260200190815260200160002090508060020160019054906101000a900460ff16610a45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611f7f6021913960400191505060405180910390fd5b600354604080517f143e55e00000000000000000000000000000000000000000000000000000000081528151600093849373ffffffffffffffffffffffffffffffffffffffff9091169263143e55e09260048083019392829003018186803b158015610ab057600080fd5b505afa158015610ac4573d6000803e3d6000fd5b505050506040513d6040811015610ada57600080fd5b50805160209091015190925090506000826002811115610af657fe5b148015610b99575080600301600360009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663900cf0cf6040518163ffffffff1660e01b815260040160206040518083038186803b158015610b6a57600080fd5b505afa158015610b7e573d6000803e3d6000fd5b505050506040513d6020811015610b9457600080fd5b505110155b610bee576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180611f55602a913960400191505060405180910390fd5b6002830180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16905560045460055460408051436020808301919091524482840152426060808401919091528351808403909101815260809092019092528051910120610c5d929190611814565b50610c66610c94565b6040517fe28742282056724e602056f6aa9ca3b96df0f2aaced985aacac5b0a789a40a1d90600090a2505050565b600654600090610cab90600163ffffffff6119b116565b905090565b6000838152600760205260409020600281015460ff16610d1b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526029815260200180611fe76029913960400191505060405180910390fd5b600080805b6004840154811015610d6157836004018181548110610d3b57fe5b9060005260206000200154851415610d595760019250809150610d61565b600101610d20565b5081610db8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180611f346021913960400191505060405180910390fd5b826006018181548110610dc757fe5b90600052602060002090602091828204019190069054906101000a900460ff1615610e5357604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4c6f74746572793a2052657761726420616c72656164792072656465656d6564604482015290519081900360640190fd5b6001836006018281548110610e6457fe5b90600052602060002090602091828204019190066101000a81548160ff02191690831515021790555060008360080160008560070160003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208881548110610ee157fe5b90600052602060002001548152602001908152602001600020905084816000015411158015610f14575084816001015410155b610f69576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260348152602001806120516034913960400191505060405180910390fd5b60035460058501805473ffffffffffffffffffffffffffffffffffffffff9092169163887f048591339186908110610f9d57fe5b90600052602060002001546040518363ffffffff1660e01b8152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050600060405180830381600087803b15801561101157600080fd5b505af1158015611025573d6000803e3d6000fd5b505050503384600301838154811061103957fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550863373ffffffffffffffffffffffffffffffffffffffff167fc37465ff193f774057dca6e5213393c0be6539811e14d27361449666b618ecff8660050185815481106110c957fe5b90600052602060002001546040518082815260200191505060405180910390a350505050505050565b600354604080517f61d027b3000000000000000000000000000000000000000000000000000000008152905160009273ffffffffffffffffffffffffffffffffffffffff16916361d027b3916004808301926020929190829003018186803b15801561098e57600080fd5b6000818152600760209081526040918290206003018054835181840281018401909452808452606093928301828280156111cd57602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff1681526001909101906020018083116111a2575b50505050509050919050565b600082815260076020818152604080842073ffffffffffffffffffffffffffffffffffffffff86168552909201815291819020805482518185028101850190935280835260609383018282801561124f57602002820191906000526020600020905b81548152602001906001019080831161123b575b5050505050905092915050565b60015473ffffffffffffffffffffffffffffffffffffffff1633146112e257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c00604482015290519081900360640190fd5b6112ec8282611a28565b5050565b600090815260076020526040902060020154610100900460ff1690565b6000818152600760209081526040918290206004018054835181840281018401909452808452606093928301828280156111cd57602002820191906000526020600020905b8154815260200190600101908083116113525750505050509050919050565b678ac7230489e800008110156113d2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180611fc26025913960400191505060405180910390fd5b60006113e882678ac7230489e8000081066119b1565b90506000600760006113f8610c94565b815260200190815260200160002090508060020160019054906101000a900460ff1661148557604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4c6f74746572793a204e6f206f6e676f696e672067616d650000000000000000604482015290519081900360640190fd5b61148d610923565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd336114b16110f2565b856040518463ffffffff1660e01b8152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050602060405180830381600087803b15801561154e57600080fd5b505af1158015611562573d6000803e3d6000fd5b505050506040513d602081101561157857600080fd5b506000905061159583678ac7230489e8000063ffffffff611b9616565b905061159f611e87565b60408051808201909152835480825260208201906001906115c6908663ffffffff611c1a16565b039052336000908152600785016020908152604080832060018089018054835480840185559387528587209093019290925590548452600888018352922083518155908301519101558354909150611624908363ffffffff611c1a16565b835561162e610c94565b600184015482516020808501516040805193845291830152805133927fe25b826e385a21bf44519825fa8153950e87a186aceff90a03a8661244e6a91e92908290030190a450506001908101805490910190555050565b60009081526007602052604090205490565b6000818152600760209081526040918290206005018054835181840281018401909452808452606093928301828280156111cd57602002820191906000526020600020908154815260200190600101908083116113525750505050509050919050565b60035473ffffffffffffffffffffffffffffffffffffffff16331461178057604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f4c6f74746572793a2073656e6465722069736e2774207468652044414f000000604482015290519081900360640190fd5b600491909155600555565b6000818152600760209081526040918290206006018054835181840281018401909452808452606093928301828280156111cd57602002820191906000526020600020906000905b825461010083900a900460ff1615158152602060019283018181049485019490930390920291018084116117d3575094979650505050505050565b60065481565b600080546001546040805160208082018990528183018790528251808303840181526060808401948590527f4000aea00000000000000000000000000000000000000000000000000000000090945273ffffffffffffffffffffffffffffffffffffffff94851660648401818152608485018b905260a48501958652825160c486015282519690971696634000aea09691958b9593949193909260e4909101918501908083838d5b838110156118d45781810151838201526020016118bc565b50505050905090810190601f1680156119015780820380516001836020036101000a031916815260200191505b50945050505050602060405180830381600087803b15801561192257600080fd5b505af1158015611936573d6000803e3d6000fd5b505050506040513d602081101561194c57600080fd5b505060008481526002602052604081205461196c90869085903090611c95565b60008681526002602052604090205490915061198f90600163ffffffff611c1a16565b6000868152600260205260409020556119a88582611ce9565b95945050505050565b600082821115611a2257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600060076000611a36610c94565b8152602001908152602001600020905060008090505b6005820154811015611ae357816004018260000154424486866005018681548110611a7357fe5b9060005260206000200154604051602001808581526020018481526020018381526020018281526020019450505050506040516020818303038152906040528051906020012060001c81611ac357fe5b825460018181018555600094855260209094209290910691015501611a4c565b506002810180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055611b19610c94565b7f67560e56104b874db7f297ada01f454fb5f0b88aa913609c1683b918113943ef8260040160405180806020018281038252838181548152602001915080548015611b8357602002820191906000526020600020905b815481526020019060010190808311611b6f575b50509250505060405180910390a2505050565b6000808211611c0657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b6000828481611c1157fe5b04949350505050565b600082820183811015611c8e57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b604080516020808201969096528082019490945273ffffffffffffffffffffffffffffffffffffffff9290921660608401526080808401919091528151808403909101815260a09092019052805191012090565b604080516020808201949094528082019290925280518083038201815260609092019052805191012090565b828054828255906000526020600020908101928215611d50579160200282015b82811115611d50578235825591602001919060010190611d35565b50611d5c929150611ea1565b5090565b828054828255906000526020600020908101928215611dda579160200282015b82811115611dda57825182547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909116178255602090920191600190910190611d80565b50611d5c929150611ebb565b82805482825590600052602060002090601f01602090048101928215611e7b5791602002820160005b83821115611e4c57835183826101000a81548160ff0219169083151502179055509260200192600101602081600001049283019260010302611e0f565b8015611e795782816101000a81549060ff0219169055600101602081600001049283019260010302611e4c565b505b50611d5c929150611ef7565b604051806040016040528060008152602001600081525090565b6109bd91905b80821115611d5c5760008155600101611ea7565b6109bd91905b80821115611d5c5780547fffffffffffffffffffffffff0000000000000000000000000000000000000000168155600101611ec1565b6109bd91905b80821115611d5c5780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00168155600101611efd56fe4c6f74746572793a2077696e6e696e67207469636b6574206e6f7420666f756e644c6f74746572793a2043616e206f6e6c79206578747261637420647572696e6720657870616e73696f6e4c6f74746572793a2077696e6e657220616c7265616479206578747261637465644c6f74746572793a20496e73756666696369656e74206c696e6b2062616c616e63654c6f74746572793a20496e73756666696369656e7420707572636861736520616d6f756e744c6f74746572793a2077696e6e6572206861736e2774206265656e20657874726163746564207965744c6f74746572793a2063616e27742073746172742061206e6577206c6f7474657279206265666f7265207468652077696e6e6572206973206578747261637465644c6f74746572793a20707572636861736520646f65736e277420636f6e7461696e207468652077696e6e696e67207469636b6574a265627a7a723158201119f3f65366f45b32aa08de17a7876238dcbc196018d3976d488f6c174a074b64736f6c63430005110032

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.