Contract 0x76739d9693Aa2bB62C44ae1B9084d6937eDB91aa 2

Contract Overview

Balance:
0 AVAX
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xb377d0c99613e1d4f5f0567b9e8229b63207021af5db04ad59fa6d334eedb931Grant Role116575932022-07-16 19:35:5082 days 10 hrs ago0x2c305888a456e7004663bc12a74395e637eabcbc IN 0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX0.00128442525
0xe57b97c5629db0876a3505ff22e2188ab70d3f75c7298bf412c9fd44d98cd5d1Grant Role107775382022-06-18 1:35:01111 days 4 hrs ago0x2c305888a456e7004663bc12a74395e637eabcbc IN 0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX0.00128412525
0x9c091aa8308a5e760850d890bf03800c412a4e9a1c38fb7a74b13c13204621c7Grant Role107775372022-06-18 1:34:57111 days 4 hrs ago0x2c305888a456e7004663bc12a74395e637eabcbc IN 0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX0.00128442525
0x63339ab0173a45f68e089ac5b2df35f6afedf266d068a878b3cfb923a8ce10c4Grant Role107775332022-06-18 1:34:46111 days 4 hrs ago0x2c305888a456e7004663bc12a74395e637eabcbc IN 0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX0.00128442525
0x4ed36814752bde1fea78efd47f254a997c26950a69af122b011d138c2d1f40b00x60806040107775262022-06-18 1:34:22111 days 4 hrs ago0x2c305888a456e7004663bc12a74395e637eabcbc IN  Create: Referral0 AVAX0.05243202525
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x2c06eb25f4bea6c5a59132a8a3078ae9224b20db5c182bef15e03e023472d90e127698072022-08-23 6:40:4144 days 23 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x5e799090bc6a0fdc3cdacb94d935f1ee32872a283a5097c5797c77959d98ec94127697802022-08-23 6:39:4744 days 23 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x8f11b9abf4c707ac062238c484e147bb2636946b5e406b4da901c6bd9312b9d9127697482022-08-23 6:38:4244 days 23 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x42ed2aa254e9a810f9652ee346470f3008aeff626e2bb9e25bfbffa29bd865d7127697252022-08-23 6:37:5644 days 23 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0xc152cbc38772e2ce52d2c1a948b8281ae7bde82e6ac63eb2b0f1b9361a383150125618412022-08-15 16:12:5852 days 14 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x06d5d0bfcda65d76f95094f8b7d8b1513ecf038face2f66d99000a2a34efb4df125618082022-08-15 16:11:1952 days 14 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x09d44d3b62c1d1776a498fc64e63475156269648961629e786194763536315da124855822022-08-12 20:21:3655 days 10 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x32227f06a6cfb26724758d95e253564fc7e70dae51efb7e8bb8423a8e65d4388124855572022-08-12 20:20:4355 days 10 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0xbb93bdbd4109eb19e64aaea08a9982f5c66837d671628cc375dfe31ff87092a7124855372022-08-12 20:19:5455 days 10 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x5d8f3bba67f6a1305cd22f0f61900809183a0b278cc2f567a38d8659a0b6fa38124855192022-08-12 20:19:0055 days 10 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0xf22a4ede442f2f0ba5412163948abf52b105575e05fccfb6f68245866231d78d124854922022-08-12 20:18:0555 days 10 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0xf65e532bdcb97459464d73b7792b082ae5d05399c2e4f6e5ac8016bf0c599149124854672022-08-12 20:17:0655 days 10 hrs ago 0x7d142a8b80cd68694cec9c34ae86c9f68ccc359a0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0xb5724d18a55728f414626adec3525395e760845694b290062fb7f48a3bc97f73124854382022-08-12 20:16:0055 days 10 hrs ago 0x7d142a8b80cd68694cec9c34ae86c9f68ccc359a0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0xfcf0f9adee1e99972d844cd11e530149c890a4a8df7495f1e6f42784f47bc11b124854002022-08-12 20:14:3255 days 10 hrs ago 0x7d142a8b80cd68694cec9c34ae86c9f68ccc359a0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x427e6ac30f04c6b879cf67edb0b565c58aa914a0abcb27e4a115bf170aa756a3124853622022-08-12 20:13:0755 days 10 hrs ago 0x7d142a8b80cd68694cec9c34ae86c9f68ccc359a0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x7e280c898e80e4925380d984ccc810376c4ceec5968b60849fe3d2c85ccc7bc7124853382022-08-12 20:12:1855 days 10 hrs ago 0x7d142a8b80cd68694cec9c34ae86c9f68ccc359a0x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x2616c30649dc69ec4500a62deb81d137db18de75df8269a47abbe9a67a66a893124853172022-08-12 20:11:2455 days 10 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x76315724072425aaad9cba2c91f199b27862b1105862f122066c848106219cda124852822022-08-12 20:10:0055 days 10 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x0fb53708fda3e315aa4cf2ba7e08d3428a97772c88fb55cd069e59e740049c50124852382022-08-12 20:08:2055 days 10 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0xd962bb6bed032a26f3e1179f336535f353e0c7f610be2be689c87636d68c41f8124851992022-08-12 20:06:5255 days 10 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x8c1d1009270fedabadee87a9641c7f52f5b05071ba743efe0e956bf904dbd49e124851522022-08-12 20:04:5855 days 10 hrs ago 0xaeaf7948c38973908ffa97c92f3384595d0571350x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x5a4efe01908b1b4be4425e6fd06adf241390916a0f2172c0a595ae7311926829124797762022-08-12 16:45:4155 days 13 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0xd61f4f5c71d05f1eb2be8be4520a4d36eb500894bc5954c77d07a9430970f152124797362022-08-12 16:44:0955 days 13 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x0ac4567c68bc6df261e0a192bc572db141606b00ce4a1ef7ed1a85a9691ab608124797172022-08-12 16:43:2855 days 13 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
0x33dd357f27c71766b2556c21170a6f2fab39bf8c9be5137c6923be386240ad8f124796922022-08-12 16:42:3555 days 13 hrs ago 0x654b32aaf7ea14d9b9f81517f938dff890e386e30x76739d9693aa2bb62c44ae1b9084d6937edb91aa0 AVAX
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Referral

Compiler Version
v0.8.14+commit.80d49f37

Optimization Enabled:
Yes with 8000 runs

Other Settings:
default evmVersion, MIT license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 11 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * 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, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

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

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @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 virtual override 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 override onlyRole(getRoleAdmin(role)) {
        _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 override onlyRole(getRoleAdmin(role)) {
        _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 revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        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}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    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 {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 2 of 11 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @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 {AccessControl-_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) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @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) external;

    /**
     * @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) external;

    /**
     * @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) external;
}

File 3 of 11 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 4 of 11 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

File 5 of 11 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 6 of 11 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 7 of 11 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 8 of 11 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 9 of 11 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 10 of 11 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 11 of 11 : Referral.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.10;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

// import "hardhat/console.sol";

/// @title Multi-level referral program
/// @author Thundercore, customized by Romuald Hog
/// @dev All rates are in basis point.
contract Referral is AccessControl, Pausable {
    using SafeERC20 for IERC20;

    /// @notice The struct of account information.
    /// @param referrer The referrer addresss.
    /// @param referredCount The total referral amount of an address.
    /// @param lastActiveTimestamp The last active timestamp of an address.
    struct Account {
        address referrer;
        uint24 referredCount;
        uint32 lastActiveTimestamp;
    }

    /// @notice The struct of referee amount to bonus rate.
    /// @param lowerBound The minial referee amount.
    /// @param rate The bonus rate for each referee amount.
    struct RefereeBonusRate {
        uint16 lowerBound;
        uint16 rate;
    }

    /// @notice The bonus rate for each level.
    /// @dev The max depth is 3.
    uint16[3] public levelRate;

    /// @notice The seconds that a user does not update will be seen as inactive.
    uint24 public secondsUntilInactive;

    /// @notice The flag to enable not paying to inactive uplines.
    bool public onlyRewardActiveReferrers;

    /// @notice The bonus rate mapping to each referree amount. The max depth is 3.
    RefereeBonusRate[3] public refereeBonusRateMap;

    /// @notice Maps users addresses to tokens addresses to credits amount.
    mapping(address => mapping(address => uint256)) private _credits;

    /// @notice Maps users addresses to referrer account information.
    mapping(address => Account) private _accounts;

    /// @notice Role associated to Games smart contracts.
    bytes32 public constant GAME_ROLE = keccak256("GAME_ROLE");

    /// @notice Role associated to the Bank smart contracts.
    bytes32 public constant BANK_ROLE = keccak256("BANK_ROLE");

    /// @notice Emitted after the configuration is set.
    /// @param secondsUntilInactive The seconds that a user does not update will be seen as inactive.
    /// @param onlyRewardActiveReferrers The flag to enable not paying to inactive uplines.
    /// @param levelRate The bonus rate for each level.
    event SetReferral(
        uint24 secondsUntilInactive,
        bool onlyRewardActiveReferrers,
        uint16[3] levelRate
    );

    /// @notice Emitted after a bonus rate configuration is set.
    /// @param lowerBound Number of minimum referee to benefit the bonus rate.
    /// @param rate The bonus rate.
    event SetReferreeBonusRate(uint16 lowerBound, uint16 rate);

    /// @notice Emitted after setting the referrer of a referee.
    /// @param referee The address of the user
    /// @param referrer The address would set as referrer of user
    event RegisteredReferer(address indexed referee, address indexed referrer);

    /// @notice Emitted after referrer's activity.
    /// @param referrer The address of the user.
    /// @param lastActiveTimestamp The last active timestamp of the referrer.
    event SetLastActiveTimestamp(
        address indexed referrer,
        uint32 lastActiveTimestamp
    );

    /// @notice Emitted after adding credit to a referrer.
    /// @param user Address of the referrer.
    /// @param token Address of the token.
    /// @param amount Amount of credited tokens.
    /// @param level The referrer level.
    event AddReferralCredit(
        address indexed user,
        address indexed token,
        uint256 amount,
        uint16 indexed level
    );

    /// @notice Emitted after the referrer withdraw credits.
    /// @param payee Address of the referrer.
    /// @param token Address of the token.
    /// @param amount Amount of credited tokens.
    event WithdrawnReferralCredit(
        address indexed payee,
        address indexed token,
        uint256 amount
    );

    /// @notice Referral level should be at least one, length not exceed 3, and total not exceed 100%.
    error WrongLevelRate();

    /// @notice One of referee bonus rate exceeds 100%.
    /// @param rate The referee bonus rate.
    error WrongRefereeBonusRate(uint16 rate);

    /// @notice Sets the Referral program configuration. c.f. `Referral._setReferral`.
    /// @param _secondsUntilInactive The seconds that a user does not update will be seen as inactive.
    /// @param _onlyRewardActiveReferrers The flag to enable not paying to inactive uplines.
    /// @param _levelRate The bonus rate for each level. The max depth is 3.
    /// @param _refereeBonusRateMap The bonus rate mapping to each referree amount. The max depth is 3.
    constructor(
        uint24 _secondsUntilInactive,
        bool _onlyRewardActiveReferrers,
        uint16[3] memory _levelRate,
        uint16[6] memory _refereeBonusRateMap
    ) {
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
        setReferral(
            _secondsUntilInactive,
            _onlyRewardActiveReferrers,
            _levelRate,
            _refereeBonusRateMap
        );
    }

    receive() external payable {}

    /// @notice Gets the bonus rate based on the referred count.
    /// @param referredCount The number of referrees.
    /// @return The bonus rate.
    function _getRefereeBonusRate(uint24 referredCount)
        private
        view
        returns (uint16)
    {
        uint16 rate = refereeBonusRateMap[0].rate;
        uint256 refereeBonusRateMapLength = refereeBonusRateMap.length;
        for (uint8 i = 1; i < refereeBonusRateMapLength; i++) {
            RefereeBonusRate memory refereeBonusRate = refereeBonusRateMap[i];
            if (referredCount < refereeBonusRate.lowerBound) {
                break;
            }
            rate = refereeBonusRate.rate;
        }
        return rate;
    }

    /// @notice Checks whether the referee is one of referrer uplines.
    /// @param referrer Address of the referrer.
    /// @param referee Address of the referee.
    /// @return Whether the referee is already on referrer's upper levels.
    function _isCircularReference(address referrer, address referee)
        private
        view
        returns (bool)
    {
        address parent = referrer;
        uint256 levelRateLength = levelRate.length;
        for (uint8 i; i < levelRateLength; i++) {
            if (parent == address(0)) {
                break;
            }

            if (parent == referee) {
                return true;
            }

            parent = _accounts[parent].referrer;
        }

        return false;
    }

    /// @notice Sets the Referral program configuration.
    /// @param _secondsUntilInactive The seconds that a user does not update will be seen as inactive.
    /// @param _onlyRewardActiveReferrers The flag to enable not paying to inactive uplines.
    /// @param _levelRate The bonus rate for each level. The max depth is 3.
    /// @param _refereeBonusRateMap The bonus rate mapping to each referree amount. The max depth is 3.
    /// @dev The map should be pass as [<lower amount>, <rate>, ....]. For example, you should pass [1, 2500, 5, 5000, 10, 10000].
    ///
    ///  25%     50%     100%
    ///   | ----- | ----- |----->
    ///  1ppl    5ppl    10ppl
    ///
    /// @dev refereeBonusRateMap's lower amount should be ascending
    function setReferral(
        uint24 _secondsUntilInactive,
        bool _onlyRewardActiveReferrers,
        uint16[3] memory _levelRate,
        uint16[6] memory _refereeBonusRateMap
    ) public onlyRole(DEFAULT_ADMIN_ROLE) {
        uint256 levelRateTotal;
        uint256 levelRateLength = _levelRate.length;
        for (uint8 i; i < levelRateLength; i++) {
            levelRateTotal += _levelRate[i];
        }
        if (levelRateTotal > 10000) {
            revert WrongLevelRate();
        }

        secondsUntilInactive = _secondsUntilInactive;
        onlyRewardActiveReferrers = _onlyRewardActiveReferrers;
        levelRate = _levelRate;

        emit SetReferral(
            secondsUntilInactive,
            onlyRewardActiveReferrers,
            levelRate
        );

        uint8 j;
        uint256 refereeBonusRateMapLength = _refereeBonusRateMap.length;
        for (uint8 i; i < refereeBonusRateMapLength; i += 2) {
            uint16 refereeBonusLowerBound = _refereeBonusRateMap[i];
            uint16 refereeBonusRate = _refereeBonusRateMap[i + 1];
            if (refereeBonusRate > 10000) {
                revert WrongRefereeBonusRate(refereeBonusRate);
            }
            refereeBonusRateMap[j] = RefereeBonusRate(
                refereeBonusLowerBound,
                refereeBonusRate
            );
            emit SetReferreeBonusRate(refereeBonusLowerBound, refereeBonusRate);
            j++;
        }
    }

    /// @notice Adds an address as referrer.
    /// @param user Address of the gamer.
    /// @param referrer The address would set as referrer of user.
    function addReferrer(address user, address referrer)
        external
        onlyRole(GAME_ROLE)
    {
        if (referrer == address(0)) {
            // Referrer cannot be 0x0 address
            return;
        } else if (_isCircularReference(referrer, user)) {
            // Referee cannot be one of referrer uplines
            return;
        } else if (_accounts[user].referrer != address(0)) {
            // Address have been registered upline
            return;
        }

        Account storage userAccount = _accounts[user];
        Account storage parentAccount = _accounts[referrer];

        userAccount.referrer = referrer;
        userAccount.lastActiveTimestamp = uint32(block.timestamp);
        parentAccount.referredCount += 1;

        emit RegisteredReferer(user, referrer);
    }

    /// @notice Calculates and allocate referrer(s) credits to uplines.
    /// @param user Address of the gamer to find referrer(s).
    /// @param token The token to allocate.
    /// @param amount The number of tokens allocated for referrer(s).
    function payReferral(
        address user,
        address token,
        uint256 amount
    ) external onlyRole(BANK_ROLE) returns (uint256) {
        uint256 totalReferral;
        Account memory userAccount = _accounts[user];

        if (userAccount.referrer != address(0)) {
            uint256 levelRateLength = levelRate.length;
            for (uint8 i; i < levelRateLength; i++) {
                address parent = userAccount.referrer;
                Account memory parentAccount = _accounts[parent];

                if (parent == address(0)) {
                    break;
                }

                if (
                    !onlyRewardActiveReferrers ||
                    (parentAccount.lastActiveTimestamp + secondsUntilInactive >=
                        block.timestamp)
                ) {
                    uint256 credit = (((amount * levelRate[i]) / 10000) *
                        _getRefereeBonusRate(parentAccount.referredCount)) /
                        10000;
                    totalReferral += credit;

                    _credits[parent][token] += credit;

                    emit AddReferralCredit(parent, token, credit, i + 1);
                }

                userAccount = parentAccount;
            }
        }
        return totalReferral;
    }

    /// @notice Updates referrer's last active timestamp.
    /// @param user Address of the gamer.
    function updateReferrerActivity(address user) external onlyRole(GAME_ROLE) {
        Account storage userAccount = _accounts[user];
        if (userAccount.referredCount > 0) {
            uint32 lastActiveTimestamp = uint32(block.timestamp);
            userAccount.lastActiveTimestamp = lastActiveTimestamp;
            emit SetLastActiveTimestamp(user, lastActiveTimestamp);
        }
    }

    /// @notice Referrer withdraw credits.
    /// @param tokens The tokens addresses.
    function withdrawCredits(address[] calldata tokens) external {
        address payable payee = payable(msg.sender);
        for (uint8 i; i < tokens.length; i++) {
            address token = tokens[i];
            uint256 credit = _credits[payee][token];
            if (credit > 0) {
                _credits[payee][token] = 0;

                if (token == address(0)) {
                    Address.sendValue(payee, credit);
                } else {
                    IERC20(token).safeTransfer(payee, credit);
                }

                emit WithdrawnReferralCredit(payee, token, credit);
            }
        }
    }

    /// @notice Utils function for check whether an address has the referrer.
    /// @param user Address of the gamer.
    /// @return Whether user has a referrer.
    function hasReferrer(address user) external view returns (bool) {
        return _accounts[user].referrer != address(0);
    }

    /// @notice Gets the referrer's token credits.
    /// @param payee Address of the referrer.
    /// @param token Address of the token.
    /// @return The number of tokens available to withdraw.
    function referralCreditOf(address payee, address token)
        external
        view
        returns (uint256)
    {
        return _credits[payee][token];
    }

    /// @notice Gets the referrer's account information.
    /// @param user Address of the referrer.
    /// @return The account information.
    function getReferralAccount(address user)
        external
        view
        returns (Account memory)
    {
        return _accounts[user];
    }
}

Settings
{
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 8000
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[{"internalType":"uint24","name":"_secondsUntilInactive","type":"uint24"},{"internalType":"bool","name":"_onlyRewardActiveReferrers","type":"bool"},{"internalType":"uint16[3]","name":"_levelRate","type":"uint16[3]"},{"internalType":"uint16[6]","name":"_refereeBonusRateMap","type":"uint16[6]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"WrongLevelRate","type":"error"},{"inputs":[{"internalType":"uint16","name":"rate","type":"uint16"}],"name":"WrongRefereeBonusRate","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":true,"internalType":"uint16","name":"level","type":"uint16"}],"name":"AddReferralCredit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"referee","type":"address"},{"indexed":true,"internalType":"address","name":"referrer","type":"address"}],"name":"RegisteredReferer","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":"referrer","type":"address"},{"indexed":false,"internalType":"uint32","name":"lastActiveTimestamp","type":"uint32"}],"name":"SetLastActiveTimestamp","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint24","name":"secondsUntilInactive","type":"uint24"},{"indexed":false,"internalType":"bool","name":"onlyRewardActiveReferrers","type":"bool"},{"indexed":false,"internalType":"uint16[3]","name":"levelRate","type":"uint16[3]"}],"name":"SetReferral","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"lowerBound","type":"uint16"},{"indexed":false,"internalType":"uint16","name":"rate","type":"uint16"}],"name":"SetReferreeBonusRate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"payee","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawnReferralCredit","type":"event"},{"inputs":[],"name":"BANK_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GAME_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"referrer","type":"address"}],"name":"addReferrer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getReferralAccount","outputs":[{"components":[{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint24","name":"referredCount","type":"uint24"},{"internalType":"uint32","name":"lastActiveTimestamp","type":"uint32"}],"internalType":"struct Referral.Account","name":"","type":"tuple"}],"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":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"hasReferrer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"uint256","name":"","type":"uint256"}],"name":"levelRate","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onlyRewardActiveReferrers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"payReferral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"refereeBonusRateMap","outputs":[{"internalType":"uint16","name":"lowerBound","type":"uint16"},{"internalType":"uint16","name":"rate","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"payee","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"referralCreditOf","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":"secondsUntilInactive","outputs":[{"internalType":"uint24","name":"","type":"uint24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint24","name":"_secondsUntilInactive","type":"uint24"},{"internalType":"bool","name":"_onlyRewardActiveReferrers","type":"bool"},{"internalType":"uint16[3]","name":"_levelRate","type":"uint16[3]"},{"internalType":"uint16[6]","name":"_refereeBonusRateMap","type":"uint16[6]"}],"name":"setReferral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"updateReferrerActivity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"withdrawCredits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b5060405162002c0b38038062002c0b83398101604081905262000034916200077a565b6001805460ff191690556200004b60003362000063565b620000598484848462000073565b50505050620009f2565b6200006f828262000304565b5050565b6000620000818133620003a4565b60006003815b818160ff161015620000d757858160ff1660038110620000ab57620000ab62000844565b6020020151620000c09061ffff168462000870565b925080620000ce816200088b565b91505062000087565b50612710821115620000fc576040516347b2d1a160e01b815260040160405180910390fd5b6003805487151563010000000263ffffffff1990911662ffffff8a16171781556200012c906002908790620005ff565b506003546040805162ffffff83168152630100000090920460ff16151560208084019190915260025461ffff80821685850152601082901c81166060860152911c166080830152517ff00824b816a4531d705cd1029abff952a032e648db7de396f9f0f8c539fc4f2b9160a0908290030190a160006006815b818160ff161015620002f8576000878260ff1660068110620001cb57620001cb62000844565b60200201519050600088620001e2846001620008ad565b60ff1660068110620001f857620001f862000844565b602002015190506127108161ffff1611156200023257604051630f5e2f7f60e21b815261ffff821660048201526024015b60405180910390fd5b60405180604001604052808361ffff1681526020018261ffff1681525060048660ff166003811062000268576200026862000844565b82519101805460209384015161ffff908116620100000263ffffffff1990921693811693909317179055604080518583168152918416928201929092527f93b1de1f3c33ea5943767b6d6cf51236c3832c86fb3ffd41a92f0f807eb6fee6910160405180910390a184620002dc816200088b565b9550505050600281620002f09190620008ad565b9050620001a5565b50505050505050505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166200006f576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620003603390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166200006f57620003ee816001600160a01b031660146200043f60201b6200110e1760201c565b620004048360206200110e6200043f821b17811c565b6040516020016200041792919062000908565b60408051601f198184030181529082905262461bcd60e51b8252620002299160040162000981565b6060600062000450836002620009b6565b6200045d90600262000870565b6001600160401b03811115620004775762000477620006b3565b6040519080825280601f01601f191660200182016040528015620004a2576020820181803683370190505b509050600360fc1b81600081518110620004c057620004c062000844565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110620004f257620004f262000844565b60200101906001600160f81b031916908160001a905350600062000518846002620009b6565b6200052590600162000870565b90505b6001811115620005a7576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106200055d576200055d62000844565b1a60f81b82828151811062000576576200057662000844565b60200101906001600160f81b031916908160001a90535060049490941c936200059f81620009d8565b905062000528565b508315620005f85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640162000229565b9392505050565b6001830191839082156200068a5791602002820160005b838211156200065857835183826101000a81548161ffff021916908361ffff160217905550926020019260020160208160010104928301926001030262000616565b8015620006885782816101000a81549061ffff021916905560020160208160010104928301926001030262000658565b505b50620006989291506200069c565b5090565b5b808211156200069857600081556001016200069d565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b0381118282101715620006ee57620006ee620006b3565b60405290565b805161ffff811681146200070757600080fd5b919050565b60405160009060c081016001600160401b0381118282101715620007345762000734620006b3565b60405290508060c08301848111156200074c57600080fd5b835b8181101562000771576200076281620006f4565b8352602092830192016200074e565b50505092915050565b60008060008061016085870312156200079257600080fd5b845162ffffff81168114620007a657600080fd5b809450506020808601518015158114620007bf57600080fd5b9350605f86018713620007d157600080fd5b620007db620006c9565b8060a0880189811115620007ee57600080fd5b604089015b8181101562000815576200080781620006f4565b8452928401928401620007f3565b508195508960bf8a01126200082957600080fd5b620008358a826200070c565b94505050505092959194509250565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600082198211156200088657620008866200085a565b500190565b600060ff821660ff8103620008a457620008a46200085a565b60010192915050565b600060ff821660ff84168060ff03821115620008cd57620008cd6200085a565b019392505050565b60005b83811015620008f2578181015183820152602001620008d8565b8381111562000902576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835162000942816017850160208801620008d5565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835162000975816028840160208801620008d5565b01602801949350505050565b6020815260008251806020840152620009a2816040850160208701620008d5565b601f01601f19169190910160400192915050565b6000816000190483118215151615620009d357620009d36200085a565b500290565b600081620009ea57620009ea6200085a565b506000190190565b6122098062000a026000396000f3fe6080604052600436106101795760003560e01c80635c975abb116100cb578063b94265b81161007f578063d547741f11610059578063d547741f1461057d578063dc12365f1461059d578063e8f08c1b146105d057600080fd5b8063b94265b8146104f7578063c63602a014610517578063ce5cae921461055d57600080fd5b806391d14854116100b057806391d148541461046a578063a217fddf146104ae578063ab400706146104c357600080fd5b80635c975abb146104325780637700f17b1461044a57600080fd5b80632ee7754d1161012d57806336568abe1161010757806336568abe146103a75780633a8e7bdc146103c75780634b7f8ba4146103f757600080fd5b80632ee7754d146102895780632f2ff15d146102aa5780633171b76f146102ca57600080fd5b806318452cd81161015e57806318452cd8146101fc5780632434850f14610237578063248a9ca31461025957600080fd5b806301ffc9a7146101855780630eb71432146101ba57600080fd5b3661018057005b600080fd5b34801561019157600080fd5b506101a56101a0366004611bc0565b6105f0565b60405190151581526020015b60405180910390f35b3480156101c657600080fd5b506101ee7f591fa5458fe051cc8c02c405479bd38e00713c98dbd3db209d982048f1e638fa81565b6040519081526020016101b1565b34801561020857600080fd5b506101a5610217366004611c1e565b6001600160a01b0390811660009081526008602052604090205416151590565b34801561024357600080fd5b50610257610252366004611d1a565b610689565b005b34801561026557600080fd5b506101ee610274366004611dcf565b60009081526020819052604090206001015490565b34801561029557600080fd5b506003546101a5906301000000900460ff1681565b3480156102b657600080fd5b506102576102c5366004611de8565b610962565b3480156102d657600080fd5b506103716102e5366004611c1e565b6040805160608082018352600080835260208084018290529284018190526001600160a01b039485168152600883528390208351918201845254938416815274010000000000000000000000000000000000000000840462ffffff16918101919091527701000000000000000000000000000000000000000000000090920463ffffffff169082015290565b6040805182516001600160a01b0316815260208084015162ffffff16908201529181015163ffffffff16908201526060016101b1565b3480156103b357600080fd5b506102576103c2366004611de8565b61098d565b3480156103d357600080fd5b506003546103e39062ffffff1681565b60405162ffffff90911681526020016101b1565b34801561040357600080fd5b50610417610412366004611dcf565b610a33565b6040805161ffff9384168152929091166020830152016101b1565b34801561043e57600080fd5b5060015460ff166101a5565b34801561045657600080fd5b506101ee610465366004611e14565b610a58565b34801561047657600080fd5b506101a5610485366004611de8565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156104ba57600080fd5b506101ee600081565b3480156104cf57600080fd5b506101ee7f6a64baf327d646d1bca72653e2a075d15fd6ac6d8cbd7f6ee03fc55875e0fa8881565b34801561050357600080fd5b50610257610512366004611e50565b610d35565b34801561052357600080fd5b506101ee610532366004611e50565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205490565b34801561056957600080fd5b50610257610578366004611c1e565b610e9e565b34801561058957600080fd5b50610257610598366004611de8565b610f97565b3480156105a957600080fd5b506105bd6105b8366004611dcf565b610fbd565b60405161ffff90911681526020016101b1565b3480156105dc57600080fd5b506102576105eb366004611e7a565b610feb565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b00000000000000000000000000000000000000000000000000000000148061068357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b60006106958133611358565b60006003815b818160ff1610156106e257858160ff16600381106106bb576106bb611eef565b60200201516106ce9061ffff1684611f4d565b9250806106da81611f65565b91505061069b565b5061271082111561071f576040517f47b2d1a100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600380548715156301000000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000090911662ffffff8a1617178155610768906002908790611b15565b506003546040805162ffffff83168152630100000090920460ff16151560208084019190915260025461ffff80821685850152601082901c81166060860152911c166080830152517ff00824b816a4531d705cd1029abff952a032e648db7de396f9f0f8c539fc4f2b9160a0908290030190a160006006815b818160ff161015610956576000878260ff166006811061080357610803611eef565b60200201519050600088610818846001611f84565b60ff166006811061082b5761082b611eef565b602002015190506127108161ffff16111561087d576040517f3d78bdfc00000000000000000000000000000000000000000000000000000000815261ffff821660048201526024015b60405180910390fd5b60405180604001604052808361ffff1681526020018261ffff1681525060048660ff16600381106108b0576108b0611eef565b82519101805460209384015161ffff90811662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000090921693811693909317179055604080518583168152918416928201929092527f93b1de1f3c33ea5943767b6d6cf51236c3832c86fb3ffd41a92f0f807eb6fee6910160405180910390a18461093d81611f65565b955050505060028161094f9190611f84565b90506107e1565b50505050505050505050565b60008281526020819052604090206001015461097e8133611358565b610988838361140e565b505050565b6001600160a01b0381163314610a25576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610874565b610a2f82826114ca565b5050565b60048160038110610a4357600080fd5b015461ffff8082169250620100009091041682565b60007f591fa5458fe051cc8c02c405479bd38e00713c98dbd3db209d982048f1e638fa610a858133611358565b6001600160a01b0385811660009081526008602090815260408083208151606081018352905494851680825274010000000000000000000000000000000000000000860462ffffff16938201939093527701000000000000000000000000000000000000000000000090940463ffffffff169084015290919015610d2b57600360005b818160ff161015610d285782516001600160a01b0380821660008181526008602090815260409182902082516060810184529054948516815274010000000000000000000000000000000000000000850462ffffff16918101919091527701000000000000000000000000000000000000000000000090930463ffffffff1690830152610b96575050610d28565b6003546301000000900460ff161580610bce575060035460408201514291610bc59162ffffff90911690611fa9565b63ffffffff1610155b15610d12576000612710610be58360200151611567565b61ffff1661271060028760ff1660038110610c0257610c02611eef565b601091828204019190066002029054906101000a900461ffff1661ffff168d610c2b9190611fd1565b610c35919061200e565b610c3f9190611fd1565b610c49919061200e565b9050610c558188611f4d565b96508060076000856001600160a01b03166001600160a01b0316815260200190815260200160002060008d6001600160a01b03166001600160a01b031681526020019081526020016000206000828254610caf9190611f4d565b90915550610cc09050846001611f84565b60ff168b6001600160a01b0316846001600160a01b03167f5529ef3a23da49436a47cbc1306b610f6f0860de4d1ecea8a7913488726044c184604051610d0891815260200190565b60405180910390a4505b9350819050610d2081611f65565b915050610b08565b50505b5095945050505050565b7f6a64baf327d646d1bca72653e2a075d15fd6ac6d8cbd7f6ee03fc55875e0fa88610d608133611358565b6001600160a01b0382161561098857610d7982846115f8565b610988576001600160a01b0383811660009081526008602052604090205416610988576001600160a01b03838116600090815260086020526040808220928516808352912082547fffffffffff00000000ffffff000000000000000000000000000000000000000016909117770100000000000000000000000000000000000000000000004263ffffffff160217825580546001908290601490610e3b90849074010000000000000000000000000000000000000000900462ffffff16612049565b92506101000a81548162ffffff021916908362ffffff160217905550836001600160a01b0316856001600160a01b03167ffaf63637882ff2d63ca76881cf92fb857130e36f350c926f9cc884b499b42b7760405160405180910390a35050505050565b7f6a64baf327d646d1bca72653e2a075d15fd6ac6d8cbd7f6ee03fc55875e0fa88610ec98133611358565b6001600160a01b0382166000908152600860205260409020805474010000000000000000000000000000000000000000900462ffffff16156109885780547fffffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffff16770100000000000000000000000000000000000000000000004263ffffffff81169182029290921783556040519081526001600160a01b038516907f040d3d9ad766cf2f7b2b1276ed725eb6e7e9864c6f19fcd411ccefc4ee432cc59060200160405180910390a250505050565b600082815260208190526040902060010154610fb38133611358565b61098883836114ca565b60028160038110610fcd57600080fd5b60109182820401919006600202915054906101000a900461ffff1681565b3360005b60ff811683111561110857600084848360ff1681811061101157611011611eef565b90506020020160208101906110269190611c1e565b6001600160a01b0380851660009081526007602090815260408083209385168352929052205490915080156110f3576001600160a01b038085166000908152600760209081526040808320938616808452939091528120556110915761108c848261167a565b6110a5565b6110a56001600160a01b03831685836117c7565b816001600160a01b0316846001600160a01b03167f6f8ec2b930fcc8511256f97d7be5b762ce92fd2cb30972b801cff4e4ca0a8eca836040516110ea91815260200190565b60405180910390a35b5050808061110090611f65565b915050610fef565b50505050565b6060600061111d836002611fd1565b611128906002611f4d565b67ffffffffffffffff81111561114057611140611c4a565b6040519080825280601f01601f19166020018201604052801561116a576020820181803683370190505b5090507f3000000000000000000000000000000000000000000000000000000000000000816000815181106111a1576111a1611eef565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061120457611204611eef565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000611240846002611fd1565b61124b906001611f4d565b90505b60018111156112e8577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061128c5761128c611eef565b1a60f81b8282815181106112a2576112a2611eef565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c936112e181612067565b905061124e565b508315611351576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610874565b9392505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610a2f57611394816001600160a01b0316601461110e565b61139f83602061110e565b6040516020016113b09291906120c8565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f08c379a000000000000000000000000000000000000000000000000000000000825261087491600401612149565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610a2f576000828152602081815260408083206001600160a01b0385168452909152902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001660011790556114863390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1615610a2f576000828152602081815260408083206001600160a01b038516808552925280832080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60045460009062010000900461ffff16600360015b818160ff1610156115ef57600060048260ff166003811061159f5761159f611eef565b6040805180820190915291015461ffff8082168084526201000090920416602083015290915062ffffff871610156115d757506115ef565b602001519250806115e781611f65565b91505061157c565b50909392505050565b6000826003825b818160ff16101561166e576001600160a01b0383161561166e57846001600160a01b0316836001600160a01b03160361163e5760019350505050610683565b6001600160a01b03928316600090815260086020526040902054909216918061166681611f65565b9150506115ff565b50600095945050505050565b804710156116e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610874565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611731576040519150601f19603f3d011682016040523d82523d6000602084013e611736565b606091505b5050905080610988576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610874565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092018352602080830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526109889286929160009161188591851690849061192f565b80519091501561098857808060200190518101906118a3919061219a565b610988576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610874565b606061193e8484600085611946565b949350505050565b6060824710156119d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610874565b6001600160a01b0385163b611a49576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610874565b600080866001600160a01b03168587604051611a6591906121b7565b60006040518083038185875af1925050503d8060008114611aa2576040519150601f19603f3d011682016040523d82523d6000602084013e611aa7565b606091505b5091509150611ab7828286611ac2565b979650505050505050565b60608315611ad1575081611351565b825115611ae15782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108749190612149565b600183019183908215611b9b5791602002820160005b83821115611b6b57835183826101000a81548161ffff021916908361ffff1602179055509260200192600201602081600101049283019260010302611b2b565b8015611b995782816101000a81549061ffff0219169055600201602081600101049283019260010302611b6b565b505b50611ba7929150611bab565b5090565b5b80821115611ba75760008155600101611bac565b600060208284031215611bd257600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461135157600080fd5b80356001600160a01b0381168114611c1957600080fd5b919050565b600060208284031215611c3057600080fd5b61135182611c02565b8015158114611c4757600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff81118282101715611c9c57611c9c611c4a565b60405290565b803561ffff81168114611c1957600080fd5b600060405160c0810181811067ffffffffffffffff82111715611cd957611cd9611c4a565b60405290508060c0830184811115611cf057600080fd5b835b81811015611d1157611d0381611ca2565b835260209283019201611cf2565b50505092915050565b6000806000806101608587031215611d3157600080fd5b843562ffffff81168114611d4457600080fd5b9350602085810135611d5581611c39565b9350605f86018713611d6657600080fd5b611d6e611c79565b8060a0880189811115611d8057600080fd5b604089015b81811015611da357611d9681611ca2565b8452928401928401611d85565b508195508960bf8a0112611db657600080fd5b611dc08a82611cb4565b94505050505092959194509250565b600060208284031215611de157600080fd5b5035919050565b60008060408385031215611dfb57600080fd5b82359150611e0b60208401611c02565b90509250929050565b600080600060608486031215611e2957600080fd5b611e3284611c02565b9250611e4060208501611c02565b9150604084013590509250925092565b60008060408385031215611e6357600080fd5b611e6c83611c02565b9150611e0b60208401611c02565b60008060208385031215611e8d57600080fd5b823567ffffffffffffffff80821115611ea557600080fd5b818501915085601f830112611eb957600080fd5b813581811115611ec857600080fd5b8660208260051b8501011115611edd57600080fd5b60209290920196919550909350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115611f6057611f60611f1e565b500190565b600060ff821660ff8103611f7b57611f7b611f1e565b60010192915050565b600060ff821660ff84168060ff03821115611fa157611fa1611f1e565b019392505050565b600063ffffffff808316818516808303821115611fc857611fc8611f1e565b01949350505050565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561200957612009611f1e565b500290565b600082612044577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b600062ffffff808316818516808303821115611fc857611fc8611f1e565b60008161207657612076611f1e565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190565b60005b838110156120b757818101518382015260200161209f565b838111156111085750506000910152565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161210081601785016020880161209c565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161213d81602884016020880161209c565b01602801949350505050565b602081526000825180602084015261216881604085016020870161209c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169190910160400192915050565b6000602082840312156121ac57600080fd5b815161135181611c39565b600082516121c981846020870161209c565b919091019291505056fea2646970667358221220c78a64397371ca28fdb439e6de8d901582f29914bda5dbe54d1e0e05dcc370e964736f6c634300080e00330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017700000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000001388000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000002710

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

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017700000000000000000000000000000000000000000000000000000000000000bb800000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000001388000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000002710

-----Decoded View---------------
Arg [0] : _secondsUntilInactive (uint24): 0
Arg [1] : _onlyRewardActiveReferrers (bool): False
Arg [2] : _levelRate (uint16[3]): 6000,3000,1000
Arg [3] : _refereeBonusRateMap (uint16[6]): 1,2500,5,5000,10,10000

-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [2] : 0000000000000000000000000000000000000000000000000000000000001770
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000bb8
Arg [4] : 00000000000000000000000000000000000000000000000000000000000003e8
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [6] : 00000000000000000000000000000000000000000000000000000000000009c4
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [8] : 0000000000000000000000000000000000000000000000000000000000001388
Arg [9] : 000000000000000000000000000000000000000000000000000000000000000a
Arg [10] : 0000000000000000000000000000000000000000000000000000000000002710


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading