Contract 0xe4cdc7DDF475953018280e9A325e480FdB77D25C 1

 
Ad
Ad
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x390682613543bb3995abd0b387584edf04154a0d8936b689a60f52ca76a2a289Draw Final Numbe...202046622021-10-14 9:18:461 day 23 hrs ago0x1d1d854650956c6f67ab27e474a02f2be342c0e1 IN  0xe4cdc7ddf475953018280e9a325e480fdb77d25c0 MATIC0.00498465
0xba4a9e04ed7fd62672a28b9d3aa8e805e19ce2d020fbd461694909cee2e7d78fClose Lottery202046482021-10-14 9:18:181 day 23 hrs ago0x1d1d854650956c6f67ab27e474a02f2be342c0e1 IN  0xe4cdc7ddf475953018280e9a325e480fdb77d25c0 MATIC0.00452052
0x7d16c0c9096e3c64b10bb3e119395771a38f6e1618cccaf7674c9876ae0c69f5Transfer Ownersh...201828482021-10-13 18:47:082 days 13 hrs ago0x1d1d854650956c6f67ab27e474a02f2be342c0e1 IN  0xe4cdc7ddf475953018280e9a325e480fdb77d25c0 MATIC0.00086028
0x29093ee0134ad56ff3ae591d0ac906b0783ed49a3e633f6ed8e417b703fcb240Start Lottery201826672021-10-13 18:40:542 days 13 hrs ago0x1d1d854650956c6f67ab27e474a02f2be342c0e1 IN  0xe4cdc7ddf475953018280e9a325e480fdb77d25c0 MATIC0.011982003
0x96eaa28de15f8a577e384f689e5e4687f33332e8419dc63f7a8b39585b26d574Set Operator And...201826572021-10-13 18:40:342 days 13 hrs ago0x1d1d854650956c6f67ab27e474a02f2be342c0e1 IN  0xe4cdc7ddf475953018280e9a325e480fdb77d25c0 MATIC0.003071079
0x9e772744f56b0359adbebe1227da11c110c002062321c030bbebd1e61229738c0x60806040201824262021-10-13 18:32:362 days 13 hrs ago0x1d1d854650956c6f67ab27e474a02f2be342c0e1 IN  Contract Creation0 MATIC0.116639886
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
JavaSwapLottery

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 9 : JavaSwapLottery.sol
// SPDX-License-Identifier: MIT

import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import './interfaces/IRandomNumberGenerator.sol';
import './interfaces/IJavaSwapLottery.sol';

pragma solidity ^0.8.4;
pragma abicoder v2;

/** @title JavaSwap Lottery.
 * @notice It is a contract for a lottery system using
 * randomness provided externally.
 */
contract JavaSwapLottery is ReentrancyGuard, IJavaSwapLottery, Ownable {
    using SafeERC20 for IERC20;

    address public injectorAddress;
    address public operatorAddress;
    address public treasuryAddress;

    uint256 public currentLotteryId;
    uint256 public currentTicketId;

    uint256 public maxNumberTicketsPerBuyOrClaim = 100;

    uint256 public maxPriceTicketInJava = 50 ether;
    uint256 public minPriceTicketInJava = 0.005 ether;

    uint256 public pendingInjectionNextLottery;

    uint256 public constant MIN_DISCOUNT_DIVISOR = 300;
    uint256 public constant MIN_LENGTH_LOTTERY = 4 hours - 5 minutes; // 4 hours
    uint256 public constant MAX_LENGTH_LOTTERY = 4 days + 5 minutes; // 4 days
    uint256 public constant MAX_TREASURY_FEE = 3000; // 30%

    IERC20 public javaToken;
    IRandomNumberGenerator public randomGenerator;

    enum Status {
        Pending,
        Open,
        Close,
        Claimable
    }

    struct Lottery {
        Status status;
        uint256 startTime;
        uint256 endTime;
        uint256 priceTicketInJava;
        uint256 discountDivisor;
        uint256[6] rewardsBreakdown; // 0: 1 matching number // 5: 6 matching numbers
        uint256 treasuryFee; // 500: 5% // 200: 2% // 50: 0.5%
        uint256[6] javaPerBracket;
        uint256[6] countWinnersPerBracket;
        uint256 firstTicketId;
        uint256 firstTicketIdNextLottery;
        uint256 amountCollectedInJava;
        uint32 finalNumber;
    }

    struct Ticket {
        uint32 number;
        address owner;
    }

    // Mapping are cheaper than arrays
    mapping(uint256 => Lottery) private _lotteries;
    mapping(uint256 => Ticket) private _tickets;

    // Bracket calculator is used for verifying claims for ticket prizes
    mapping(uint32 => uint32) private _bracketCalculator;

    // Keeps track of number of ticket per unique combination for each lotteryId
    mapping(uint256 => mapping(uint32 => uint256)) private _numberTicketsPerLotteryId;

    // Keep track of user ticket ids for a given lotteryId
    mapping(address => mapping(uint256 => uint256[])) private _userTicketIdsPerLotteryId;

    modifier notContract() {
        require(!_isContract(msg.sender), "Contract not allowed");
        require(msg.sender == tx.origin, "Proxy contract not allowed");
        _;
    }

    modifier onlyOperator() {
        require(msg.sender == operatorAddress, "Not operator");
        _;
    }

    modifier onlyOwnerOrInjector() {
        require((msg.sender == owner()) || (msg.sender == injectorAddress), "Not owner or injector");
        _;
    }

    event AdminTokenRecovery(address token, uint256 amount);
    event LotteryClose(uint256 indexed lotteryId, uint256 firstTicketIdNextLottery);
    event LotteryInjection(uint256 indexed lotteryId, uint256 injectedAmount);
    event LotteryOpen(
        uint256 indexed lotteryId,
        uint256 startTime,
        uint256 endTime,
        uint256 priceTicketInJava,
        uint256 firstTicketId,
        uint256 injectedAmount
    );
    event LotteryNumberDrawn(uint256 indexed lotteryId, uint256 finalNumber, uint256 countWinningTickets);
    event NewOperatorAndTreasuryAndInjectorAddresses(address operator, address treasury, address injector);
    event NewRandomGenerator(address indexed randomGenerator);
    event TicketsPurchase(address indexed buyer, uint256 indexed lotteryId, uint256 numberTickets);
    event TicketsClaim(address indexed claimer, uint256 amount, uint256 indexed lotteryId, uint256 numberTickets);

    /**
     * @notice Constructor
     * @dev RandomNumberGenerator must be deployed prior to this contract
     * @param _javaTokenAddress: address of the JAVA token
     * @param _randomGeneratorAddress: address of the RandomGenerator contract used to work with ChainLink VRF
     */
    constructor(address _javaTokenAddress, address _randomGeneratorAddress) {
        javaToken = IERC20(_javaTokenAddress);
        randomGenerator = IRandomNumberGenerator(_randomGeneratorAddress);

        // Initializes a mapping
        _bracketCalculator[0] = 1;
        _bracketCalculator[1] = 11;
        _bracketCalculator[2] = 111;
        _bracketCalculator[3] = 1111;
        _bracketCalculator[4] = 11111;
        _bracketCalculator[5] = 111111;
    }

    /**
     * @notice Buy tickets for the current lottery
     * @param _lotteryId: lotteryId
     * @param _ticketNumbers: array of ticket numbers between 1,000,000 and 1,999,999
     * @dev Callable by users
     */
    function buyTickets(uint256 _lotteryId, uint32[] calldata _ticketNumbers)
        external
        override
        notContract
        nonReentrant
    {
        require(_ticketNumbers.length != 0, "No ticket specified");
        require(_ticketNumbers.length <= maxNumberTicketsPerBuyOrClaim, "Too many tickets");

        require(_lotteries[_lotteryId].status == Status.Open, "Lottery is not open");
        require(block.timestamp < _lotteries[_lotteryId].endTime, "Lottery is over");

        // Calculate number of JAVA to this contract
        uint256 amountJavaToTransfer = _calculateTotalPriceForBulkTickets(
            _lotteries[_lotteryId].discountDivisor,
            _lotteries[_lotteryId].priceTicketInJava,
            _ticketNumbers.length
        );

        // Transfer java tokens to this contract
        javaToken.safeTransferFrom(address(msg.sender), address(this), amountJavaToTransfer);

        // Increment the total amount collected for the lottery round
        _lotteries[_lotteryId].amountCollectedInJava += amountJavaToTransfer;

        for (uint256 i = 0; i < _ticketNumbers.length; i++) {
            uint32 thisTicketNumber = _ticketNumbers[i];

            require((thisTicketNumber >= 1000000) && (thisTicketNumber <= 1999999), "Outside range");

            _numberTicketsPerLotteryId[_lotteryId][1 + (thisTicketNumber % 10)]++;
            _numberTicketsPerLotteryId[_lotteryId][11 + (thisTicketNumber % 100)]++;
            _numberTicketsPerLotteryId[_lotteryId][111 + (thisTicketNumber % 1000)]++;
            _numberTicketsPerLotteryId[_lotteryId][1111 + (thisTicketNumber % 10000)]++;
            _numberTicketsPerLotteryId[_lotteryId][11111 + (thisTicketNumber % 100000)]++;
            _numberTicketsPerLotteryId[_lotteryId][111111 + (thisTicketNumber % 1000000)]++;

            _userTicketIdsPerLotteryId[msg.sender][_lotteryId].push(currentTicketId);

            _tickets[currentTicketId] = Ticket({number: thisTicketNumber, owner: msg.sender});

            // Increase lottery ticket number
            currentTicketId++;
        }

        emit TicketsPurchase(msg.sender, _lotteryId, _ticketNumbers.length);
    }

    /**
     * @notice Claim a set of winning tickets for a lottery
     * @param _lotteryId: lottery id
     * @param _ticketIds: array of ticket ids
     * @param _brackets: array of brackets for the ticket ids
     * @dev Callable by users only, not contract!
     */
    function claimTickets(
        uint256 _lotteryId,
        uint256[] calldata _ticketIds,
        uint32[] calldata _brackets
    ) external override notContract nonReentrant {
        require(_ticketIds.length == _brackets.length, "Not same length");
        require(_ticketIds.length != 0, "Length must be >0");
        require(_ticketIds.length <= maxNumberTicketsPerBuyOrClaim, "Too many tickets");
        require(_lotteries[_lotteryId].status == Status.Claimable, "Lottery not claimable");

        // Initializes the rewardInJavaToTransfer
        uint256 rewardInJavaToTransfer;

        for (uint256 i = 0; i < _ticketIds.length; i++) {
            require(_brackets[i] < 6, "Bracket out of range"); // Must be between 0 and 5

            uint256 thisTicketId = _ticketIds[i];

            require(_lotteries[_lotteryId].firstTicketIdNextLottery > thisTicketId, "TicketId too high");
            require(_lotteries[_lotteryId].firstTicketId <= thisTicketId, "TicketId too low");
            require(msg.sender == _tickets[thisTicketId].owner, "Not the owner");

            // Update the lottery ticket owner to 0x address
            _tickets[thisTicketId].owner = address(0);

            uint256 rewardForTicketId = _calculateRewardsForTicketId(_lotteryId, thisTicketId, _brackets[i]);

            // Check user is claiming the correct bracket
            require(rewardForTicketId != 0, "No prize for this bracket");

            if (_brackets[i] != 5) {
                require(
                    _calculateRewardsForTicketId(_lotteryId, thisTicketId, _brackets[i] + 1) == 0,
                    "Bracket must be higher"
                );
            }

            // Increment the reward to transfer
            rewardInJavaToTransfer += rewardForTicketId;
        }

        // Transfer money to msg.sender
        javaToken.safeTransfer(msg.sender, rewardInJavaToTransfer);

        emit TicketsClaim(msg.sender, rewardInJavaToTransfer, _lotteryId, _ticketIds.length);
    }

    /**
     * @notice Close lottery
     * @param _lotteryId: lottery id
     * @dev Callable by operator
     */
    function closeLottery(uint256 _lotteryId) external override onlyOperator nonReentrant {
        require(_lotteries[_lotteryId].status == Status.Open, "Lottery not open");
        require(block.timestamp > _lotteries[_lotteryId].endTime, "Lottery not over");
        _lotteries[_lotteryId].firstTicketIdNextLottery = currentTicketId;

        // Request a random number from the generator based on a seed
        randomGenerator.getRandomNumber(uint256(keccak256(abi.encodePacked(_lotteryId, currentTicketId))));

        _lotteries[_lotteryId].status = Status.Close;

        emit LotteryClose(_lotteryId, currentTicketId);
    }

    /**
     * @notice Draw the final number, calculate reward in JAVA per group, and make lottery claimable
     * @param _lotteryId: lottery id
     * @param _autoInjection: reinjects funds into next lottery (vs. withdrawing all)
     * @dev Callable by operator
     */
    function drawFinalNumberAndMakeLotteryClaimable(uint256 _lotteryId, bool _autoInjection)
        external
        override
        onlyOperator
        nonReentrant
    {
        require(_lotteries[_lotteryId].status == Status.Close, "Lottery not close");
        require(_lotteryId == randomGenerator.viewLatestLotteryId(), "Numbers not drawn");

        // Calculate the finalNumber based on the randomResult generated by ChainLink's fallback
        uint32 finalNumber = randomGenerator.viewRandomResult();

        // Initialize a number to count addresses in the previous bracket
        uint256 numberAddressesInPreviousBracket;

        // Calculate the amount to share post-treasury fee
        uint256 amountToShareToWinners = (
            ((_lotteries[_lotteryId].amountCollectedInJava) * (10000 - _lotteries[_lotteryId].treasuryFee))
        ) / 10000;

        // Initializes the amount to withdraw to treasury
        uint256 amountToWithdrawToTreasury;

        // Calculate prizes in JAVA for each bracket by starting from the highest one
        for (uint32 i = 0; i < 6; i++) {
            uint32 j = 5 - i;
            uint32 transformedWinningNumber = _bracketCalculator[j] + (finalNumber % (uint32(10)**(j + 1)));

            _lotteries[_lotteryId].countWinnersPerBracket[j] =
                _numberTicketsPerLotteryId[_lotteryId][transformedWinningNumber] -
                numberAddressesInPreviousBracket;

            // A. If number of users for this _bracket number is superior to 0
            if (
                (_numberTicketsPerLotteryId[_lotteryId][transformedWinningNumber] - numberAddressesInPreviousBracket) !=
                0
            ) {
                // B. If rewards at this bracket are > 0, calculate, else, report the numberAddresses from previous bracket
                if (_lotteries[_lotteryId].rewardsBreakdown[j] != 0) {
                    _lotteries[_lotteryId].javaPerBracket[j] =
                        ((_lotteries[_lotteryId].rewardsBreakdown[j] * amountToShareToWinners) /
                            (_numberTicketsPerLotteryId[_lotteryId][transformedWinningNumber] -
                                numberAddressesInPreviousBracket)) /
                        10000;

                    // Update numberAddressesInPreviousBracket
                    numberAddressesInPreviousBracket = _numberTicketsPerLotteryId[_lotteryId][transformedWinningNumber];
                }
                // A. No JAVA to distribute, they are added to the amount to withdraw to treasury address
            } else {
                _lotteries[_lotteryId].javaPerBracket[j] = 0;

                amountToWithdrawToTreasury +=
                    (_lotteries[_lotteryId].rewardsBreakdown[j] * amountToShareToWinners) /
                    10000;
            }
        }

        // Update internal statuses for lottery
        _lotteries[_lotteryId].finalNumber = finalNumber;
        _lotteries[_lotteryId].status = Status.Claimable;

        if (_autoInjection) {
            pendingInjectionNextLottery = amountToWithdrawToTreasury;
            amountToWithdrawToTreasury = 0;
        }

        amountToWithdrawToTreasury += (_lotteries[_lotteryId].amountCollectedInJava - amountToShareToWinners);

        // Transfer JAVA to treasury address
        javaToken.safeTransfer(treasuryAddress, amountToWithdrawToTreasury);

        emit LotteryNumberDrawn(currentLotteryId, finalNumber, numberAddressesInPreviousBracket);
    }

    /**
     * @notice Change the random generator
     * @dev The calls to functions are used to verify the new generator implements them properly.
     * It is necessary to wait for the VRF response before starting a round.
     * Callable only by the contract owner
     * @param _randomGeneratorAddress: address of the random generator
     */
    function changeRandomGenerator(address _randomGeneratorAddress) external onlyOwner {
        require(_lotteries[currentLotteryId].status == Status.Claimable, "Lottery not in claimable");

        // Request a random number from the generator based on a seed
        IRandomNumberGenerator(_randomGeneratorAddress).getRandomNumber(
            uint256(keccak256(abi.encodePacked(currentLotteryId, currentTicketId)))
        );

        // Calculate the finalNumber based on the randomResult generated by ChainLink's fallback
        IRandomNumberGenerator(_randomGeneratorAddress).viewRandomResult();

        randomGenerator = IRandomNumberGenerator(_randomGeneratorAddress);

        emit NewRandomGenerator(_randomGeneratorAddress);
    }

    /**
     * @notice Inject funds
     * @param _lotteryId: lottery id
     * @param _amount: amount to inject in JAVA token
     * @dev Callable by owner or injector address
     */
    function injectFunds(uint256 _lotteryId, uint256 _amount) external override onlyOwnerOrInjector {
        require(_lotteries[_lotteryId].status == Status.Open, "Lottery not open");

        javaToken.safeTransferFrom(address(msg.sender), address(this), _amount);
        _lotteries[_lotteryId].amountCollectedInJava += _amount;

        emit LotteryInjection(_lotteryId, _amount);
    }

    /**
     * @notice Start the lottery
     * @dev Callable by operator
     * @param _endTime: endTime of the lottery
     * @param _priceTicketInJava: price of a ticket in JAVA
     * @param _discountDivisor: the divisor to calculate the discount magnitude for bulks
     * @param _rewardsBreakdown: breakdown of rewards per bracket (must sum to 10,000)
     * @param _treasuryFee: treasury fee (10,000 = 100%, 100 = 1%)
     */
    function startLottery(
        uint256 _endTime,
        uint256 _priceTicketInJava,
        uint256 _discountDivisor,
        uint256[6] calldata _rewardsBreakdown,
        uint256 _treasuryFee
    ) external override onlyOperator {
        require(
            (currentLotteryId == 0) || (_lotteries[currentLotteryId].status == Status.Claimable),
            "Not time to start lottery"
        );

        require(
            ((_endTime - block.timestamp) > MIN_LENGTH_LOTTERY) && ((_endTime - block.timestamp) < MAX_LENGTH_LOTTERY),
            "Lottery length outside of range"
        );

        require(
            (_priceTicketInJava >= minPriceTicketInJava) && (_priceTicketInJava <= maxPriceTicketInJava),
            "Outside of limits"
        );

        require(_discountDivisor >= MIN_DISCOUNT_DIVISOR, "Discount divisor too low");
        require(_treasuryFee <= MAX_TREASURY_FEE, "Treasury fee too high");

        require(
            (_rewardsBreakdown[0] +
                _rewardsBreakdown[1] +
                _rewardsBreakdown[2] +
                _rewardsBreakdown[3] +
                _rewardsBreakdown[4] +
                _rewardsBreakdown[5]) == 10000,
            "Rewards must equal 10000"
        );

        currentLotteryId++;

        _lotteries[currentLotteryId] = Lottery({
            status: Status.Open,
            startTime: block.timestamp,
            endTime: _endTime,
            priceTicketInJava: _priceTicketInJava,
            discountDivisor: _discountDivisor,
            rewardsBreakdown: _rewardsBreakdown,
            treasuryFee: _treasuryFee,
            javaPerBracket: [uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0)],
            countWinnersPerBracket: [uint256(0), uint256(0), uint256(0), uint256(0), uint256(0), uint256(0)],
            firstTicketId: currentTicketId,
            firstTicketIdNextLottery: currentTicketId,
            amountCollectedInJava: pendingInjectionNextLottery,
            finalNumber: 0
        });

        emit LotteryOpen(
            currentLotteryId,
            block.timestamp,
            _endTime,
            _priceTicketInJava,
            currentTicketId,
            pendingInjectionNextLottery
        );

        pendingInjectionNextLottery = 0;
    }

    /**
     * @notice It allows the admin to recover wrong tokens sent to the contract
     * @param _tokenAddress: the address of the token to withdraw
     * @param _tokenAmount: the number of token amount to withdraw
     * @dev Only callable by owner.
     */
    function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount) external onlyOwner {
        require(_tokenAddress != address(javaToken), "Cannot be JAVA token");

        IERC20(_tokenAddress).safeTransfer(address(msg.sender), _tokenAmount);

        emit AdminTokenRecovery(_tokenAddress, _tokenAmount);
    }

    /**
     * @notice Set JAVA price ticket upper/lower limit
     * @dev Only callable by owner
     * @param _minPriceTicketInJava: minimum price of a ticket in JAVA
     * @param _maxPriceTicketInJava: maximum price of a ticket in JAVA
     */
    function setMinAndMaxTicketPriceInJava(uint256 _minPriceTicketInJava, uint256 _maxPriceTicketInJava)
        external
        onlyOwner
    {
        require(_minPriceTicketInJava <= _maxPriceTicketInJava, "minPrice must be < maxPrice");

        minPriceTicketInJava = _minPriceTicketInJava;
        maxPriceTicketInJava = _maxPriceTicketInJava;
    }

    /**
     * @notice Set max number of tickets
     * @dev Only callable by owner
     */
    function setMaxNumberTicketsPerBuy(uint256 _maxNumberTicketsPerBuy) external onlyOwner {
        require(_maxNumberTicketsPerBuy != 0, "Must be > 0");
        maxNumberTicketsPerBuyOrClaim = _maxNumberTicketsPerBuy;
    }

    /**
     * @notice Set operator, treasury, and injector addresses
     * @dev Only callable by owner
     * @param _operatorAddress: address of the operator
     * @param _treasuryAddress: address of the treasury
     * @param _injectorAddress: address of the injector
     */
    function setOperatorAndTreasuryAndInjectorAddresses(
        address _operatorAddress,
        address _treasuryAddress,
        address _injectorAddress
    ) external onlyOwner {
        require(_operatorAddress != address(0), "Cannot be zero address");
        require(_treasuryAddress != address(0), "Cannot be zero address");
        require(_injectorAddress != address(0), "Cannot be zero address");

        operatorAddress = _operatorAddress;
        treasuryAddress = _treasuryAddress;
        injectorAddress = _injectorAddress;

        emit NewOperatorAndTreasuryAndInjectorAddresses(_operatorAddress, _treasuryAddress, _injectorAddress);
    }

    /**
     * @notice Calculate price of a set of tickets
     * @param _discountDivisor: divisor for the discount
     * @param _priceTicket price of a ticket (in JAVA)
     * @param _numberTickets number of tickets to buy
     */
    function calculateTotalPriceForBulkTickets(
        uint256 _discountDivisor,
        uint256 _priceTicket,
        uint256 _numberTickets
    ) external pure returns (uint256) {
        require(_discountDivisor >= MIN_DISCOUNT_DIVISOR, "Must be >= MIN_DISCOUNT_DIVISOR");
        require(_numberTickets != 0, "Number of tickets must be > 0");

        return _calculateTotalPriceForBulkTickets(_discountDivisor, _priceTicket, _numberTickets);
    }

    /**
     * @notice View current lottery id
     */
    function viewCurrentLotteryId() external view override returns (uint256) {
        return currentLotteryId;
    }

    /**
     * @notice View lottery information
     * @param _lotteryId: lottery id
     */
    function viewLottery(uint256 _lotteryId) external view returns (Lottery memory) {
        return _lotteries[_lotteryId];
    }

    /**
     * @notice View ticker statuses and numbers for an array of ticket ids
     * @param _ticketIds: array of _ticketId
     */
    function viewNumbersAndStatusesForTicketIds(uint256[] calldata _ticketIds)
        external
        view
        returns (uint32[] memory, bool[] memory)
    {
        uint256 length = _ticketIds.length;
        uint32[] memory ticketNumbers = new uint32[](length);
        bool[] memory ticketStatuses = new bool[](length);

        for (uint256 i = 0; i < length; i++) {
            ticketNumbers[i] = _tickets[_ticketIds[i]].number;
            if (_tickets[_ticketIds[i]].owner == address(0)) {
                ticketStatuses[i] = true;
            } else {
                ticketStatuses[i] = false;
            }
        }

        return (ticketNumbers, ticketStatuses);
    }

    /**
     * @notice View rewards for a given ticket, providing a bracket, and lottery id
     * @dev Computations are mostly offchain. This is used to verify a ticket!
     * @param _lotteryId: lottery id
     * @param _ticketId: ticket id
     * @param _bracket: bracket for the ticketId to verify the claim and calculate rewards
     */
    function viewRewardsForTicketId(
        uint256 _lotteryId,
        uint256 _ticketId,
        uint32 _bracket
    ) external view returns (uint256) {
        // Check lottery is in claimable status
        if (_lotteries[_lotteryId].status != Status.Claimable) {
            return 0;
        }

        // Check ticketId is within range
        if (
            (_lotteries[_lotteryId].firstTicketIdNextLottery < _ticketId) &&
            (_lotteries[_lotteryId].firstTicketId >= _ticketId)
        ) {
            return 0;
        }

        return _calculateRewardsForTicketId(_lotteryId, _ticketId, _bracket);
    }

    /**
     * @notice View user ticket ids, numbers, and statuses of user for a given lottery
     * @param _user: user address
     * @param _lotteryId: lottery id
     * @param _cursor: cursor to start where to retrieve the tickets
     * @param _size: the number of tickets to retrieve
     */
    function viewUserInfoForLotteryId(
        address _user,
        uint256 _lotteryId,
        uint256 _cursor,
        uint256 _size
    )
        external
        view
        returns (
            uint256[] memory,
            uint32[] memory,
            bool[] memory,
            uint256
        )
    {
        uint256 length = _size;
        uint256 numberTicketsBoughtAtLotteryId = _userTicketIdsPerLotteryId[_user][_lotteryId].length;

        if (length > (numberTicketsBoughtAtLotteryId - _cursor)) {
            length = numberTicketsBoughtAtLotteryId - _cursor;
        }

        uint256[] memory lotteryTicketIds = new uint256[](length);
        uint32[] memory ticketNumbers = new uint32[](length);
        bool[] memory ticketStatuses = new bool[](length);

        for (uint256 i = 0; i < length; i++) {
            lotteryTicketIds[i] = _userTicketIdsPerLotteryId[_user][_lotteryId][i + _cursor];
            ticketNumbers[i] = _tickets[lotteryTicketIds[i]].number;

            // True = ticket claimed
            if (_tickets[lotteryTicketIds[i]].owner == address(0)) {
                ticketStatuses[i] = true;
            } else {
                // ticket not claimed (includes the ones that cannot be claimed)
                ticketStatuses[i] = false;
            }
        }

        return (lotteryTicketIds, ticketNumbers, ticketStatuses, _cursor + length);
    }

    /**
     * @notice Calculate rewards for a given ticket
     * @param _lotteryId: lottery id
     * @param _ticketId: ticket id
     * @param _bracket: bracket for the ticketId to verify the claim and calculate rewards
     */
    function _calculateRewardsForTicketId(
        uint256 _lotteryId,
        uint256 _ticketId,
        uint32 _bracket
    ) internal view returns (uint256) {
        // Retrieve the winning number combination
        uint32 userNumber = _lotteries[_lotteryId].finalNumber;

        // Retrieve the user number combination from the ticketId
        uint32 winningTicketNumber = _tickets[_ticketId].number;

        // Apply transformation to verify the claim provided by the user is true
        uint32 transformedWinningNumber = _bracketCalculator[_bracket] +
            (winningTicketNumber % (uint32(10)**(_bracket + 1)));

        uint32 transformedUserNumber = _bracketCalculator[_bracket] + (userNumber % (uint32(10)**(_bracket + 1)));

        // Confirm that the two transformed numbers are the same, if not throw
        if (transformedWinningNumber == transformedUserNumber) {
            return _lotteries[_lotteryId].javaPerBracket[_bracket];
        } else {
            return 0;
        }
    }

    /**
     * @notice Calculate final price for bulk of tickets
     * @param _discountDivisor: divisor for the discount (the smaller it is, the greater the discount is)
     * @param _priceTicket: price of a ticket
     * @param _numberTickets: number of tickets purchased
     */
    function _calculateTotalPriceForBulkTickets(
        uint256 _discountDivisor,
        uint256 _priceTicket,
        uint256 _numberTickets
    ) internal pure returns (uint256) {
        return (_priceTicket * _numberTickets * (_discountDivisor + 1 - _numberTickets)) / _discountDivisor;
    }

    /**
     * @notice Check if an address is a contract
     */
    function _isContract(address _addr) internal view returns (bool) {
        uint256 size;
        assembly {
            size := extcodesize(_addr)
        }
        return size > 0;
    }
}

File 2 of 9 : IJavaSwapLottery.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IJavaSwapLottery {
    /**
     * @notice Buy tickets for the current lottery
     * @param _lotteryId: lotteryId
     * @param _ticketNumbers: array of ticket numbers between 1,000,000 and 1,999,999
     * @dev Callable by users
     */
    function buyTickets(uint256 _lotteryId, uint32[] calldata _ticketNumbers) external;

    /**
     * @notice Claim a set of winning tickets for a lottery
     * @param _lotteryId: lottery id
     * @param _ticketIds: array of ticket ids
     * @param _brackets: array of brackets for the ticket ids
     * @dev Callable by users only, not contract!
     */
    function claimTickets(
        uint256 _lotteryId,
        uint256[] calldata _ticketIds,
        uint32[] calldata _brackets
    ) external;

    /**
     * @notice Close lottery
     * @param _lotteryId: lottery id
     * @dev Callable by operator
     */
    function closeLottery(uint256 _lotteryId) external;

    /**
     * @notice Draw the final number, calculate reward in JAVA per group, and make lottery claimable
     * @param _lotteryId: lottery id
     * @param _autoInjection: reinjects funds into next lottery (vs. withdrawing all)
     * @dev Callable by operator
     */
    function drawFinalNumberAndMakeLotteryClaimable(uint256 _lotteryId, bool _autoInjection) external;

    /**
     * @notice Inject funds
     * @param _lotteryId: lottery id
     * @param _amount: amount to inject in JAVA token
     * @dev Callable by operator
     */
    function injectFunds(uint256 _lotteryId, uint256 _amount) external;

    /**
     * @notice Start the lottery
     * @dev Callable by operator
     * @param _endTime: endTime of the lottery
     * @param _priceTicketInJava: price of a ticket in JAVA
     * @param _discountDivisor: the divisor to calculate the discount magnitude for bulks
     * @param _rewardsBreakdown: breakdown of rewards per bracket (must sum to 10,000)
     * @param _treasuryFee: treasury fee (10,000 = 100%, 100 = 1%)
     */
    function startLottery(
        uint256 _endTime,
        uint256 _priceTicketInJava,
        uint256 _discountDivisor,
        uint256[6] calldata _rewardsBreakdown,
        uint256 _treasuryFee
    ) external;

    /**
     * @notice View current lottery id
     */
    function viewCurrentLotteryId() external returns (uint256);
}

File 3 of 9 : IRandomNumberGenerator.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

interface IRandomNumberGenerator {
    /**
     * Requests randomness from a user-provided seed
     */
    function getRandomNumber(uint256 _seed) external;

    /**
     * View latest lotteryId numbers
     */
    function viewLatestLotteryId() external view returns (uint256);

    /**
     * Views random result
     */
    function viewRandomResult() external view returns (uint32);
}

File 4 of 9 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 5 of 9 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 6 of 9 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
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);
}

File 7 of 9 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 8 of 9 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 9 of 9 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_javaTokenAddress","type":"address"},{"internalType":"address","name":"_randomGeneratorAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AdminTokenRecovery","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"firstTicketIdNextLottery","type":"uint256"}],"name":"LotteryClose","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"injectedAmount","type":"uint256"}],"name":"LotteryInjection","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"finalNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"countWinningTickets","type":"uint256"}],"name":"LotteryNumberDrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceTicketInJava","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"firstTicketId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"injectedAmount","type":"uint256"}],"name":"LotteryOpen","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"treasury","type":"address"},{"indexed":false,"internalType":"address","name":"injector","type":"address"}],"name":"NewOperatorAndTreasuryAndInjectorAddresses","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"randomGenerator","type":"address"}],"name":"NewRandomGenerator","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberTickets","type":"uint256"}],"name":"TicketsClaim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":true,"internalType":"uint256","name":"lotteryId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"numberTickets","type":"uint256"}],"name":"TicketsPurchase","type":"event"},{"inputs":[],"name":"MAX_LENGTH_LOTTERY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TREASURY_FEE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_DISCOUNT_DIVISOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_LENGTH_LOTTERY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint32[]","name":"_ticketNumbers","type":"uint32[]"}],"name":"buyTickets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_discountDivisor","type":"uint256"},{"internalType":"uint256","name":"_priceTicket","type":"uint256"},{"internalType":"uint256","name":"_numberTickets","type":"uint256"}],"name":"calculateTotalPriceForBulkTickets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_randomGeneratorAddress","type":"address"}],"name":"changeRandomGenerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256[]","name":"_ticketIds","type":"uint256[]"},{"internalType":"uint32[]","name":"_brackets","type":"uint32[]"}],"name":"claimTickets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"}],"name":"closeLottery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentLotteryId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentTicketId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"bool","name":"_autoInjection","type":"bool"}],"name":"drawFinalNumberAndMakeLotteryClaimable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"injectFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"injectorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"javaToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxNumberTicketsPerBuyOrClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPriceTicketInJava","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minPriceTicketInJava","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operatorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingInjectionNextLottery","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"randomGenerator","outputs":[{"internalType":"contract IRandomNumberGenerator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_tokenAmount","type":"uint256"}],"name":"recoverWrongTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxNumberTicketsPerBuy","type":"uint256"}],"name":"setMaxNumberTicketsPerBuy","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minPriceTicketInJava","type":"uint256"},{"internalType":"uint256","name":"_maxPriceTicketInJava","type":"uint256"}],"name":"setMinAndMaxTicketPriceInJava","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_operatorAddress","type":"address"},{"internalType":"address","name":"_treasuryAddress","type":"address"},{"internalType":"address","name":"_injectorAddress","type":"address"}],"name":"setOperatorAndTreasuryAndInjectorAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_endTime","type":"uint256"},{"internalType":"uint256","name":"_priceTicketInJava","type":"uint256"},{"internalType":"uint256","name":"_discountDivisor","type":"uint256"},{"internalType":"uint256[6]","name":"_rewardsBreakdown","type":"uint256[6]"},{"internalType":"uint256","name":"_treasuryFee","type":"uint256"}],"name":"startLottery","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"viewCurrentLotteryId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"}],"name":"viewLottery","outputs":[{"components":[{"internalType":"enum JavaSwapLottery.Status","name":"status","type":"uint8"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"priceTicketInJava","type":"uint256"},{"internalType":"uint256","name":"discountDivisor","type":"uint256"},{"internalType":"uint256[6]","name":"rewardsBreakdown","type":"uint256[6]"},{"internalType":"uint256","name":"treasuryFee","type":"uint256"},{"internalType":"uint256[6]","name":"javaPerBracket","type":"uint256[6]"},{"internalType":"uint256[6]","name":"countWinnersPerBracket","type":"uint256[6]"},{"internalType":"uint256","name":"firstTicketId","type":"uint256"},{"internalType":"uint256","name":"firstTicketIdNextLottery","type":"uint256"},{"internalType":"uint256","name":"amountCollectedInJava","type":"uint256"},{"internalType":"uint32","name":"finalNumber","type":"uint32"}],"internalType":"struct JavaSwapLottery.Lottery","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_ticketIds","type":"uint256[]"}],"name":"viewNumbersAndStatusesForTicketIds","outputs":[{"internalType":"uint32[]","name":"","type":"uint32[]"},{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256","name":"_ticketId","type":"uint256"},{"internalType":"uint32","name":"_bracket","type":"uint32"}],"name":"viewRewardsForTicketId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_lotteryId","type":"uint256"},{"internalType":"uint256","name":"_cursor","type":"uint256"},{"internalType":"uint256","name":"_size","type":"uint256"}],"name":"viewUserInfoForLotteryId","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint32[]","name":"","type":"uint32[]"},{"internalType":"bool[]","name":"","type":"bool[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

608060405260646007556802b5e3af16b18800006008556611c37937e080006009553480156200002e57600080fd5b5060405162003bf138038062003bf1833981016040819052620000519162000219565b60016000556200006133620001aa565b600b80546001600160a01b039384166001600160a01b0319918216178255600c805493909416921691909117909155600f6020527ff4803e074bd026baaf6ed2e288c9515f68c72fb7216eebdd7cae1718a53ec375805463ffffffff199081166001179091557f169f97de0d9a84d840042b17d3c6b9638b3d6fd9024c9eb0c7a306a17b49f88f805482169092179091557fa74ba3945261e09fde15ba3db55005b205e61eeb4ad811ac0faa2b315bffeead80548216606f1790557f45f76dafbbad695564362934e24d72eedc57f9fc1a65f39bca62176cc8296828805482166104571790557f367ccd2d0ac16bf7110a5dffe0801fdc9452a95a1adb7e1a12fe97dd3e9a4edd80548216612b6717905560056000527f6bda57492eba051cb4a12a1e19df47c9755d78165341d4009b1d09b3f361620480549091166201b20717905562000251565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b80516001600160a01b03811681146200021457600080fd5b919050565b600080604083850312156200022d57600080fd5b6200023883620001fc565b91506200024860208401620001fc565b90509250929050565b61399080620002616000396000f3fe608060405234801561001057600080fd5b50600436106102115760003560e01c806388303dbd11610125578063c5f956af116100ad578063dcbad90d1161007c578063dcbad90d14610441578063f11fd2ed14610454578063f1adc20b1461045d578063f2b3c80914610470578063f2fde38b1461047957600080fd5b8063c5f956af146103fe578063c914914f14610411578063da4ca03914610424578063db19da0d1461043757600080fd5b80639c384653116100f45780639c3846531461039f5780639d8ca531146103b2578063b1829b82146103c5578063c38de539146103d8578063c4937ab9146103eb57600080fd5b806388303dbd146103475780638da5cb5b1461035a5780638fc3539a1461036b57806398359fa11461038c57600080fd5b80633f138d4b116101a85780636b873788116101775780636b873788146103125780636be4097c14610325578063715018a61461032e5780637cb583bd1461033657806380a061601461033f57600080fd5b80633f138d4b146102ce5780634186f299146102e3578063471aeab4146102f6578063686465b81461030957600080fd5b806312a9769d116101e457806312a9769d146102895780631fe86c6b146102925780632423807a1461029b5780632e530cae146102bb57600080fd5b8063014376951461021657806305531eeb1461023257806307fb5a9c14610255578063127effb21461025e575b600080fd5b61021f60085481565b6040519081526020015b60405180910390f35b610245610240366004612f94565b61048c565b6040516102299493929190613040565b61021f61371481565b600354610271906001600160a01b031681565b6040516001600160a01b039091168152602001610229565b61021f600a5481565b61021f60075481565b6102ae6102a93660046130b4565b610778565b6040516102299190613128565b61021f6102c93660046131fd565b6108d9565b6102e16102dc366004613236565b610960565b005b600b54610271906001600160a01b031681565b6102e1610304366004613260565b610a42565b61021f60065481565b6102e16103203660046130b4565b610b85565b61021f60055481565b6102e1610bef565b61021f61012c81565b60055461021f565b6102e16103553660046132c7565b610c25565b6001546001600160a01b0316610271565b61037e610379366004613313565b6111ea565b604051610229929190613355565b6102e161039a366004613383565b6113a4565b600254610271906001600160a01b031681565b6102e16103c03660046130b4565b611592565b6102e16103d336600461339e565b61179a565b6102e16103e63660046133fb565b611c84565b61021f6103f936600461342b565b61221a565b600454610271906001600160a01b031681565b6102e161041f366004613457565b6122c6565b6102e16104323660046134d1565b61282f565b61021f6205472c81565b600c54610271906001600160a01b031681565b61021f60095481565b6102e161046b366004613260565b61294f565b61021f610bb881565b6102e1610487366004613383565b6129d4565b6001600160a01b0384166000908152601160209081526040808320868452909152812054606091829182919085906104c4888261352a565b8211156104d8576104d5888261352a565b91505b60008267ffffffffffffffff8111156104f3576104f3613541565b60405190808252806020026020018201604052801561051c578160200160208202803683370190505b50905060008367ffffffffffffffff81111561053a5761053a613541565b604051908082528060200260200182016040528015610563578160200160208202803683370190505b50905060008467ffffffffffffffff81111561058157610581613541565b6040519080825280602002602001820160405280156105aa578160200160208202803683370190505b50905060005b8581101561075257601160008f6001600160a01b03166001600160a01b0316815260200190815260200160002060008e81526020019081526020016000208c826105fa9190613557565b8154811061060a5761060a61356f565b90600052602060002001548482815181106106275761062761356f565b602002602001018181525050600e60008583815181106106495761064961356f565b6020026020010151815260200190815260200160002060000160009054906101000a900463ffffffff168382815181106106855761068561356f565b602002602001019063ffffffff16908163ffffffff168152505060006001600160a01b0316600e60008684815181106106c0576106c061356f565b60209081029190910181015182528101919091526040016000205464010000000090046001600160a01b0316141561071b5760018282815181106107065761070661356f565b91151560209283029190910190910152610740565b600082828151811061072f5761072f61356f565b911515602092830291909101909101525b8061074a81613585565b9150506105b0565b50828282610760888f613557565b98509850985098505050505050945094509450949050565b610780612e86565b6000828152600d60205260409081902081516101a081019092528054829060ff1660038111156107b2576107b26130cd565b60038111156107c3576107c36130cd565b81526001820154602082015260028201546040808301919091526003830154606083015260048301546080830152805160c081019182905260a09092019190600584019060069082845b81548152602001906001019080831161080d575050509183525050600b82015460208201526040805160c081018252910190600c830160068282826020028201915b81548152602001906001019080831161084f5750505091835250506040805160c081019182905260209092019190601284019060069082845b8154815260200190600101908083116108885750505091835250506018820154602082015260198201546040820152601a8201546060820152601b9091015463ffffffff1660809091015292915050565b600060036000858152600d602052604090205460ff166003811115610900576109006130cd565b1461090d57506000610959565b6000848152600d60205260409020601901548311801561093e57506000848152600d60205260409020601801548311155b1561094b57506000610959565b610956848484612a6f565b90505b9392505050565b6001546001600160a01b031633146109935760405162461bcd60e51b815260040161098a906135a0565b60405180910390fd5b600b546001600160a01b03838116911614156109e85760405162461bcd60e51b815260206004820152601460248201527321b0b73737ba103132902520ab20903a37b5b2b760611b604482015260640161098a565b6109fc6001600160a01b0383163383612b7a565b604080516001600160a01b0384168152602081018390527f74545154aac348a3eac92596bd1971957ca94795f4e954ec5f613b55fab78129910160405180910390a15050565b6001546001600160a01b0316331480610a6557506002546001600160a01b031633145b610aa95760405162461bcd60e51b81526020600482015260156024820152742737ba1037bbb732b91037b91034b73532b1ba37b960591b604482015260640161098a565b60016000838152600d602052604090205460ff166003811115610ace57610ace6130cd565b14610b0e5760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037b832b760811b604482015260640161098a565b600b54610b26906001600160a01b0316333084612be2565b6000828152600d60205260408120601a018054839290610b47908490613557565b909155505060405181815282907f1bbd659dd628a25f7ff2eabb69c74a56939c539728282275c1c9c1a2d3e340499060200160405180910390a25050565b6001546001600160a01b03163314610baf5760405162461bcd60e51b815260040161098a906135a0565b80610bea5760405162461bcd60e51b815260206004820152600b60248201526a04d757374206265203e20360ac1b604482015260640161098a565b600755565b6001546001600160a01b03163314610c195760405162461bcd60e51b815260040161098a906135a0565b610c236000612c20565b565b333b15610c6b5760405162461bcd60e51b815260206004820152601460248201527310dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b604482015260640161098a565b333214610cba5760405162461bcd60e51b815260206004820152601a60248201527f50726f787920636f6e7472616374206e6f7420616c6c6f776564000000000000604482015260640161098a565b60026000541415610cdd5760405162461bcd60e51b815260040161098a906135d5565b600260005580610d255760405162461bcd60e51b8152602060048201526013602482015272139bc81d1a58dad95d081cdc1958da599a5959606a1b604482015260640161098a565b600754811115610d6a5760405162461bcd60e51b815260206004820152601060248201526f546f6f206d616e79207469636b65747360801b604482015260640161098a565b60016000848152600d602052604090205460ff166003811115610d8f57610d8f6130cd565b14610dd25760405162461bcd60e51b81526020600482015260136024820152722637ba3a32b93c9034b9903737ba1037b832b760691b604482015260640161098a565b6000838152600d60205260409020600201544210610e245760405162461bcd60e51b815260206004820152600f60248201526e2637ba3a32b93c9034b99037bb32b960891b604482015260640161098a565b6000838152600d602052604081206004810154600390910154610e48919084612c72565b600b54909150610e63906001600160a01b0316333084612be2565b6000848152600d60205260408120601a018054839290610e84908490613557565b90915550600090505b828110156111a7576000848483818110610ea957610ea961356f565b9050602002016020810190610ebe919061360c565b9050620f42408163ffffffff1610158015610ee25750621e847f8163ffffffff1611155b610f1e5760405162461bcd60e51b815260206004820152600d60248201526c4f7574736964652072616e676560981b604482015260640161098a565b600086815260106020526040812090610f38600a8461363f565b610f43906001613662565b63ffffffff16815260208101919091526040016000908120805491610f6783613585565b9091555050600086815260106020526040812090610f8660648461363f565b610f9190600b613662565b63ffffffff16815260208101919091526040016000908120805491610fb583613585565b9091555050600086815260106020526040812090610fd56103e88461363f565b610fe090606f613662565b63ffffffff1681526020810191909152604001600090812080549161100483613585565b90915550506000868152601060205260408120906110246127108461363f565b61103090610457613662565b63ffffffff1681526020810191909152604001600090812080549161105483613585565b9091555050600086815260106020526040812090611075620186a08461363f565b61108190612b67613662565b63ffffffff168152602081019190915260400160009081208054916110a583613585565b90915550506000868152601060205260408120906110c6620f42408461363f565b6110d3906201b207613662565b63ffffffff168152602081019190915260400160009081208054916110f783613585565b90915550503360008181526011602090815260408083208a84528252808320600680548254600181018455928652848620909201919091558151808301835263ffffffff808816825281850196875282548652600e9094529184209151825495516001600160a01b0316640100000000026001600160c01b0319909616931692909217939093179092558154919061118e83613585565b919050555050808061119f90613585565b915050610e8d565b50604051828152849033907fd7d247b583de1023852eef87b48f54354dbec771d01bc2cc49e96094efc322b99060200160405180910390a3505060016000555050565b6060808260008167ffffffffffffffff81111561120957611209613541565b604051908082528060200260200182016040528015611232578160200160208202803683370190505b50905060008267ffffffffffffffff81111561125057611250613541565b604051908082528060200260200182016040528015611279578160200160208202803683370190505b50905060005b8381101561139557600e600089898481811061129d5761129d61356f565b90506020020135815260200190815260200160002060000160009054906101000a900463ffffffff168382815181106112d8576112d861356f565b63ffffffff909216602092830291909101909101526000600e818a8a858181106113045761130461356f565b602090810292909201358352508101919091526040016000205464010000000090046001600160a01b0316141561135e5760018282815181106113495761134961356f565b91151560209283029190910190910152611383565b60008282815181106113725761137261356f565b911515602092830291909101909101525b8061138d81613585565b91505061127f565b509093509150505b9250929050565b6001546001600160a01b031633146113ce5760405162461bcd60e51b815260040161098a906135a0565b60036005546000908152600d602052604090205460ff1660038111156113f6576113f66130cd565b146114435760405162461bcd60e51b815260206004820152601860248201527f4c6f7474657279206e6f7420696e20636c61696d61626c650000000000000000604482015260640161098a565b806001600160a01b031663b37217a4600554600654604051602001611472929190918252602082015260400190565b60408051808303601f1901815290829052805160209091012060e083901b6001600160e01b03191682526004820152602401600060405180830381600087803b1580156114be57600080fd5b505af11580156114d2573d6000803e3d6000fd5b50505050806001600160a01b031663a1c4f55a6040518163ffffffff1660e01b815260040160206040518083038186803b15801561150f57600080fd5b505afa158015611523573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611547919061368a565b50600c80546001600160a01b0319166001600160a01b0383169081179091556040517f383f8cb39dfa7c3fb901a460dd449ea924868f0a92ff03da64740fffa5f1de6290600090a250565b6003546001600160a01b031633146115bc5760405162461bcd60e51b815260040161098a906136a7565b600260005414156115df5760405162461bcd60e51b815260040161098a906135d5565b600260005560016000828152600d602052604090205460ff166003811115611609576116096130cd565b146116495760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037b832b760811b604482015260640161098a565b6000818152600d6020526040902060020154421161169c5760405162461bcd60e51b815260206004820152601060248201526f2637ba3a32b93c903737ba1037bb32b960811b604482015260640161098a565b6006546000828152600d6020908152604091829020601901839055600c548251918201859052918101929092526001600160a01b03169063b37217a49060600160408051808303601f1901815290829052805160209091012060e083901b6001600160e01b03191682526004820152602401600060405180830381600087803b15801561172857600080fd5b505af115801561173c573d6000803e3d6000fd5b5050506000828152600d6020908152604091829020805460ff1916600217905560065491519182528392507f3728e75294796694d59d2ffced9c394279baf7b9ebd2702db43f5f04bac67929910160405180910390a2506001600055565b6003546001600160a01b031633146117c45760405162461bcd60e51b815260040161098a906136a7565b60055415806117f8575060036005546000908152600d602052604090205460ff1660038111156117f6576117f66130cd565b145b6118445760405162461bcd60e51b815260206004820152601960248201527f4e6f742074696d6520746f207374617274206c6f747465727900000000000000604482015260640161098a565b613714611851428761352a565b11801561186957506205472c611867428761352a565b105b6118b55760405162461bcd60e51b815260206004820152601f60248201527f4c6f7474657279206c656e677468206f757473696465206f662072616e676500604482015260640161098a565b60095484101580156118c957506008548411155b6119095760405162461bcd60e51b81526020600482015260116024820152704f757473696465206f66206c696d69747360781b604482015260640161098a565b61012c83101561195b5760405162461bcd60e51b815260206004820152601860248201527f446973636f756e742064697669736f7220746f6f206c6f770000000000000000604482015260640161098a565b610bb88111156119a55760405162461bcd60e51b81526020600482015260156024820152740a8e4cac2e6eae4f240cccaca40e8dede40d0d2ced605b1b604482015260640161098a565b60a08201356080830135606084013560408501356119c860208701358735613557565b6119d29190613557565b6119dc9190613557565b6119e69190613557565b6119f09190613557565b61271014611a405760405162461bcd60e51b815260206004820152601860248201527f52657761726473206d75737420657175616c2031303030300000000000000000604482015260640161098a565b60058054906000611a5083613585565b9091555050604080516101a0810190915280600181526020014281526020018681526020018581526020018481526020018360068060200260405190810160405280929190826006602002808284376000920182905250928452505060208083018590526040805160c080820183528482528184018590528183018590526060808301869052608080840187905260a080850188905285890194909452845180840186528781528087018890528086018890528083018890528082018890528085018890529188019190915260065490870181905291860191909152600a549085015260e09093018290526005548252600d90522081518154829060ff19166001836003811115611b6357611b636130cd565b02179055506020820151600182015560408201516002820155606082015160038201556080820151600482015560a0820151611ba59060058301906006612f07565b5060c0820151600b82015560e0820151611bc590600c8301906006612f07565b50610100820151611bdc9060128301906006612f07565b5061012082015160188201556101408201516019820155610160820151601a82015561018090910151601b909101805463ffffffff191663ffffffff909216919091179055600554600654600a5460408051428152602081018a9052908101889052606081019290925260808201527f367e70f8c0e0c0a6504d92172bda155c02022d532fc85b5d66a9c49e31c8bc779060a00160405180910390a250506000600a55505050565b6003546001600160a01b03163314611cae5760405162461bcd60e51b815260040161098a906136a7565b60026000541415611cd15760405162461bcd60e51b815260040161098a906135d5565b60026000818155838152600d602052604090205460ff166003811115611cf957611cf96130cd565b14611d3a5760405162461bcd60e51b81526020600482015260116024820152704c6f7474657279206e6f7420636c6f736560781b604482015260640161098a565b600c60009054906101000a90046001600160a01b03166001600160a01b031663fbe5d9176040518163ffffffff1660e01b815260040160206040518083038186803b158015611d8857600080fd5b505afa158015611d9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc091906136cd565b8214611e025760405162461bcd60e51b8152602060048201526011602482015270273ab6b132b939903737ba10323930bbb760791b604482015260640161098a565b600c54604080516350e27aad60e11b815290516000926001600160a01b03169163a1c4f55a916004808301926020929190829003018186803b158015611e4757600080fd5b505afa158015611e5b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e7f919061368a565b6000848152600d60205260408120600b015491925090819061271090611ea5908261352a565b6000878152600d60205260409020601a0154611ec191906136e6565b611ecb9190613705565b90506000805b60068163ffffffff161015612145576000611eed826005613719565b90506000611efc826001613662565b611f0790600a613851565b611f11908861363f565b63ffffffff8084166000908152600f6020526040902054611f33929116613662565b60008a815260106020908152604080832063ffffffff85168452909152902054909150611f6190879061352a565b60008a8152600d6020526040902060120163ffffffff841660068110611f8957611f8961356f565b0155600089815260106020908152604080832063ffffffff85168452909152902054611fb690879061352a565b156120b5576000898152600d6020526040902060050163ffffffff831660068110611fe357611fe361356f565b0154156120b057600089815260106020908152604080832063ffffffff851684529091529020546127109061201990889061352a565b60008b8152600d60205260409020879060050163ffffffff8616600681106120435761204361356f565b015461204f91906136e6565b6120599190613705565b6120639190613705565b60008a8152600d60205260409020600c0163ffffffff84166006811061208b5761208b61356f565b0155600089815260106020908152604080832063ffffffff8516845290915290205495505b612130565b6000898152600d60205260408120600c0163ffffffff8416600681106120dd576120dd61356f565b01556000898152600d6020526040902061271090869060050163ffffffff85166006811061210d5761210d61356f565b015461211991906136e6565b6121239190613705565b61212d9085613557565b93505b5050808061213d9061386e565b915050611ed1565b506000868152600d60205260409020601b8101805463ffffffff871663ffffffff19909116179055805460ff19166003179055841561218457600a5560005b6000868152600d60205260409020601a01546121a190839061352a565b6121ab9082613557565b600454600b549192506121cb916001600160a01b03908116911683612b7a565b6005546040805163ffffffff87168152602081018690527f98e31a6607b8b15b4d5b91de54f4c09ffe4c4cf162aa532c70b5213754e2e703910160405180910390a25050600160005550505050565b600061012c84101561226e5760405162461bcd60e51b815260206004820152601f60248201527f4d757374206265203e3d204d494e5f444953434f554e545f44495649534f5200604482015260640161098a565b816122bb5760405162461bcd60e51b815260206004820152601d60248201527f4e756d626572206f66207469636b657473206d757374206265203e2030000000604482015260640161098a565b610956848484612c72565b333b1561230c5760405162461bcd60e51b815260206004820152601460248201527310dbdb9d1c9858dd081b9bdd08185b1b1bddd95960621b604482015260640161098a565b33321461235b5760405162461bcd60e51b815260206004820152601a60248201527f50726f787920636f6e7472616374206e6f7420616c6c6f776564000000000000604482015260640161098a565b6002600054141561237e5760405162461bcd60e51b815260040161098a906135d5565b60026000558281146123c45760405162461bcd60e51b815260206004820152600f60248201526e09cdee840e6c2daca40d8cadccee8d608b1b604482015260640161098a565b826124055760405162461bcd60e51b815260206004820152601160248201527004c656e677468206d757374206265203e3607c1b604482015260640161098a565b60075483111561244a5760405162461bcd60e51b815260206004820152601060248201526f546f6f206d616e79207469636b65747360801b604482015260640161098a565b60036000868152600d602052604090205460ff16600381111561246f5761246f6130cd565b146124b45760405162461bcd60e51b81526020600482015260156024820152744c6f7474657279206e6f7420636c61696d61626c6560581b604482015260640161098a565b6000805b848110156127cd5760068484838181106124d4576124d461356f565b90506020020160208101906124e9919061360c565b63ffffffff16106125335760405162461bcd60e51b8152602060048201526014602482015273427261636b6574206f7574206f662072616e676560601b604482015260640161098a565b60008686838181106125475761254761356f565b90506020020135905080600d60008a815260200190815260200160002060190154116125a95760405162461bcd60e51b81526020600482015260116024820152700a8d2c6d6cae892c840e8dede40d0d2ced607b1b604482015260640161098a565b6000888152600d60205260409020601801548110156125fd5760405162461bcd60e51b815260206004820152601060248201526f5469636b6574496420746f6f206c6f7760801b604482015260640161098a565b6000818152600e602052604090205464010000000090046001600160a01b0316331461265b5760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b604482015260640161098a565b6000818152600e602052604081208054640100000000600160c01b03191690556126ac89838888878181106126925761269261356f565b90506020020160208101906126a7919061360c565b612a6f565b9050806126fb5760405162461bcd60e51b815260206004820152601960248201527f4e6f207072697a6520666f72207468697320627261636b657400000000000000604482015260640161098a565b85858481811061270d5761270d61356f565b9050602002016020810190612722919061360c565b63ffffffff166005146127ac5761276689838888878181106127465761274661356f565b905060200201602081019061275b919061360c565b6126a7906001613662565b156127ac5760405162461bcd60e51b8152602060048201526016602482015275213930b1b5b2ba1036bab9ba103132903434b3b432b960511b604482015260640161098a565b6127b68185613557565b9350505080806127c590613585565b9150506124b8565b50600b546127e5906001600160a01b03163383612b7a565b6040805182815260208101869052879133917f0f5fca62da8fb5d95525b49e5eaa7b20bc6bd9e2f6b64b493442d1c0bd6ef486910160405180910390a35050600160005550505050565b6001546001600160a01b031633146128595760405162461bcd60e51b815260040161098a906135a0565b6001600160a01b03831661287f5760405162461bcd60e51b815260040161098a90613892565b6001600160a01b0382166128a55760405162461bcd60e51b815260040161098a90613892565b6001600160a01b0381166128cb5760405162461bcd60e51b815260040161098a90613892565b600380546001600160a01b038581166001600160a01b0319928316811790935560048054868316908416811790915560028054928616929093168217909255604080519384526020840192909252908201527f3e945b7660001d46cfd5e729545f7f0b6c65bdee54066a91c7acad703f1b731e9060600160405180910390a1505050565b6001546001600160a01b031633146129795760405162461bcd60e51b815260040161098a906135a0565b808211156129c95760405162461bcd60e51b815260206004820152601b60248201527f6d696e5072696365206d757374206265203c206d617850726963650000000000604482015260640161098a565b600991909155600855565b6001546001600160a01b031633146129fe5760405162461bcd60e51b815260040161098a906135a0565b6001600160a01b038116612a635760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161098a565b612a6c81612c20565b50565b6000838152600d60209081526040808320601b0154858452600e90925282205463ffffffff918216911682612aa5856001613662565b612ab090600a613851565b612aba908361363f565b63ffffffff8087166000908152600f6020526040902054612adc929116613662565b90506000612aeb866001613662565b612af690600a613851565b612b00908561363f565b63ffffffff8088166000908152600f6020526040902054612b22929116613662565b90508063ffffffff168263ffffffff161415612b6d576000888152600d60205260409020600c0163ffffffff871660068110612b6057612b6061356f565b0154945050505050610959565b6000945050505050610959565b6040516001600160a01b038316602482015260448101829052612bdd90849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612ca9565b505050565b6040516001600160a01b0380851660248301528316604482015260648101829052612c1a9085906323b872dd60e01b90608401612ba6565b50505050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60008382612c81826001613557565b612c8b919061352a565b612c9584866136e6565b612c9f91906136e6565b6109569190613705565b6000612cfe826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d7b9092919063ffffffff16565b805190915015612bdd5780806020019051810190612d1c91906138c2565b612bdd5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b606482015260840161098a565b6060610956848460008585843b612dd45760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161098a565b600080866001600160a01b03168587604051612df0919061390b565b60006040518083038185875af1925050503d8060008114612e2d576040519150601f19603f3d011682016040523d82523d6000602084013e612e32565b606091505b5091509150612e42828286612e4d565b979650505050505050565b60608315612e5c575081610959565b825115612e6c5782518084602001fd5b8160405162461bcd60e51b815260040161098a9190613927565b604080516101a08101909152806000815260200160008152602001600081526020016000815260200160008152602001612ebe612f45565b815260200160008152602001612ed2612f45565b8152602001612edf612f45565b8152602001600081526020016000815260200160008152602001600063ffffffff1681525090565b8260068101928215612f35579160200282015b82811115612f35578251825591602001919060010190612f1a565b50612f41929150612f63565b5090565b6040518060c001604052806006906020820280368337509192915050565b5b80821115612f415760008155600101612f64565b80356001600160a01b0381168114612f8f57600080fd5b919050565b60008060008060808587031215612faa57600080fd5b612fb385612f78565b966020860135965060408601359560600135945092505050565b600081518084526020808501945080840160005b8381101561300357815163ffffffff1687529582019590820190600101612fe1565b509495945050505050565b600081518084526020808501945080840160005b83811015613003578151151587529582019590820190600101613022565b6080808252855190820181905260009060209060a0840190828901845b828110156130795781518452928401929084019060010161305d565b5050508381038285015261308d8188612fcd565b91505082810360408401526130a2818661300e565b91505082606083015295945050505050565b6000602082840312156130c657600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b6004811061310157634e487b7160e01b600052602160045260246000fd5b9052565b8060005b6006811015612c1a578151845260209384019390910190600101613109565b60006103808201905061313c8284516130e3565b6020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015161317660a0840182613105565b5060c0830151610160818185015260e0850151915061018061319a81860184613105565b61010086015192506131b0610240860184613105565b6101208601516103008601526101408601516103208601529085015161034085015284015163ffffffff811661036085015290505092915050565b63ffffffff81168114612a6c57600080fd5b60008060006060848603121561321257600080fd5b8335925060208401359150604084013561322b816131eb565b809150509250925092565b6000806040838503121561324957600080fd5b61325283612f78565b946020939093013593505050565b6000806040838503121561327357600080fd5b50508035926020909101359150565b60008083601f84011261329457600080fd5b50813567ffffffffffffffff8111156132ac57600080fd5b6020830191508360208260051b850101111561139d57600080fd5b6000806000604084860312156132dc57600080fd5b83359250602084013567ffffffffffffffff8111156132fa57600080fd5b61330686828701613282565b9497909650939450505050565b6000806020838503121561332657600080fd5b823567ffffffffffffffff81111561333d57600080fd5b61334985828601613282565b90969095509350505050565b6040815260006133686040830185612fcd565b828103602084015261337a818561300e565b95945050505050565b60006020828403121561339557600080fd5b61095982612f78565b600080600080600061014086880312156133b757600080fd5b8535945060208601359350604086013592506101208601878111156133db57600080fd5b94979396509194606001933592915050565b8015158114612a6c57600080fd5b6000806040838503121561340e57600080fd5b823591506020830135613420816133ed565b809150509250929050565b60008060006060848603121561344057600080fd5b505081359360208301359350604090920135919050565b60008060008060006060868803121561346f57600080fd5b85359450602086013567ffffffffffffffff8082111561348e57600080fd5b61349a89838a01613282565b909650945060408801359150808211156134b357600080fd5b506134c088828901613282565b969995985093965092949392505050565b6000806000606084860312156134e657600080fd5b6134ef84612f78565b92506134fd60208501612f78565b915061350b60408501612f78565b90509250925092565b634e487b7160e01b600052601160045260246000fd5b60008282101561353c5761353c613514565b500390565b634e487b7160e01b600052604160045260246000fd5b6000821982111561356a5761356a613514565b500190565b634e487b7160e01b600052603260045260246000fd5b600060001982141561359957613599613514565b5060010190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006020828403121561361e57600080fd5b8135610959816131eb565b634e487b7160e01b600052601260045260246000fd5b600063ffffffff8084168061365657613656613629565b92169190910692915050565b600063ffffffff80831681851680830382111561368157613681613514565b01949350505050565b60006020828403121561369c57600080fd5b8151610959816131eb565b6020808252600c908201526b2737ba1037b832b930ba37b960a11b604082015260600190565b6000602082840312156136df57600080fd5b5051919050565b600081600019048311821515161561370057613700613514565b500290565b60008261371457613714613629565b500490565b600063ffffffff8381169083168181101561373657613736613514565b039392505050565b600181815b8085111561377b578163ffffffff0482111561376157613761613514565b8085161561376e57918102915b93841c9390800290613743565b509250929050565b6000826137925750600161384b565b8161379f5750600061384b565b81600181146137b557600281146137bf576137f0565b600191505061384b565b60ff8411156137d0576137d0613514565b6001841b915063ffffffff8211156137ea576137ea613514565b5061384b565b5060208310610133831016604e8410600b8410161715613827575081810a63ffffffff81111561382257613822613514565b61384b565b613831838361373e565b8063ffffffff0482111561384757613847613514565b0290505b92915050565b600063ffffffff613866818516828516613783565b949350505050565b600063ffffffff8083168181141561388857613888613514565b6001019392505050565b60208082526016908201527543616e6e6f74206265207a65726f206164647265737360501b604082015260600190565b6000602082840312156138d457600080fd5b8151610959816133ed565b60005b838110156138fa5781810151838201526020016138e2565b83811115612c1a5750506000910152565b6000825161391d8184602087016138df565b9190910192915050565b60208152600082518060208401526139468160408501602087016138df565b601f01601f1916919091016040019291505056fea2646970667358221220ea18104af68b228283d30fb69fc2b1539987de01a8a044aa72b4ad996d6ffdb464736f6c63430008090033000000000000000000000000afc9aa5ebd7197662d869f75890f18aafeefb1f50000000000000000000000002643afdf600bcdfe720e1077d627c1bc620b9741

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000afc9aa5ebd7197662d869f75890f18aafeefb1f50000000000000000000000002643afdf600bcdfe720e1077d627c1bc620b9741

-----Decoded View---------------
Arg [0] : _javaTokenAddress (address): 0xafc9aa5ebd7197662d869f75890f18aafeefb1f5
Arg [1] : _randomGeneratorAddress (address): 0x2643afdf600bcdfe720e1077d627c1bc620b9741

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000afc9aa5ebd7197662d869f75890f18aafeefb1f5
Arg [1] : 0000000000000000000000002643afdf600bcdfe720e1077d627c1bc620b9741


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.