ETH Price: $1,948.55 (-0.73%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Init128727552021-07-21 23:27:291684 days ago1626910049IN
0x4be937b3...A399EfAb7
0 ETH0.0010853511

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MovieVotingMasterChef

Compiler Version
v0.6.2+commit.bacdbe57

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT
pragma solidity 0.6.2;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./matic/BasicMetaTransaction.sol";

contract MovieVotingMasterChef is BasicMetaTransaction, AccessControl {
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    bytes32 public constant ROLE_ADMIN = keccak256("ROLE_ADMIN");

    // Info of each user.
    struct UserInfo {
        uint256 amount; // how many Stars the user has provided.
        uint256 rewardDebt; // reward debt. See explaination below.
        uint256 penalizedRewards; // rewards that got penalized when users withdraw prematurely
        //
        // We do some fancy math here. Basically, any point in time, the amount of Stars
        // entitled to a user but is pending to be distributed is:
        //
        //   pending reward = (user.amount * pool.accStarsPerShare) - user.rewardDebt
        //
        // Whenever a user deposits or withdraws Stars to the pool. Here's what happens:
        //   1. The pool's `accStarsPerShare` (and `lastRewardBlock`) gets updated.
        //   2. User receives the pending reward sent to his/her address.
        //   3. User's `amount` gets updated.
        //   4. User's `rewardDebt` gets updated.
    }

    struct PoolInfo {
        uint256 lastRewardBlock; // Last block number that Stars distribution occurs.
        uint256 accStarsPerShare; // Accumulated Stars per share, times ACC_STARS_PRECISION. See below.
        uint256 poolSupply; // the the total amount of Stars in the pool.
        uint256 rewardAmount; // the amount of Stars to give out as rewards.
        uint256 rewardAmountPerBlock; // the amount of Stars to give out as rewards per block.
        uint256 startBlock; // staking start block.
        uint256 endBlock; // staking end block.
    }

    bool public initialized;
    uint256 private constant ACC_STARS_PRECISION = 1e12;
    // The movie voting contract.
    address public movieVoting;
    // The Stars token.
    IERC20 public stars;
    // Info of each pool.
    PoolInfo[] public poolInfo;
    // Info of each user that stakes tokens.
    mapping(uint256 => mapping(address => UserInfo)) public userInfo;

    event RewardsCollected(address indexed user, uint256 indexed pid);
    event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
    event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
    event WithdrawPartial(
        address indexed user,
        uint256 indexed pid,
        uint256 amount
    );
    event EmergencyWithdraw(
        address indexed user,
        uint256 indexed pid,
        uint256 amount
    );

    modifier onlyAdmin {
        require(hasRole(ROLE_ADMIN, msg.sender), "Sender is not admin");
        _;
    }

    modifier isInitialized {
        require(initialized, "Not initialized");
        _;
    }

    /**
     * @dev Stores the Stars contract, and allows users with the admin role to
     * grant/revoke the admin role from other users.
     *
     * Params:
     * starsAddress: the address of the Stars contract.
     * _admin: the address of the first admin.
     */
    constructor(address starsAddress, address _admin) public {
        _setupRole(ROLE_ADMIN, _admin);
        _setRoleAdmin(ROLE_ADMIN, ROLE_ADMIN);

        stars = IERC20(starsAddress);
    }

    /**
     * @dev Sets the Movie Voting contract address.
     *
     * Params:
     * _movieVotingAddress: the Movie Voting contract address.
     *
     * Requirements:
     * - contract must not be initialized.
     */
    function init(address _movieVotingAddress) external onlyAdmin {
        require(!initialized, "Already initialized");
        movieVoting = _movieVotingAddress;
        _setupRole(ROLE_ADMIN, _movieVotingAddress);

        initialized = true;
    }

    /**
     * @dev Returns the number of pools there are for front-end.
     */
    function poolLength() external view returns (uint256) {
        return poolInfo.length;
    }

    /**
     * @dev Adds a new pool. Admin only.
     *
     * Params:
     * _startBlock: the staking start block.
     * _endBlock: the staking end block.
     * _rewardAmount: the total stars the distribute in this pool.
     * _withUpdate: whether or not to update all pools.
     *
     * Requirements:
     * - Start block number must be a future block.
     */
    function add(
        uint256 _startBlock,
        uint256 _endBlock,
        uint256 _rewardAmount,
        bool _withUpdate
    ) external onlyAdmin isInitialized {
        require(
            block.number < _startBlock,
            "Start block number must be a future block"
        );

        if (_withUpdate) {
            massUpdatePools();
        }
        stars.transferFrom(msgSender(), address(this), _rewardAmount);

        poolInfo.push(
            PoolInfo({
                lastRewardBlock: _startBlock,
                accStarsPerShare: 0,
                poolSupply: 0,
                rewardAmount: _rewardAmount,
                rewardAmountPerBlock: _rewardAmount.div(
                    _endBlock.sub(_startBlock)
                ),
                startBlock: _startBlock,
                endBlock: _endBlock
            })
        );
    }

    /**
     * @dev View function to see pending Stars on frontend.
     *
     * Params:
     * _pid: the pool id.
     * _user: address of the stars to view the pending rewards for.
     */
    function pendingStars(uint256 _pid, address _user)
        external
        view
        isInitialized
        returns (uint256)
    {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_user];

        if (pool.poolSupply == 0 || block.number < pool.startBlock) {
            return 0;
        }

        uint256 currRateEndStarsPerShare = accStarsPerShareAtCurrRate(
            uint256(block.number).sub(pool.startBlock),
            pool.rewardAmountPerBlock,
            pool.poolSupply,
            pool.startBlock,
            pool.endBlock
        );
        uint256 currRateStartStarsPerShare = accStarsPerShareAtCurrRate(
            pool.lastRewardBlock.sub(pool.startBlock),
            pool.rewardAmountPerBlock,
            pool.poolSupply,
            pool.startBlock,
            pool.endBlock
        );
        uint256 starsReward = (
            currRateEndStarsPerShare.sub(currRateStartStarsPerShare)
        );

        uint256 pendingAccStarsPerShare = pool.accStarsPerShare.add(
            starsReward
        );
        return
            user
                .amount
                .mul(pendingAccStarsPerShare)
                .div(ACC_STARS_PRECISION)
                .sub(user.rewardDebt)
                .add(user.penalizedRewards);
    }

    /**
     * @dev An internal function to calculate the total accumulated Stars per
     * share, assuming the stars per share remained the same since staking
     * began.
     *
     * Params:
     * blocks: The number of blocks to calculate for.
     * rewardAmountPerBlock: amount of Stars to reward per block.
     * poolSupply: total number of Stars in the pool.
     * startBlock: the staking start block.
     * endBlock: the staking end block.
     */
    function accStarsPerShareAtCurrRate(
        uint256 blocks,
        uint256 rewardAmountPerBlock,
        uint256 poolSupply,
        uint256 startBlock,
        uint256 endBlock
    ) public pure returns (uint256) {
        if (blocks > endBlock.sub(startBlock)) {
            return
                rewardAmountPerBlock
                    .mul(endBlock.sub(startBlock))
                    .mul(ACC_STARS_PRECISION)
                    .div(poolSupply);
        } else {
            return
                blocks.mul(rewardAmountPerBlock).mul(ACC_STARS_PRECISION).div(
                    poolSupply
                );
        }
    }

    /**
     * @dev A function for the front-end to see information about the current
     rewards.
     * Params:
     * pid: The pool id.
     */
    function starsPerBlock(uint256 pid) external view returns (uint256 amount) {
        return poolInfo[pid].rewardAmountPerBlock;
    }

    /**
     * @dev Calculates the additional stars per share that have been accumulated
     * since lastRewardBlock, and updates accStarsPerShare and lastRewardBlock
     * accordingly.
     */
    function updatePool(uint256 _pid) public isInitialized {
        PoolInfo storage pool = poolInfo[_pid];
        if (block.number <= pool.lastRewardBlock) {
            return;
        }
        if (pool.poolSupply != 0) {
            uint256 currRateEndStarsPerShare = accStarsPerShareAtCurrRate(
                uint256(block.number).sub(pool.startBlock),
                pool.rewardAmountPerBlock,
                pool.poolSupply,
                pool.startBlock,
                pool.endBlock
            );
            uint256 currRateStartStarsPerShare = accStarsPerShareAtCurrRate(
                pool.lastRewardBlock.sub(pool.startBlock),
                pool.rewardAmountPerBlock,
                pool.poolSupply,
                pool.startBlock,
                pool.endBlock
            );
            uint256 starsReward = (
                currRateEndStarsPerShare.sub(currRateStartStarsPerShare)
            );

            pool.accStarsPerShare = pool.accStarsPerShare.add(starsReward);
        }
        pool.lastRewardBlock = block.number;
    }

    // Update reward vairables for all pools. Be careful of gas spending!
    function massUpdatePools() public isInitialized {
        uint256 length = poolInfo.length;
        for (uint256 pid = 0; pid < length; ++pid) {
            updatePool(pid);
        }
    }

    /**
     * @dev Deposit stars for staking. The sender's information is updated accordingly.
     *
     * Params:
     * _pid: the pool id.
     * _amount: amount of Stars to deposit.
     * _staker: the staker's address.
     *
     * Requirements:
     * - the current block must have reached the pools start block.
     */
    function deposit(
        uint256 _pid,
        uint256 _amount,
        address _staker
    ) external onlyAdmin isInitialized {
        PoolInfo storage pool = poolInfo[_pid];

        require(block.number >= pool.startBlock, "Deposit not started");

        UserInfo storage user = userInfo[_pid][_staker];
        updatePool(_pid);

        user.amount = user.amount.add(_amount);
        user.rewardDebt = user.rewardDebt.add(
            (_amount.mul(pool.accStarsPerShare).div(ACC_STARS_PRECISION))
        );
        pool.poolSupply = pool.poolSupply.add(_amount);

        stars.safeTransferFrom(_staker, address(this), _amount);

        emit Deposit(_staker, _pid, _amount);
    }

    /**
     * @dev Withdraw all of the staker's stars from staking. The sender's information is updated accordingly.
     *
     * Params:
     * _pid: the pool id.
     * _staker: the staker's address.
     *
     * Requirements:
     * - the current block must have reached the pools start block.
     */
    function withdraw(uint256 _pid, address _staker)
        external
        onlyAdmin
        isInitialized
    {
        PoolInfo storage pool = poolInfo[_pid];
        require(
            block.number > pool.endBlock,
            "Cannot withdraw before voting period ends"
        );
        UserInfo storage user = userInfo[_pid][_staker];

        updatePool(_pid);

        uint256 _amount = user.amount;
        uint256 _penalizedRewards = user.penalizedRewards;

        uint256 pending = user
        .amount
        .mul(pool.accStarsPerShare)
        .div(ACC_STARS_PRECISION)
        .sub(user.rewardDebt);

        user.amount = 0;
        user.rewardDebt = 0;
        user.penalizedRewards = 0;
        pool.poolSupply = pool.poolSupply.sub(_amount);

        safeStarsTransfer(_staker, pending.add(_amount).add(_penalizedRewards));

        emit Withdraw(_staker, _pid, _amount);
    }

    function withdrawPartial(
        uint256 _pid,
        uint256 _amount,
        address _staker
    ) external onlyAdmin isInitialized {
        PoolInfo storage pool = poolInfo[_pid];

        UserInfo storage user = userInfo[_pid][_staker];

        require(user.amount >= _amount, "Insufficient STARS to withdraw");

        updatePool(_pid);

        uint256 pending = user
        .amount
        .mul(pool.accStarsPerShare)
        .div(ACC_STARS_PRECISION)
        .sub(user.rewardDebt);

        uint256 oldUserAmount = user.amount;

        if (_amount > 0) {
            user.amount = user.amount.sub(_amount);
            safeStarsTransfer(_staker, _amount);
            user.penalizedRewards = user
            .penalizedRewards
            .mul(user.amount)
            .div(oldUserAmount)
            .add(pending.mul(user.amount).div(oldUserAmount));
            pool.poolSupply = pool.poolSupply.sub(_amount);
        }

        user.rewardDebt = (
            user.amount.mul(pool.accStarsPerShare).div(ACC_STARS_PRECISION)
        );

        emit WithdrawPartial(_staker, _pid, _amount);
    }

    /**
     * @dev Withdraw without caring about rewards.
     *
     * Params:
     * _pid: the pool id.
     * _staker: the staker's address.
     *
     */
    function emergencyWithdraw(uint256 _pid, address _staker)
        external
        onlyAdmin
        isInitialized
    {
        PoolInfo storage pool = poolInfo[_pid];
        UserInfo storage user = userInfo[_pid][_staker];

        stars.safeTransfer(_staker, user.amount);

        pool.poolSupply = pool.poolSupply.sub(user.amount);
        user.amount = 0;
        user.rewardDebt = 0;

        emit EmergencyWithdraw(_staker, _pid, user.amount);
    }

    /**
     * @dev Safe Stars transfer function, just in case if rounding error causes
     * pool to not have enough Stars. Transaction gas fee on additional checks
     * will be more expensive than the possible rounding profit itself.
     *
     * Params:
     * _to: address to send Stars to.
     * _amount: amount of Stars to send.
     */
    function safeStarsTransfer(address _to, uint256 _amount) internal {
        uint256 starsBal = stars.balanceOf(address(this));
        if (_amount > starsBal) {
            stars.transfer(_to, starsBal);
        } else {
            stars.transfer(_to, _amount);
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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);
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20.sol";
import "../../math/SafeMath.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 SafeMath for uint256;
    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'
        // solhint-disable-next-line max-line-length
        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).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _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
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

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

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

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

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context {
    using EnumerableSet for EnumerableSet.AddressSet;
    using Address for address;

    struct RoleData {
        EnumerableSet.AddressSet members;
        bytes32 adminRole;
    }

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view returns (bool) {
        return _roles[role].members.contains(account);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view returns (uint256) {
        return _roles[role].members.length();
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
        return _roles[role].members.at(index);
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");

        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");

        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
        _roles[role].adminRole = adminRole;
    }

    function _grantRole(bytes32 role, address account) private {
        if (_roles[role].members.add(account)) {
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (_roles[role].members.remove(account)) {
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

pragma solidity 0.6.2;

import "@openzeppelin/contracts/math/SafeMath.sol";

contract BasicMetaTransaction {
    using SafeMath for uint256;

    event MetaTransactionExecuted(
        address userAddress,
        address payable relayerAddress,
        bytes functionSignature
    );
    mapping(address => uint256) private nonces;

    function getChainID() public pure returns (uint256) {
        uint256 id;
        assembly {
            id := chainid()
        }
        return id;
    }

    /**
     * Main function to be called when user wants to execute meta transaction.
     * The actual function to be called should be passed as param with name functionSignature
     * Here the basic signature recovery is being used. Signature is expected to be generated using
     * personal_sign method.
     * @param userAddress Address of user trying to do meta transaction
     * @param functionSignature Signature of the actual function to be called via meta transaction
     * @param sigR R part of the signature
     * @param sigS S part of the signature
     * @param sigV V part of the signature
     */
    function executeMetaTransaction(
        address userAddress,
        bytes calldata functionSignature,
        bytes32 sigR,
        bytes32 sigS,
        uint8 sigV
    ) external payable returns (bytes memory) {
        require(
            verify(
                userAddress,
                nonces[userAddress],
                getChainID(),
                functionSignature,
                sigR,
                sigS,
                sigV
            ),
            "Signer and signature do not match"
        );
        nonces[userAddress] = nonces[userAddress].add(1);

        // Append userAddress at the end to extract it from calling context
        (bool success, bytes memory returnData) =
            address(this).call(
                abi.encodePacked(functionSignature, userAddress)
            );

        require(success, "Function call not successful");
        emit MetaTransactionExecuted(
            userAddress,
            msg.sender,
            functionSignature
        );
        return returnData;
    }

    function getNonce(address user) external view returns (uint256 nonce) {
        nonce = nonces[user];
    }

    // Builds a prefixed hash to mimic the behavior of eth_sign.
    function prefixed(bytes32 hash) internal pure returns (bytes32) {
        return
            keccak256(
                abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)
            );
    }

    function verify(
        address owner,
        uint256 nonce,
        uint256 chainID,
        bytes memory functionSignature,
        bytes32 sigR,
        bytes32 sigS,
        uint8 sigV
    ) public view returns (bool) {
        bytes32 hash =
            prefixed(
                keccak256(
                    abi.encodePacked(nonce, this, chainID, functionSignature)
                )
            );
        address signer = ecrecover(hash, sigV, sigR, sigS);
        require(signer != address(0), "Invalid signature");
        return (owner == signer);
    }

    function msgSender() internal view returns (address sender) {
        if (msg.sender == address(this)) {
            bytes memory array = msg.data;
            uint256 index = msg.data.length;
            assembly {
                // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those.
                sender := and(
                    mload(add(array, index)),
                    0xffffffffffffffffffffffffffffffffffffffff
                )
            }
        } else {
            return msg.sender;
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <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;
        // solhint-disable-next-line no-inline-assembly
        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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (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");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"starsAddress","type":"address"},{"internalType":"address","name":"_admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"address payable","name":"relayerAddress","type":"address"},{"indexed":false,"internalType":"bytes","name":"functionSignature","type":"bytes"}],"name":"MetaTransactionExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"RewardsCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawPartial","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"blocks","type":"uint256"},{"internalType":"uint256","name":"rewardAmountPerBlock","type":"uint256"},{"internalType":"uint256","name":"poolSupply","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"}],"name":"accStarsPerShareAtCurrRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_startBlock","type":"uint256"},{"internalType":"uint256","name":"_endBlock","type":"uint256"},{"internalType":"uint256","name":"_rewardAmount","type":"uint256"},{"internalType":"bool","name":"_withUpdate","type":"bool"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_staker","type":"address"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_staker","type":"address"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"bytes","name":"functionSignature","type":"bytes"},{"internalType":"bytes32","name":"sigR","type":"bytes32"},{"internalType":"bytes32","name":"sigS","type":"bytes32"},{"internalType":"uint8","name":"sigV","type":"uint8"}],"name":"executeMetaTransaction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getChainID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getNonce","outputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_movieVotingAddress","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"massUpdatePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"movieVoting","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"pendingStars","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolInfo","outputs":[{"internalType":"uint256","name":"lastRewardBlock","type":"uint256"},{"internalType":"uint256","name":"accStarsPerShare","type":"uint256"},{"internalType":"uint256","name":"poolSupply","type":"uint256"},{"internalType":"uint256","name":"rewardAmount","type":"uint256"},{"internalType":"uint256","name":"rewardAmountPerBlock","type":"uint256"},{"internalType":"uint256","name":"startBlock","type":"uint256"},{"internalType":"uint256","name":"endBlock","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stars","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"starsPerBlock","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"},{"internalType":"uint256","name":"penalizedRewards","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"chainID","type":"uint256"},{"internalType":"bytes","name":"functionSignature","type":"bytes"},{"internalType":"bytes32","name":"sigR","type":"bytes32"},{"internalType":"bytes32","name":"sigS","type":"bytes32"},{"internalType":"uint8","name":"sigV","type":"uint8"}],"name":"verify","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_staker","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_staker","type":"address"}],"name":"withdrawPartial","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162002dab38038062002dab833981810160405260408110156200003757600080fd5b50805160209091015160408051692927a622afa0a226a4a760b11b8152905190819003600a0190206200007490826001600160e01b03620000e016565b60408051692927a622afa0a226a4a760b11b808252825191829003600a90810183209183529251918290039092019020620000b991906001600160e01b03620000f916565b50600380546001600160a01b0319166001600160a01b03929092169190911790556200026c565b620000f582826001600160e01b036200014b16565b5050565b600082815260016020526040808220600201549051839285917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a460009182526001602052604090912060020155565b600082815260016020908152604090912062000172918390620024db620001cf821b17901c565b15620000f5576200018b6001600160e01b03620001f816565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000620001ef836001600160a01b0384166001600160e01b03620001fc16565b90505b92915050565b3390565b60006200021383836001600160e01b036200025416565b6200024b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620001f2565b506000620001f2565b60009081526001919091016020526040902054151590565b612b2f806200027c6000396000f3fe6080604052600436106101cc5760003560e01c8063564b81ef116100f75780639010d07c11610095578063a217fddf11610064578063a217fddf14610895578063ca15c873146108aa578063d391014b146108d4578063d547741f146108e9576101cc565b80639010d07c1461079c57806391d14854146107cc57806393f1a40b14610805578063982669eb1461085c576101cc565b80636b5afed2116100d15780636b5afed2146106c8578063851b5d5a1461070a5780638dbdbe6d146107485780638eb9c0a014610787576101cc565b8063564b81ef146105c15780636281133d146105d6578063630b5ba1146106b3576101cc565b806319ab453c1161016f5780632f940c701161013e5780632f940c70146104fb57806336568abe146105345780633a9de2ed1461056d57806351eb05a614610597576101cc565b806319ab453c14610432578063248a9ca3146104655780632d0335ab1461048f5780632f2ff15d146104c2576101cc565b80630dd5b3c5116101ab5780630dd5b3c5146103375780630f185cbc146103685780631526fe27146103a7578063158ef93e14610409576101cc565b8062f714ce146101d1578063081e3eda1461020c5780630c53c51c14610233575b600080fd5b3480156101dd57600080fd5b5061020a600480360360408110156101f457600080fd5b50803590602001356001600160a01b0316610922565b005b34801561021857600080fd5b50610221610b55565b60408051918252519081900360200190f35b6102c2600480360360a081101561024957600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561027457600080fd5b82018360208201111561028657600080fd5b803590602001918460018302840111640100000000831117156102a857600080fd5b91935091508035906020810135906040013560ff16610b5c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102fc5781810151838201526020016102e4565b50505050905090810190601f1680156103295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561034357600080fd5b5061034c610e1d565b604080516001600160a01b039092168252519081900360200190f35b34801561037457600080fd5b5061020a6004803603606081101561038b57600080fd5b50803590602081013590604001356001600160a01b0316610e2c565b3480156103b357600080fd5b506103d1600480360360208110156103ca57600080fd5b50356110a6565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b34801561041557600080fd5b5061041e6110f5565b604080519115158252519081900360200190f35b34801561043e57600080fd5b5061020a6004803603602081101561045557600080fd5b50356001600160a01b03166110fe565b34801561047157600080fd5b506102216004803603602081101561048857600080fd5b5035611217565b34801561049b57600080fd5b50610221600480360360208110156104b257600080fd5b50356001600160a01b031661122c565b3480156104ce57600080fd5b5061020a600480360360408110156104e557600080fd5b50803590602001356001600160a01b0316611247565b34801561050757600080fd5b5061020a6004803603604081101561051e57600080fd5b50803590602001356001600160a01b03166112b3565b34801561054057600080fd5b5061020a6004803603604081101561055757600080fd5b50803590602001356001600160a01b0316611434565b34801561057957600080fd5b506102216004803603602081101561059057600080fd5b5035611495565b3480156105a357600080fd5b5061020a600480360360208110156105ba57600080fd5b50356114bd565b3480156105cd57600080fd5b506102216115ec565b3480156105e257600080fd5b5061041e600480360360e08110156105f957600080fd5b6001600160a01b03823516916020810135916040820135919081019060808101606082013564010000000081111561063057600080fd5b82018360208201111561064257600080fd5b8035906020019184600183028401116401000000008311171561066457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550508235935050506020810135906040013560ff166115f0565b3480156106bf57600080fd5b5061020a61176f565b3480156106d457600080fd5b50610221600480360360a08110156106eb57600080fd5b50803590602081013590604081013590606081013590608001356117d7565b34801561071657600080fd5b5061020a6004803603608081101561072d57600080fd5b50803590602081013590604081013590606001351515611856565b34801561075457600080fd5b5061020a6004803603606081101561076b57600080fd5b50803590602081013590604001356001600160a01b0316611ab0565b34801561079357600080fd5b5061034c611cd0565b3480156107a857600080fd5b5061034c600480360360408110156107bf57600080fd5b5080359060200135611ce4565b3480156107d857600080fd5b5061041e600480360360408110156107ef57600080fd5b50803590602001356001600160a01b0316611d0b565b34801561081157600080fd5b5061083e6004803603604081101561082857600080fd5b50803590602001356001600160a01b0316611d29565b60408051938452602084019290925282820152519081900360600190f35b34801561086857600080fd5b506102216004803603604081101561087f57600080fd5b50803590602001356001600160a01b0316611d55565b3480156108a157600080fd5b50610221611ecc565b3480156108b657600080fd5b50610221600480360360208110156108cd57600080fd5b5035611ed1565b3480156108e057600080fd5b50610221611ee8565b3480156108f557600080fd5b5061020a6004803603604081101561090c57600080fd5b50803590602001356001600160a01b0316611f0a565b60408051692927a622afa0a226a4a760b11b8152905190819003600a01902061094b9033611d0b565b610992576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff166109db576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b6000600483815481106109ea57fe5b9060005260206000209060070201905080600601544311610a3c5760405162461bcd60e51b8152600401808060200182810382526029815260200180612a786029913960400191505060405180910390fd5b60008381526005602090815260408083206001600160a01b03861684529091529020610a67846114bd565b8054600282015460018084015490850154600091610ab391610aa79064e8d4a5100090610a9b90889063ffffffff611f6316565b9063ffffffff611fbc16565b9063ffffffff61202316565b600080865560018601819055600280870191909155860154909150610ade908463ffffffff61202316565b6002860155610b0c86610b0784610afb858863ffffffff61208016565b9063ffffffff61208016565b6120da565b60408051848152905188916001600160a01b038916917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689181900360200190a350505050505050565b6004545b90565b6001600160a01b038616600090815260208190526040902054606090610bc7908890610b866115ec565b89898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b92508a91508990506115f0565b610c025760405162461bcd60e51b8152600401808060200182810382526021815260200180612a2e6021913960400191505060405180910390fd5b6001600160a01b038716600090815260208190526040902054610c2c90600163ffffffff61208016565b600080896001600160a01b03166001600160a01b031681526020019081526020016000208190555060006060306001600160a01b031688888b6040516020018084848082843780830192505050826001600160a01b03166001600160a01b031660601b815260140193505050506040516020818303038152906040526040518082805190602001908083835b60208310610cd75780518252601f199092019160209182019101610cb8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610d39576040519150601f19603f3d011682016040523d82523d6000602084013e610d3e565b606091505b509150915081610d95576040805162461bcd60e51b815260206004820152601c60248201527f46756e6374696f6e2063616c6c206e6f74207375636365737366756c00000000604482015290519081900360640190fd5b604080516001600160a01b038b168152336020820181905260609282018381529282018a90527f5845892132946850460bff5a0083f71031bc5bf9aadcd40f1de79423eac9b10b928c928c918c919060808201848480828437600083820152604051601f909101601f191690920182900397509095505050505050a198975050505050505050565b6003546001600160a01b031681565b60408051692927a622afa0a226a4a760b11b8152905190819003600a019020610e559033611d0b565b610e9c576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff16610ee5576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b600060048481548110610ef457fe5b600091825260208083208784526005825260408085206001600160a01b03881686529092529220805460079092029092019250841115610f7b576040805162461bcd60e51b815260206004820152601e60248201527f496e73756666696369656e7420535441525320746f2077697468647261770000604482015290519081900360640190fd5b610f84856114bd565b6000610fb28260010154610aa764e8d4a51000610a9b87600101548760000154611f6390919063ffffffff16565b82549091508515611037578254610fcf908763ffffffff61202316565b8355610fdb85876120da565b611015610ff982610a9b866000015486611f6390919063ffffffff16565b84546002860154610afb918591610a9b9163ffffffff611f6316565b600280850191909155840154611031908763ffffffff61202316565b60028501555b600184015483546110589164e8d4a5100091610a9b9163ffffffff611f6316565b600184015560408051878152905188916001600160a01b038816917f680dd80a97d6492f92e0452d2304446b3feaafe9ecca87a130cdc09018b4ed1d9181900360200190a350505050505050565b600481815481106110b357fe5b90600052602060002090600702016000915090508060000154908060010154908060020154908060030154908060040154908060050154908060060154905087565b60025460ff1681565b60408051692927a622afa0a226a4a760b11b8152905190819003600a0190206111279033611d0b565b61116e576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff16156111bc576040805162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604482015290519081900360640190fd5b600280546001600160a01b03831661010002610100600160a81b031990911617905560408051692927a622afa0a226a4a760b11b8152905190819003600a01902061120790826112a5565b506002805460ff19166001179055565b60009081526001602052604090206002015490565b6001600160a01b031660009081526020819052604090205490565b60008281526001602052604090206002015461126a9061126561226b565b611d0b565b6112a55760405162461bcd60e51b815260040180806020018281038252602f815260200180612988602f913960400191505060405180910390fd5b6112af828261226f565b5050565b60408051692927a622afa0a226a4a760b11b8152905190819003600a0190206112dc9033611d0b565b611323576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff1661136c576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b60006004838154811061137b57fe5b600091825260208083208684526005825260408085206001600160a01b0380891687529352909320805460035460079094029094019450926113c89290911690859063ffffffff6122de16565b805460028301546113de9163ffffffff61202316565b6002830155600080825560018201819055604080519182525185916001600160a01b038616917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959181900360200190a350505050565b61143c61226b565b6001600160a01b0316816001600160a01b03161461148b5760405162461bcd60e51b815260040180806020018281038252602f815260200180612acb602f913960400191505060405180910390fd5b6112af8282612330565b6000600482815481106114a457fe5b9060005260206000209060070201600401549050919050565b60025460ff16611506576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b60006004828154811061151557fe5b906000526020600020906007020190508060000154431161153657506115e9565b6002810154156115e557600061157561155c83600501544361202390919063ffffffff16565b83600401548460020154856005015486600601546117d7565b905060006115b06115978460050154856000015461202390919063ffffffff16565b84600401548560020154866005015487600601546117d7565b905060006115c4838363ffffffff61202316565b60018501549091506115dc908263ffffffff61208016565b60018501555050505b4390555b50565b4690565b6000806116968830898960405160200180858152602001846001600160a01b03166001600160a01b031660601b815260140183815260200182805190602001908083835b602083106116535780518252601f199092019160209182019101611634565b6001836020036101000a0380198251168184511680821785525050505050509050019450505050506040516020818303038152906040528051906020012061239f565b9050600060018285888860405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156116f7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611753576040805162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b604482015290519081900360640190fd5b6001600160a01b038a8116911614915050979650505050505050565b60025460ff166117b8576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b60045460005b818110156112af576117cf816114bd565b6001016117be565b60006117e9828463ffffffff61202316565b8611156118305761182984610a9b64e8d4a5100061181d611810878963ffffffff61202316565b8a9063ffffffff611f6316565b9063ffffffff611f6316565b905061184d565b61182984610a9b64e8d4a5100061181d8a8a63ffffffff611f6316565b95945050505050565b60408051692927a622afa0a226a4a760b11b8152905190819003600a01902061187f9033611d0b565b6118c6576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff1661190f576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b83431061194d5760405162461bcd60e51b8152600401808060200182810382526029815260200180612a4f6029913960400191505060405180910390fd5b801561195b5761195b61176f565b6003546001600160a01b03166323b872dd6119746123f0565b604080516001600160e01b031960e085901b1681526001600160a01b039092166004830152306024830152604482018690525160648083019260209291908290030181600087803b1580156119c857600080fd5b505af11580156119dc573d6000803e3d6000fd5b505050506040513d60208110156119f257600080fd5b50506040805160e081018252858152600060208201819052918101919091526060810183905260049060808101611a3f611a32878963ffffffff61202316565b869063ffffffff611fbc16565b8152602080820197909752604090810195909552815460018181018455600093845292879020825160079092020190815595810151918601919091559283015160028501555050606081015160038301556080810151600483015560a0810151600583015560c00151600690910155565b60408051692927a622afa0a226a4a760b11b8152905190819003600a019020611ad99033611d0b565b611b20576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff16611b69576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b600060048481548110611b7857fe5b906000526020600020906007020190508060050154431015611bd7576040805162461bcd60e51b815260206004820152601360248201527211195c1bdcda5d081b9bdd081cdd185c9d1959606a1b604482015290519081900360640190fd5b60008481526005602090815260408083206001600160a01b03861684529091529020611c02856114bd565b8054611c14908563ffffffff61208016565b81556001820154611c4c90611c3b9064e8d4a5100090610a9b90889063ffffffff611f6316565b60018301549063ffffffff61208016565b60018201556002820154611c66908563ffffffff61208016565b6002830155600354611c89906001600160a01b031684308763ffffffff61244f16565b60408051858152905186916001600160a01b038616917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159181900360200190a35050505050565b60025461010090046001600160a01b031681565b6000828152600160205260408120611d02908363ffffffff6124af16565b90505b92915050565b6000828152600160205260408120611d02908363ffffffff6124bb16565b600560209081526000928352604080842090915290825290208054600182015460029092015490919083565b60025460009060ff16611da1576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b600060048481548110611db057fe5b600091825260208083208784526005825260408085206001600160a01b0389168652909252922060026007909202909201908101549092501580611df75750816005015443105b15611e0757600092505050611d05565b6000611e2361159784600501544361202390919063ffffffff16565b90506000611e5e611e458560050154866000015461202390919063ffffffff16565b85600401548660020154876005015488600601546117d7565b90506000611e72838363ffffffff61202316565b90506000611e8d82876001015461208090919063ffffffff16565b9050611ebf8560020154610afb8760010154610aa764e8d4a51000610a9b878c60000154611f6390919063ffffffff16565b9998505050505050505050565b600081565b6000818152600160205260408120611d05906124d0565b60408051692927a622afa0a226a4a760b11b8152905190819003600a01902081565b600082815260016020526040902060020154611f289061126561226b565b61148b5760405162461bcd60e51b81526004018080602001828103825260308152602001806129dd6030913960400191505060405180910390fd5b600082611f7257506000611d05565b82820282848281611f7f57fe5b0414611d025760405162461bcd60e51b8152600401808060200182810382526021815260200180612a0d6021913960400191505060405180910390fd5b6000808211612012576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161201b57fe5b049392505050565b60008282111561207a576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082820183811015611d02576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600354604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561212557600080fd5b505afa158015612139573d6000803e3d6000fd5b505050506040513d602081101561214f57600080fd5b50519050808211156121e3576003546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156121b157600080fd5b505af11580156121c5573d6000803e3d6000fd5b505050506040513d60208110156121db57600080fd5b506122669050565b6003546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561223957600080fd5b505af115801561224d573d6000803e3d6000fd5b505050506040513d602081101561226357600080fd5b50505b505050565b3390565b600082815260016020526040902061228d908263ffffffff6124db16565b156112af5761229a61226b565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526122669084906124f0565b600082815260016020526040902061234e908263ffffffff6125a116565b156112af5761235b61226b565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b604080517f19457468657265756d205369676e6564204d6573736167653a0a333200000000602080830191909152603c8083019490945282518083039094018452605c909101909152815191012090565b6000333014156124485760606000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b03169150610b599050565b5033610b59565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526124a99085906124f0565b50505050565b6000611d0283836125b6565b6000611d02836001600160a01b03841661261a565b6000611d0582612632565b6000611d02836001600160a01b038416612636565b6060612545826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126809092919063ffffffff16565b8051909150156122665780806020019051602081101561256457600080fd5b50516122665760405162461bcd60e51b815260040180806020018281038252602a815260200180612aa1602a913960400191505060405180910390fd5b6000611d02836001600160a01b038416612699565b815460009082106125f85760405162461bcd60e51b81526004018080602001828103825260228152602001806129666022913960400191505060405180910390fd5b82600001828154811061260757fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b6000612642838361261a565b61267857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611d05565b506000611d05565b606061268f848460008561275f565b90505b9392505050565b6000818152600183016020526040812054801561275557835460001980830191908101906000908790839081106126cc57fe5b90600052602060002001549050808760000184815481106126e957fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061271957fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611d05565b6000915050611d05565b6060824710156127a05760405162461bcd60e51b81526004018080602001828103825260268152602001806129b76026913960400191505060405180910390fd5b6127a9856128bb565b6127fa576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106128395780518252601f19909201916020918201910161281a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461289b576040519150601f19603f3d011682016040523d82523d6000602084013e6128a0565b606091505b50915091506128b08282866128c1565b979650505050505050565b3b151590565b606083156128d0575081612692565b8251156128e05782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561292a578181015183820152602001612912565b50505050905090810190601f1680156129575780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775369676e657220616e64207369676e617475726520646f206e6f74206d61746368537461727420626c6f636b206e756d626572206d75737420626520612066757475726520626c6f636b43616e6e6f74207769746864726177206265666f726520766f74696e6720706572696f6420656e64735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220f460f6d3f657841178dab5d5279a5d301046c5071147373461f3bb740424e3fb64736f6c63430006020033000000000000000000000000c55c2175e90a46602fd42e931f62b3acc1a013ca00000000000000000000000017aad37fdf5bdc1b7d0e9cb601f623e647cc849a

Deployed Bytecode

0x6080604052600436106101cc5760003560e01c8063564b81ef116100f75780639010d07c11610095578063a217fddf11610064578063a217fddf14610895578063ca15c873146108aa578063d391014b146108d4578063d547741f146108e9576101cc565b80639010d07c1461079c57806391d14854146107cc57806393f1a40b14610805578063982669eb1461085c576101cc565b80636b5afed2116100d15780636b5afed2146106c8578063851b5d5a1461070a5780638dbdbe6d146107485780638eb9c0a014610787576101cc565b8063564b81ef146105c15780636281133d146105d6578063630b5ba1146106b3576101cc565b806319ab453c1161016f5780632f940c701161013e5780632f940c70146104fb57806336568abe146105345780633a9de2ed1461056d57806351eb05a614610597576101cc565b806319ab453c14610432578063248a9ca3146104655780632d0335ab1461048f5780632f2ff15d146104c2576101cc565b80630dd5b3c5116101ab5780630dd5b3c5146103375780630f185cbc146103685780631526fe27146103a7578063158ef93e14610409576101cc565b8062f714ce146101d1578063081e3eda1461020c5780630c53c51c14610233575b600080fd5b3480156101dd57600080fd5b5061020a600480360360408110156101f457600080fd5b50803590602001356001600160a01b0316610922565b005b34801561021857600080fd5b50610221610b55565b60408051918252519081900360200190f35b6102c2600480360360a081101561024957600080fd5b6001600160a01b03823516919081019060408101602082013564010000000081111561027457600080fd5b82018360208201111561028657600080fd5b803590602001918460018302840111640100000000831117156102a857600080fd5b91935091508035906020810135906040013560ff16610b5c565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102fc5781810151838201526020016102e4565b50505050905090810190601f1680156103295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561034357600080fd5b5061034c610e1d565b604080516001600160a01b039092168252519081900360200190f35b34801561037457600080fd5b5061020a6004803603606081101561038b57600080fd5b50803590602081013590604001356001600160a01b0316610e2c565b3480156103b357600080fd5b506103d1600480360360208110156103ca57600080fd5b50356110a6565b604080519788526020880196909652868601949094526060860192909252608085015260a084015260c0830152519081900360e00190f35b34801561041557600080fd5b5061041e6110f5565b604080519115158252519081900360200190f35b34801561043e57600080fd5b5061020a6004803603602081101561045557600080fd5b50356001600160a01b03166110fe565b34801561047157600080fd5b506102216004803603602081101561048857600080fd5b5035611217565b34801561049b57600080fd5b50610221600480360360208110156104b257600080fd5b50356001600160a01b031661122c565b3480156104ce57600080fd5b5061020a600480360360408110156104e557600080fd5b50803590602001356001600160a01b0316611247565b34801561050757600080fd5b5061020a6004803603604081101561051e57600080fd5b50803590602001356001600160a01b03166112b3565b34801561054057600080fd5b5061020a6004803603604081101561055757600080fd5b50803590602001356001600160a01b0316611434565b34801561057957600080fd5b506102216004803603602081101561059057600080fd5b5035611495565b3480156105a357600080fd5b5061020a600480360360208110156105ba57600080fd5b50356114bd565b3480156105cd57600080fd5b506102216115ec565b3480156105e257600080fd5b5061041e600480360360e08110156105f957600080fd5b6001600160a01b03823516916020810135916040820135919081019060808101606082013564010000000081111561063057600080fd5b82018360208201111561064257600080fd5b8035906020019184600183028401116401000000008311171561066457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550508235935050506020810135906040013560ff166115f0565b3480156106bf57600080fd5b5061020a61176f565b3480156106d457600080fd5b50610221600480360360a08110156106eb57600080fd5b50803590602081013590604081013590606081013590608001356117d7565b34801561071657600080fd5b5061020a6004803603608081101561072d57600080fd5b50803590602081013590604081013590606001351515611856565b34801561075457600080fd5b5061020a6004803603606081101561076b57600080fd5b50803590602081013590604001356001600160a01b0316611ab0565b34801561079357600080fd5b5061034c611cd0565b3480156107a857600080fd5b5061034c600480360360408110156107bf57600080fd5b5080359060200135611ce4565b3480156107d857600080fd5b5061041e600480360360408110156107ef57600080fd5b50803590602001356001600160a01b0316611d0b565b34801561081157600080fd5b5061083e6004803603604081101561082857600080fd5b50803590602001356001600160a01b0316611d29565b60408051938452602084019290925282820152519081900360600190f35b34801561086857600080fd5b506102216004803603604081101561087f57600080fd5b50803590602001356001600160a01b0316611d55565b3480156108a157600080fd5b50610221611ecc565b3480156108b657600080fd5b50610221600480360360208110156108cd57600080fd5b5035611ed1565b3480156108e057600080fd5b50610221611ee8565b3480156108f557600080fd5b5061020a6004803603604081101561090c57600080fd5b50803590602001356001600160a01b0316611f0a565b60408051692927a622afa0a226a4a760b11b8152905190819003600a01902061094b9033611d0b565b610992576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff166109db576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b6000600483815481106109ea57fe5b9060005260206000209060070201905080600601544311610a3c5760405162461bcd60e51b8152600401808060200182810382526029815260200180612a786029913960400191505060405180910390fd5b60008381526005602090815260408083206001600160a01b03861684529091529020610a67846114bd565b8054600282015460018084015490850154600091610ab391610aa79064e8d4a5100090610a9b90889063ffffffff611f6316565b9063ffffffff611fbc16565b9063ffffffff61202316565b600080865560018601819055600280870191909155860154909150610ade908463ffffffff61202316565b6002860155610b0c86610b0784610afb858863ffffffff61208016565b9063ffffffff61208016565b6120da565b60408051848152905188916001600160a01b038916917ff279e6a1f5e320cca91135676d9cb6e44ca8a08c0b88342bcdb1144f6511b5689181900360200190a350505050505050565b6004545b90565b6001600160a01b038616600090815260208190526040902054606090610bc7908890610b866115ec565b89898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152508b92508a91508990506115f0565b610c025760405162461bcd60e51b8152600401808060200182810382526021815260200180612a2e6021913960400191505060405180910390fd5b6001600160a01b038716600090815260208190526040902054610c2c90600163ffffffff61208016565b600080896001600160a01b03166001600160a01b031681526020019081526020016000208190555060006060306001600160a01b031688888b6040516020018084848082843780830192505050826001600160a01b03166001600160a01b031660601b815260140193505050506040516020818303038152906040526040518082805190602001908083835b60208310610cd75780518252601f199092019160209182019101610cb8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114610d39576040519150601f19603f3d011682016040523d82523d6000602084013e610d3e565b606091505b509150915081610d95576040805162461bcd60e51b815260206004820152601c60248201527f46756e6374696f6e2063616c6c206e6f74207375636365737366756c00000000604482015290519081900360640190fd5b604080516001600160a01b038b168152336020820181905260609282018381529282018a90527f5845892132946850460bff5a0083f71031bc5bf9aadcd40f1de79423eac9b10b928c928c918c919060808201848480828437600083820152604051601f909101601f191690920182900397509095505050505050a198975050505050505050565b6003546001600160a01b031681565b60408051692927a622afa0a226a4a760b11b8152905190819003600a019020610e559033611d0b565b610e9c576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff16610ee5576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b600060048481548110610ef457fe5b600091825260208083208784526005825260408085206001600160a01b03881686529092529220805460079092029092019250841115610f7b576040805162461bcd60e51b815260206004820152601e60248201527f496e73756666696369656e7420535441525320746f2077697468647261770000604482015290519081900360640190fd5b610f84856114bd565b6000610fb28260010154610aa764e8d4a51000610a9b87600101548760000154611f6390919063ffffffff16565b82549091508515611037578254610fcf908763ffffffff61202316565b8355610fdb85876120da565b611015610ff982610a9b866000015486611f6390919063ffffffff16565b84546002860154610afb918591610a9b9163ffffffff611f6316565b600280850191909155840154611031908763ffffffff61202316565b60028501555b600184015483546110589164e8d4a5100091610a9b9163ffffffff611f6316565b600184015560408051878152905188916001600160a01b038816917f680dd80a97d6492f92e0452d2304446b3feaafe9ecca87a130cdc09018b4ed1d9181900360200190a350505050505050565b600481815481106110b357fe5b90600052602060002090600702016000915090508060000154908060010154908060020154908060030154908060040154908060050154908060060154905087565b60025460ff1681565b60408051692927a622afa0a226a4a760b11b8152905190819003600a0190206111279033611d0b565b61116e576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff16156111bc576040805162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481a5b9a5d1a585b1a5e9959606a1b604482015290519081900360640190fd5b600280546001600160a01b03831661010002610100600160a81b031990911617905560408051692927a622afa0a226a4a760b11b8152905190819003600a01902061120790826112a5565b506002805460ff19166001179055565b60009081526001602052604090206002015490565b6001600160a01b031660009081526020819052604090205490565b60008281526001602052604090206002015461126a9061126561226b565b611d0b565b6112a55760405162461bcd60e51b815260040180806020018281038252602f815260200180612988602f913960400191505060405180910390fd5b6112af828261226f565b5050565b60408051692927a622afa0a226a4a760b11b8152905190819003600a0190206112dc9033611d0b565b611323576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff1661136c576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b60006004838154811061137b57fe5b600091825260208083208684526005825260408085206001600160a01b0380891687529352909320805460035460079094029094019450926113c89290911690859063ffffffff6122de16565b805460028301546113de9163ffffffff61202316565b6002830155600080825560018201819055604080519182525185916001600160a01b038616917fbb757047c2b5f3974fe26b7c10f732e7bce710b0952a71082702781e62ae05959181900360200190a350505050565b61143c61226b565b6001600160a01b0316816001600160a01b03161461148b5760405162461bcd60e51b815260040180806020018281038252602f815260200180612acb602f913960400191505060405180910390fd5b6112af8282612330565b6000600482815481106114a457fe5b9060005260206000209060070201600401549050919050565b60025460ff16611506576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b60006004828154811061151557fe5b906000526020600020906007020190508060000154431161153657506115e9565b6002810154156115e557600061157561155c83600501544361202390919063ffffffff16565b83600401548460020154856005015486600601546117d7565b905060006115b06115978460050154856000015461202390919063ffffffff16565b84600401548560020154866005015487600601546117d7565b905060006115c4838363ffffffff61202316565b60018501549091506115dc908263ffffffff61208016565b60018501555050505b4390555b50565b4690565b6000806116968830898960405160200180858152602001846001600160a01b03166001600160a01b031660601b815260140183815260200182805190602001908083835b602083106116535780518252601f199092019160209182019101611634565b6001836020036101000a0380198251168184511680821785525050505050509050019450505050506040516020818303038152906040528051906020012061239f565b9050600060018285888860405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa1580156116f7573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116611753576040805162461bcd60e51b8152602060048201526011602482015270496e76616c6964207369676e617475726560781b604482015290519081900360640190fd5b6001600160a01b038a8116911614915050979650505050505050565b60025460ff166117b8576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b60045460005b818110156112af576117cf816114bd565b6001016117be565b60006117e9828463ffffffff61202316565b8611156118305761182984610a9b64e8d4a5100061181d611810878963ffffffff61202316565b8a9063ffffffff611f6316565b9063ffffffff611f6316565b905061184d565b61182984610a9b64e8d4a5100061181d8a8a63ffffffff611f6316565b95945050505050565b60408051692927a622afa0a226a4a760b11b8152905190819003600a01902061187f9033611d0b565b6118c6576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff1661190f576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b83431061194d5760405162461bcd60e51b8152600401808060200182810382526029815260200180612a4f6029913960400191505060405180910390fd5b801561195b5761195b61176f565b6003546001600160a01b03166323b872dd6119746123f0565b604080516001600160e01b031960e085901b1681526001600160a01b039092166004830152306024830152604482018690525160648083019260209291908290030181600087803b1580156119c857600080fd5b505af11580156119dc573d6000803e3d6000fd5b505050506040513d60208110156119f257600080fd5b50506040805160e081018252858152600060208201819052918101919091526060810183905260049060808101611a3f611a32878963ffffffff61202316565b869063ffffffff611fbc16565b8152602080820197909752604090810195909552815460018181018455600093845292879020825160079092020190815595810151918601919091559283015160028501555050606081015160038301556080810151600483015560a0810151600583015560c00151600690910155565b60408051692927a622afa0a226a4a760b11b8152905190819003600a019020611ad99033611d0b565b611b20576040805162461bcd60e51b815260206004820152601360248201527229b2b73232b91034b9903737ba1030b236b4b760691b604482015290519081900360640190fd5b60025460ff16611b69576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b600060048481548110611b7857fe5b906000526020600020906007020190508060050154431015611bd7576040805162461bcd60e51b815260206004820152601360248201527211195c1bdcda5d081b9bdd081cdd185c9d1959606a1b604482015290519081900360640190fd5b60008481526005602090815260408083206001600160a01b03861684529091529020611c02856114bd565b8054611c14908563ffffffff61208016565b81556001820154611c4c90611c3b9064e8d4a5100090610a9b90889063ffffffff611f6316565b60018301549063ffffffff61208016565b60018201556002820154611c66908563ffffffff61208016565b6002830155600354611c89906001600160a01b031684308763ffffffff61244f16565b60408051858152905186916001600160a01b038616917f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a159181900360200190a35050505050565b60025461010090046001600160a01b031681565b6000828152600160205260408120611d02908363ffffffff6124af16565b90505b92915050565b6000828152600160205260408120611d02908363ffffffff6124bb16565b600560209081526000928352604080842090915290825290208054600182015460029092015490919083565b60025460009060ff16611da1576040805162461bcd60e51b815260206004820152600f60248201526e139bdd081a5b9a5d1a585b1a5e9959608a1b604482015290519081900360640190fd5b600060048481548110611db057fe5b600091825260208083208784526005825260408085206001600160a01b0389168652909252922060026007909202909201908101549092501580611df75750816005015443105b15611e0757600092505050611d05565b6000611e2361159784600501544361202390919063ffffffff16565b90506000611e5e611e458560050154866000015461202390919063ffffffff16565b85600401548660020154876005015488600601546117d7565b90506000611e72838363ffffffff61202316565b90506000611e8d82876001015461208090919063ffffffff16565b9050611ebf8560020154610afb8760010154610aa764e8d4a51000610a9b878c60000154611f6390919063ffffffff16565b9998505050505050505050565b600081565b6000818152600160205260408120611d05906124d0565b60408051692927a622afa0a226a4a760b11b8152905190819003600a01902081565b600082815260016020526040902060020154611f289061126561226b565b61148b5760405162461bcd60e51b81526004018080602001828103825260308152602001806129dd6030913960400191505060405180910390fd5b600082611f7257506000611d05565b82820282848281611f7f57fe5b0414611d025760405162461bcd60e51b8152600401808060200182810382526021815260200180612a0d6021913960400191505060405180910390fd5b6000808211612012576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161201b57fe5b049392505050565b60008282111561207a576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b600082820183811015611d02576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b600354604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b15801561212557600080fd5b505afa158015612139573d6000803e3d6000fd5b505050506040513d602081101561214f57600080fd5b50519050808211156121e3576003546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156121b157600080fd5b505af11580156121c5573d6000803e3d6000fd5b505050506040513d60208110156121db57600080fd5b506122669050565b6003546040805163a9059cbb60e01b81526001600160a01b038681166004830152602482018690529151919092169163a9059cbb9160448083019260209291908290030181600087803b15801561223957600080fd5b505af115801561224d573d6000803e3d6000fd5b505050506040513d602081101561226357600080fd5b50505b505050565b3390565b600082815260016020526040902061228d908263ffffffff6124db16565b156112af5761229a61226b565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526122669084906124f0565b600082815260016020526040902061234e908263ffffffff6125a116565b156112af5761235b61226b565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b604080517f19457468657265756d205369676e6564204d6573736167653a0a333200000000602080830191909152603c8083019490945282518083039094018452605c909101909152815191012090565b6000333014156124485760606000368080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505050503601516001600160a01b03169150610b599050565b5033610b59565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526124a99085906124f0565b50505050565b6000611d0283836125b6565b6000611d02836001600160a01b03841661261a565b6000611d0582612632565b6000611d02836001600160a01b038416612636565b6060612545826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166126809092919063ffffffff16565b8051909150156122665780806020019051602081101561256457600080fd5b50516122665760405162461bcd60e51b815260040180806020018281038252602a815260200180612aa1602a913960400191505060405180910390fd5b6000611d02836001600160a01b038416612699565b815460009082106125f85760405162461bcd60e51b81526004018080602001828103825260228152602001806129666022913960400191505060405180910390fd5b82600001828154811061260757fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b6000612642838361261a565b61267857508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155611d05565b506000611d05565b606061268f848460008561275f565b90505b9392505050565b6000818152600183016020526040812054801561275557835460001980830191908101906000908790839081106126cc57fe5b90600052602060002001549050808760000184815481106126e957fe5b60009182526020808320909101929092558281526001898101909252604090209084019055865487908061271957fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050611d05565b6000915050611d05565b6060824710156127a05760405162461bcd60e51b81526004018080602001828103825260268152602001806129b76026913960400191505060405180910390fd5b6127a9856128bb565b6127fa576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b602083106128395780518252601f19909201916020918201910161281a565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461289b576040519150601f19603f3d011682016040523d82523d6000602084013e6128a0565b606091505b50915091506128b08282866128c1565b979650505050505050565b3b151590565b606083156128d0575081612692565b8251156128e05782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561292a578181015183820152602001612912565b50505050905090810190601f1680156129575780820380516001836020036101000a031916815260200191505b509250505060405180910390fdfe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775369676e657220616e64207369676e617475726520646f206e6f74206d61746368537461727420626c6f636b206e756d626572206d75737420626520612066757475726520626c6f636b43616e6e6f74207769746864726177206265666f726520766f74696e6720706572696f6420656e64735361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220f460f6d3f657841178dab5d5279a5d301046c5071147373461f3bb740424e3fb64736f6c63430006020033

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

000000000000000000000000c55c2175e90a46602fd42e931f62b3acc1a013ca00000000000000000000000017aad37fdf5bdc1b7d0e9cb601f623e647cc849a

-----Decoded View---------------
Arg [0] : starsAddress (address): 0xc55c2175E90A46602fD42e931f62B3Acc1A013Ca
Arg [1] : _admin (address): 0x17AAD37FDF5bDc1b7D0E9cb601f623E647CC849A

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000c55c2175e90a46602fd42e931f62b3acc1a013ca
Arg [1] : 00000000000000000000000017aad37fdf5bdc1b7d0e9cb601f623e647cc849a


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

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