BNB Price: $617.84 (+0.63%)
 

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Bulk Register925921192026-04-15 1:41:134 mins ago1776217273IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.08170721 BNB0.000018010.05
Bulk Register925547102026-04-14 21:00:294 hrs ago1776200429IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00822766 BNB0.000023770.05001
Bulk Renew925010342026-04-14 14:17:3211 hrs ago1776176252IN
SPACE ID .bnb Name Service: Registrar Controller 2
0 BNB0.000007410.052
Bulk Register924938922026-04-14 13:23:4812 hrs ago1776173028IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.01637077 BNB0.000017780.05
Bulk Register924802382026-04-14 11:41:1114 hrs ago1776166871IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00819723 BNB0.000018420.05
Bulk Register924209752026-04-14 4:16:1121 hrs ago1776140171IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.03280478 BNB0.000018190.05
Bulk Register924066242026-04-14 2:28:1923 hrs ago1776133699IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00822233 BNB0.000017650.05
Bulk Register923952702026-04-14 1:03:0524 hrs ago1776128585IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00825814 BNB0.000014110.05
Bulk Register923454572026-04-13 18:49:1430 hrs ago1776106154IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00834574 BNB0.000018480.05
Bulk Register923448712026-04-13 18:44:5031 hrs ago1776105890IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00834419 BNB0.00002370.05
Bulk Register923435132026-04-13 18:34:3831 hrs ago1776105278IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00835301 BNB0.000023860.05
Bulk Register923423832026-04-13 18:26:0931 hrs ago1776104769IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00835667 BNB0.000022780.05
Bulk Register923411112026-04-13 18:16:3731 hrs ago1776104197IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00834352 BNB0.000018970.05
Bulk Register923384642026-04-13 17:56:4531 hrs ago1776103005IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00834657 BNB0.000018530.05
Bulk Register923326192026-04-13 17:12:5332 hrs ago1776100373IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00832775 BNB0.000038410.1
Bulk Register923137842026-04-13 14:51:2134 hrs ago1776091881IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.03357801 BNB0.000018160.05
Bulk Register922686752026-04-13 9:12:2740 hrs ago1776071547IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00845573 BNB0.000017690.05
Bulk Register922394542026-04-13 5:32:1144 hrs ago1776058331IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.0339103 BNB0.000018760.05
Bulk Renew922140412026-04-13 2:21:1047 hrs ago1776046870IN
SPACE ID .bnb Name Service: Registrar Controller 2
0 BNB0.000006790.05
Bulk Register921098362026-04-12 13:18:482 days ago1775999928IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.03408214 BNB0.000018170.05
Bulk Register920790212026-04-12 9:27:052 days ago1775986025IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.03397695 BNB0.00001780.05
Bulk Register920629832026-04-12 7:26:422 days ago1775978802IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00850537 BNB0.000026770.1
Bulk Register920153852026-04-12 1:29:163 days ago1775957356IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.00832674 BNB0.000020770.05
Bulk Register920128782026-04-12 1:10:263 days ago1775956226IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.05823248 BNB0.000017890.05
Bulk Register919526392026-04-11 17:38:243 days ago1775929104IN
SPACE ID .bnb Name Service: Registrar Controller 2
0.05814116 BNB0.000017950.05
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
925921192026-04-15 1:41:134 mins ago1776217273
SPACE ID .bnb Name Service: Registrar Controller 2
0.00080898 BNB
925547102026-04-14 21:00:294 hrs ago1776200429
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008268 BNB
924938922026-04-14 13:23:4812 hrs ago1776173028
SPACE ID .bnb Name Service: Registrar Controller 2
0.00016208 BNB
924802382026-04-14 11:41:1114 hrs ago1776166871
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008116 BNB
924209752026-04-14 4:16:1121 hrs ago1776140171
SPACE ID .bnb Name Service: Registrar Controller 2
0.00032479 BNB
924066242026-04-14 2:28:1923 hrs ago1776133699
SPACE ID .bnb Name Service: Registrar Controller 2
0.0000814 BNB
923952702026-04-14 1:03:0524 hrs ago1776128585
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008176 BNB
923454572026-04-13 18:49:1430 hrs ago1776106154
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008263 BNB
923448712026-04-13 18:44:5031 hrs ago1776105890
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008582 BNB
923435132026-04-13 18:34:3831 hrs ago1776105278
SPACE ID .bnb Name Service: Registrar Controller 2
0.0000827 BNB
923423832026-04-13 18:26:0931 hrs ago1776104769
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008273 BNB
923411112026-04-13 18:16:3731 hrs ago1776104197
SPACE ID .bnb Name Service: Registrar Controller 2
0.0000826 BNB
923384642026-04-13 17:56:4531 hrs ago1776103005
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008263 BNB
923326192026-04-13 17:12:5332 hrs ago1776100373
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008086 BNB
923137842026-04-13 14:51:2134 hrs ago1776091881
SPACE ID .bnb Name Service: Registrar Controller 2
0.00033245 BNB
922686752026-04-13 9:12:2740 hrs ago1776071547
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008372 BNB
922394542026-04-13 5:32:1144 hrs ago1776058331
SPACE ID .bnb Name Service: Registrar Controller 2
0.00033574 BNB
921098362026-04-12 13:18:482 days ago1775999928
SPACE ID .bnb Name Service: Registrar Controller 2
0.00033848 BNB
920790212026-04-12 9:27:052 days ago1775986025
SPACE ID .bnb Name Service: Registrar Controller 2
0.0003364 BNB
920629832026-04-12 7:26:422 days ago1775978802
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008421 BNB
920153852026-04-12 1:29:163 days ago1775957356
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008244 BNB
920128782026-04-12 1:10:263 days ago1775956226
SPACE ID .bnb Name Service: Registrar Controller 2
0.00057655 BNB
919526392026-04-11 17:38:243 days ago1775929104
SPACE ID .bnb Name Service: Registrar Controller 2
0.00057565 BNB
919523882026-04-11 17:36:313 days ago1775928991
SPACE ID .bnb Name Service: Registrar Controller 2
0.00032892 BNB
919305462026-04-11 14:52:173 days ago1775919137
SPACE ID .bnb Name Service: Registrar Controller 2
0.00008265 BNB
View All Internal Transactions
Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RegistrarController

Compiler Version
v0.8.12+commit.f00d7308

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

import "./BaseRegistrarImplementation.sol";
import "./StringUtils.sol";
import {ReferralHub} from "../referral/ReferralHub.sol";
import {ReferralVerifier} from "../referral/ReferralVerifier.sol";
import {SidGiftCardLedger} from "../giftcard/SidGiftCardLedger.sol";
import {ISidPriceOracle} from "../price-oracle/ISidPriceOracle.sol";
import {IRegistrarController} from "./IRegistrarController.sol";
import {ReverseRegistrar} from "../registry/ReverseRegistrar.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {ReferralInfo} from "../struct/SidStruct.sol";
import {RegInfo} from "../struct/SidStruct.sol";
import {Resolver} from "../resolvers/Resolver.sol";

/**
 * @dev Registrar with giftcard and referral support
 *
 */
contract RegistrarController is IRegistrarController, Ownable, ReentrancyGuard {
    using StringUtils for *;

    uint public constant MIN_REGISTRATION_DURATION = 365 days;
    

    BaseRegistrarImplementation base;
    SidGiftCardLedger giftCardLedger;
    ISidPriceOracle prices;
    ReferralHub referralHub;
    ReferralVerifier referralVerifier;
    ReverseRegistrar reverseRegistrar;
    

    //fund controller
    address public treasuryManager;

    uint256 public version;

    string public subfix = ".bnb";

    modifier onlyTreasuryManager() {
        require(msg.sender == treasuryManager, "Only treasury manager can withdraw");
        _;
    }

    constructor(
        BaseRegistrarImplementation _base,
        ISidPriceOracle _prices,
        SidGiftCardLedger _giftCardLedger,
        ReferralHub _referralHub,
        ReferralVerifier _referralVerifier,
        ReverseRegistrar _reverseRegistrar,
        address _treasuryManager,
        uint256 _version
    ) {
        base = _base;
        prices = _prices;
        giftCardLedger = _giftCardLedger;
        referralHub = _referralHub;
        referralVerifier = _referralVerifier;
        reverseRegistrar = _reverseRegistrar;
        treasuryManager = _treasuryManager;
        version = _version;
    }

    function rentPrice(string calldata name, uint256 duration) public view returns (ISidPriceOracle.Price memory price) {
        bytes32 label = keccak256(bytes(name));
        price = prices.domainPriceInBNB(name, base.nameExpires(uint256(label)), duration);
    }

    function rentPriceWithPoint(string calldata name, uint256 duration, address registerAddress) public view returns (ISidPriceOracle.Price memory price) {
        bytes32 label = keccak256(bytes(name));
        price = prices.domainPriceWithPointRedemptionInBNB(name, base.nameExpires(uint256(label)), duration, registerAddress);
    }

    function valid(string calldata name) public pure returns (bool) {
        // check unicode rune count, if rune count is >=3, byte length must be >=3.
        if (name.strlen() < 3) {
            return false;
        }
        bytes memory nb = bytes(name);
        // zero width for /u200b /u200c /u200d and U+FEFF
        for (uint256 i; i < nb.length - 2; i++) {
            if (bytes1(nb[i]) == 0xe2 && bytes1(nb[i + 1]) == 0x80) {
                if (bytes1(nb[i + 2]) == 0x8b || bytes1(nb[i + 2]) == 0x8c || bytes1(nb[i + 2]) == 0x8d) {
                    return false;
                }
            } else if (bytes1(nb[i]) == 0xef) {
                if (bytes1(nb[i + 1]) == 0xbb && bytes1(nb[i + 2]) == 0xbf) return false;
            }
        }
        return true;
    }

    function available(string calldata name) public view returns (bool) {
        bytes32 label = keccak256(bytes(name));
        return valid(name) && base.available(uint256(label));
    }

    // because this function returns fund based on msg.value
    // it MUST be an external function to avoid accidental call that
    // returns incorrect amount, e.g., bulk register.
    function register(string calldata name, address owner, uint duration) external payable {
        uint256 cost = _registerWithConfigAndPoint(name, RegInfo(owner, duration, address(0), false, false, msg.value), ReferralInfo(address(0), bytes32(0), 0, 0, bytes("")));
        // Refund any extra payment
        if (msg.value > cost) {
            (bool sent, ) = msg.sender.call{value: msg.value - cost}("");
            require(sent, "Failed to send Ether");
        }
    }

    // because this function returns fund based on msg.value
    // it MUST be an external function to avoid accidental call that
    // returns incorrect amount, e.g., bulk register.
    function registerWithConfigAndPoint(string calldata name, address owner, uint duration, address resolver, bool isUsePoints, bool isSetPrimaryName, ReferralInfo memory referralInfo) external payable {
        uint256 cost = _registerWithConfigAndPoint(name, RegInfo(owner, duration, resolver, isUsePoints, isSetPrimaryName, msg.value), referralInfo);
        // Refund any extra payment
        if (msg.value > cost) {
            (bool sent, ) = msg.sender.call{value: msg.value - cost}("");
            require(sent, "Failed to send Ether");
        }
    }
    
    function _registerWithConfigAndPoint(string calldata name, RegInfo memory regInfo, ReferralInfo memory referralInfo) internal nonReentrant returns (uint256 cost) {
        cost = _cost(name, regInfo.duration, regInfo.isUsePoints);

        bytes32 label = keccak256(bytes(name));
        uint256 tokenId = uint256(label);

        uint expires;
        if (regInfo.resolver != address(0)) {
            // Set this contract as the (temporary) owner, giving it
            // permission to set up the resolver.
            expires = base.register(tokenId, address(this), regInfo.duration);

            // The nodehash of this label
            bytes32 nodehash = keccak256(abi.encodePacked(base.baseNode(), label));

            // Set the resolver
            base.sid().setResolver(nodehash, regInfo.resolver);

            Resolver(regInfo.resolver).setAddr(nodehash, regInfo.owner);

            // Now transfer full ownership to the expeceted owner
            base.reclaim(tokenId, regInfo.owner);
            base.transferFrom(address(this), regInfo.owner, tokenId);
        } else {
            expires = base.register(tokenId, regInfo.owner, regInfo.duration);
        }

        emit NameRegistered(name, label, regInfo.owner, cost, expires);

        // Check if it is eligible for referral program
        if (referralInfo.referrerAddress != address(0)) {
            cost = _handleReferral(cost, referralInfo.referrerAddress, referralInfo.referrerNodehash, referralInfo.referralAmount, referralInfo.signedAt, referralInfo.signature);
        }
        // Check if should set reverse record
        if (regInfo.isSetPrimaryName) {
            _setReverseRecord(name, regInfo.owner);
        }
        return cost;
    }

    function _handleReferral(uint cost, address referrerAddress, bytes32 referrerNodehash, uint256 referralAmount, uint256 signedAt, bytes memory signature) internal returns (uint) {
        require(referralVerifier.verifyReferral(referrerAddress, referrerNodehash, referralAmount, signedAt, signature), "Invalid referral signature");
        uint256 referrerFee = 0;
        uint256 refereeFee = 0;
        if (referralHub.isPartner(referrerNodehash)) {
            (referrerFee, refereeFee) = referralHub.getReferralCommisionFee(cost, referrerNodehash);
        } else {
            (referrerFee, refereeFee) = referralVerifier.getReferralCommisionFee(cost, referralAmount);
        }
        referralHub.addNewReferralRecord(referrerNodehash);
        if (referrerFee > 0) {
            referralHub.deposit{value: referrerFee}(referrerAddress);
        }
        return cost - refereeFee;
    }

    

    // because this function returns fund based on msg.value
    // it MUST be an external function to avoid accidental call that
    // returns incorrect amount, e.g., bulk register.
    function renew(string calldata name, uint duration) external payable {
        uint256 cost = _renewWithPoint(name, duration, false, msg.value);
        // Refund any extra payment
        if (msg.value > cost) {
            (bool sent, ) = msg.sender.call{value: msg.value - cost}("");
            require(sent, "Failed to send Ether");
        }
    }

    // because this function returns fund based on msg.value
    // it MUST be an external function to avoid accidental call that
    // returns incorrect amount, e.g., bulk register.
    function renewWithPoint(string calldata name, uint duration, bool isUsePoints) external payable {
        uint256 cost = _renewWithPoint(name, duration, isUsePoints, msg.value);
        // Refund any extra payment
        if (msg.value > cost) {
            (bool sent, ) = msg.sender.call{value: msg.value - cost}("");
            require(sent, "Failed to send Ether");
        }
    }

    function _renewWithPoint(string calldata name, uint duration, bool isUsePoints, uint256 paid) internal nonReentrant returns (uint256 cost) {
        ISidPriceOracle.Price memory price;
        if (isUsePoints) {
            price = rentPriceWithPoint(name, duration, msg.sender);
            //deduct points from gift card ledger
            giftCardLedger.deduct(msg.sender, price.usedPoint);
        } else {
            price = rentPrice(name, duration);
        }
        cost = (price.base + price.premium);
        require(paid >= cost);
        bytes32 label = keccak256(bytes(name));
        uint expires = base.renew(uint256(label), duration);
        emit NameRenewed(name, label, cost, expires);
        return cost;
    }

    function withdraw() public onlyTreasuryManager nonReentrant {
        (bool sent, ) = treasuryManager.call{value: address(this).balance}("");
        require(sent, "Failed to send Ether");
    }

    function _cost(string calldata name, uint duration, bool usePoints) internal returns (uint256) {
        require(available(name));
        ISidPriceOracle.Price memory price;
        if (usePoints) {
            uint256 senderBalance = giftCardLedger.balanceOf(msg.sender);
            price = rentPriceWithPoint(name, duration, msg.sender);
            // deduct points from gift card ledger
            giftCardLedger.deduct(msg.sender, price.usedPoint);
            assert(senderBalance == 0 || senderBalance > giftCardLedger.balanceOf(msg.sender));
        } else {
            price = rentPrice(name, duration);
        }
        uint cost = (price.base + price.premium);
        require(duration >= MIN_REGISTRATION_DURATION);
        require(msg.value >= cost);
        return cost;
    }

    function bulkRentPrice(string[] calldata names, uint256 duration) public view returns (uint256 total) {
        for (uint256 i = 0; i < names.length; i++) {
            ISidPriceOracle.Price memory price = rentPrice(names[i], duration);
            total += (price.base + price.premium);
        }
    }

    function bulkRegister(string[] calldata names, address owner, uint duration, address resolver, bool isUseGiftCard, bool isSetPrimaryName, ReferralInfo memory referralInfo) external payable {
        uint256 unspent = msg.value;
        for (uint256 i = 0; i < names.length; i++) {
            uint256 cost = _registerWithConfigAndPoint(names[i], RegInfo(owner, duration, resolver, isUseGiftCard, isSetPrimaryName, unspent), referralInfo);
            unspent -= cost;
        }
        // Refund any extra payment
        if (unspent > 0) {
            (bool sent, ) = msg.sender.call{value: unspent}("");
            require(sent, "Failed to send Ether");
        }
    }

    function bulkRenew(string[] calldata names, uint duration, bool isUsePoints) external payable {
        uint256 unspent = msg.value;
        for (uint256 i = 0; i < names.length; i++) {
            uint256 cost = _renewWithPoint(names[i], duration, isUsePoints, unspent);
            unspent -= cost;
        }
        // Refund any extra payment
        if (unspent > 0) {
            (bool sent, ) = msg.sender.call{value: unspent}("");
            require(sent, "Failed to send Ether");
        }
    }

    function setPriceOracle(ISidPriceOracle _prices) public onlyOwner {
        prices = _prices;
        emit NewPriceOracle(address(prices));
    }

    function setTreasuryManager(address _treasuryManager) public onlyOwner {
        require(_treasuryManager != address(0));
        treasuryManager = _treasuryManager;
        emit NewTreasuryManager(_treasuryManager);
    }

    function _setReverseRecord(string memory name, address owner) internal {
        address defaultResolver = address(reverseRegistrar.defaultResolver());
        reverseRegistrar.setNameForAddr(owner, owner, defaultResolver, string.concat(name, subfix));
    }
     
}

pragma solidity >=0.8.4;

library StringUtils {
    /**
     * @dev Returns the length of a given string
     *
     * @param s The string to measure the length of
     * @return The length of the input string
     */
    function strlen(string memory s) internal pure returns (uint) {
        uint len;
        uint i = 0;
        uint bytelength = bytes(s).length;
        for(len = 0; i < bytelength; len++) {
            bytes1 b = bytes(s)[i];
            if(b < 0x80) {
                i += 1;
            } else if (b < 0xE0) {
                i += 2;
            } else if (b < 0xF0) {
                i += 3;
            } else if (b < 0xF8) {
                i += 4;
            } else if (b < 0xFC) {
                i += 5;
            } else {
                i += 6;
            }
        }
        return len;
    }
}

pragma solidity >=0.8.4;

import "../registry/SID.sol";
import "./IBaseRegistrar.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

contract BaseRegistrarImplementation is ERC721, IERC721Enumerable, IBaseRegistrar, Ownable {
    // A map of expiry times
    mapping(uint256 => uint) expiries;
    // The SID registry
    SID public sid;
    // The namehash of the TLD this registrar owns (eg, .eth)
    bytes32 public baseNode;
    // A map of addresses that are authorised to register and renew names.
    mapping(address => bool) public controllers;
    uint256 public constant GRACE_PERIOD = 90 days;
    bytes4 private constant INTERFACE_META_ID = bytes4(keccak256("supportsInterface(bytes4)"));
    bytes4 private constant ERC721_ID =
        bytes4(
            keccak256("balanceOf(address)") ^
                keccak256("ownerOf(uint256)") ^
                keccak256("approve(address,uint256)") ^
                keccak256("getApproved(uint256)") ^
                keccak256("setApprovalForAll(address,bool)") ^
                keccak256("isApprovedForAll(address,address)") ^
                keccak256("transferFrom(address,address,uint256)") ^
                keccak256("safeTransferFrom(address,address,uint256)") ^
                keccak256("safeTransferFrom(address,address,uint256,bytes)")
        );
    bytes4 private constant RECLAIM_ID = bytes4(keccak256("reclaim(uint256,address)"));
    string public baseUri;
    string constant INVALID_INDEX = "005007";
    uint256[] internal tokens;
    mapping(uint256 => uint256) internal idToIndex;
    mapping(address => uint256[]) internal ownerToIds;

    /**
     * v2.1.3 version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes grace period into consideration instead of ERC721.ownerOf(tokenId);
     * https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v2.1.3/contracts/token/ERC721/ERC721.sol#L187
     * @dev Returns whether the given spender can transfer a given token ID
     * @param spender address of the spender to query
     * @param tokenId uint256 ID of the token to be transferred
     * @return bool whether the msg.sender is approved for the given token ID,
     *    is an operator of the owner, or is the owner of the token
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view override returns (bool) {
        address owner = ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    constructor(SID _sid, bytes32 _baseNode) ERC721("SPACE ID", "SID") {
        sid = _sid;
        baseNode = _baseNode;
    }

    modifier live() {
        require(sid.owner(baseNode) == address(this));
        _;
    }

    modifier onlyController() {
        require(controllers[msg.sender]);
        _;
    }

    function totalSupply() external view override returns (uint256) {
        return tokens.length;
    }

    function tokenByIndex(uint256 _index) external view override returns (uint256) {
        require(_index < tokens.length, INVALID_INDEX);
        return tokens[_index];
    }

    function tokenOfOwnerByIndex(address _owner, uint256 _index) external view override returns (uint256) {
        require(_index < ownerToIds[_owner].length, INVALID_INDEX);
        return ownerToIds[_owner][_index];
    }

    function _mint(address _to, uint256 _tokenId) internal virtual override {
        super._mint(_to, _tokenId);
        tokens.push(_tokenId);
        idToIndex[_tokenId] = tokens.length - 1;
    }

    function _burn(uint256 _tokenId) internal virtual override {
        super._burn(_tokenId);

        uint256 tokenIndex = idToIndex[_tokenId];
        uint256 lastTokenIndex = tokens.length - 1;
        uint256 lastToken = tokens[lastTokenIndex];

        tokens[tokenIndex] = lastToken;

        tokens.pop();
        // This wastes gas if you are burning the last token but saves a little gas if you are not.
        idToIndex[lastToken] = tokenIndex;
        idToIndex[_tokenId] = 0;
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public override(ERC721, IERC721) {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not approved or owner");

        _transfer(from, to, tokenId);
        sid.setSubnodeOwner(baseNode, bytes32(tokenId), to);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public override(ERC721, IERC721) {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not approved or owner");
        _safeTransfer(from, to, tokenId, _data);
        sid.setSubnodeOwner(baseNode, bytes32(tokenId), to);
    }

    /**
     * @dev Gets the owner of the specified token ID. Names become unowned
     *      when their registration expires.
     * @param tokenId uint256 ID of the token to query the owner of
     * @return address currently marked as the owner of the given token ID
     */
    function ownerOf(uint256 tokenId) public view override(IERC721, ERC721) returns (address) {
        require(expiries[tokenId] > block.timestamp);
        return super.ownerOf(tokenId);
    }

    // Authorises a controller, who can register and renew domains.
    function addController(address controller) external override onlyOwner {
        require(controller != address(0), "address can not be zero!");
        controllers[controller] = true;
        emit ControllerAdded(controller);
    }

    // Revoke controller permission for an address.
    function removeController(address controller) external override onlyOwner {
        require(controller != address(0), "address can not be zero!");
        controllers[controller] = false;
        emit ControllerRemoved(controller);
    }

    // Set the resolver for the TLD this registrar manages.
    function setResolver(address resolver) external override onlyOwner {
        sid.setResolver(baseNode, resolver);
    }

    // Returns the expiration timestamp of the specified id.
    function nameExpires(uint256 id) public view override returns (uint) {
        return expiries[id];
    }

    // Returns true iff the specified name is available for registration.
    function available(uint256 id) public view override returns (bool) {
        return expiries[id] + GRACE_PERIOD < block.timestamp;
    }

    /**
     * @dev Register a name.
     * @param id The token ID (keccak256 of the label).
     * @param owner The address that should own the registration.
     * @param duration Duration in seconds for the registration.
     */
    function register(
        uint256 id,
        address owner,
        uint duration
    ) external override returns (uint) {
        return _register(id, owner, duration, true);
    }

    /**
     * @dev Register a name, without modifying the registry.
     * @param id The token ID (keccak256 of the label).
     * @param owner The address that should own the registration.
     * @param duration Duration in seconds for the registration.
     */
    function registerOnly(
        uint256 id,
        address owner,
        uint duration
    ) external returns (uint) {
        return _register(id, owner, duration, false);
    }

    function _register(
        uint256 id,
        address owner,
        uint duration,
        bool updateRegistry
    ) internal live onlyController returns (uint) {
        require(available(id));
        require(block.timestamp + duration + GRACE_PERIOD > block.timestamp + GRACE_PERIOD); // Prevent future overflow

        expiries[id] = block.timestamp + duration;
        if (_exists(id)) {
            // Name was previously owned, and expired
            _burn(id);
        }
        _mint(owner, id);
        if (updateRegistry) {
            sid.setSubnodeOwner(baseNode, bytes32(id), owner);
        }

        emit NameRegistered(id, owner, block.timestamp + duration);

        return block.timestamp + duration;
    }

    function renew(uint256 id, uint duration) external override live onlyController returns (uint) {
        require(expiries[id] + GRACE_PERIOD >= block.timestamp); // Name must be registered here or in grace period
        require(expiries[id] + duration + GRACE_PERIOD > duration + GRACE_PERIOD); // Prevent future overflow
        expiries[id] += duration;
        emit NameRenewed(id, expiries[id]);
        return expiries[id];
    }

    /**
     * @dev Reclaim ownership of a name in SID, if you own it in the registrar.
     */
    function reclaim(uint256 id, address owner) external override live {
        require(_isApprovedOrOwner(msg.sender, id));
        sid.setSubnodeOwner(baseNode, bytes32(id), owner);
    }

    function supportsInterface(bytes4 interfaceID) public view override(ERC721, IERC165) returns (bool) {
        return interfaceID == INTERFACE_META_ID || interfaceID == ERC721_ID || interfaceID == RECLAIM_ID;
    }

    /**
     * PRIVILEGED MODULE FUNCTION. Sets a new baseURI for all token types.
     */
    function setURI(string memory newURI) external onlyOwner {
        baseUri = newURI;
    }

    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = baseUri;
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, Strings.toString(tokenId))) : "";
    }
}

pragma solidity >=0.8.4;

import "./ReferralVerifier.sol";
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {ReferralHub} from "./ReferralHub.sol";

contract ReferralVerifier is EIP712, Ownable, Pausable {
    address public spaceid_signer;
    uint256 public sigValidDuration;
    ReferralHub immutable referralHub;

    bytes32 private constant _REFERRAL_TYPEHASH = keccak256("Referral(address referrerAddress,bytes32 nodehash,uint256 referralCount,uint256 signedAt)");

    constructor(address _spaceid_signer, ReferralHub _referral_hub) EIP712("ReferralVerifier", "1.0.0") {
        spaceid_signer = _spaceid_signer;
        referralHub = _referral_hub;
        sigValidDuration = 5 minutes;
    }

    function setSpaceIdSigner(address _spaceid_signer) external onlyOwner {
        spaceid_signer = _spaceid_signer;
    }

    function setSigValidDuration(uint256 duration) external onlyOwner {
        sigValidDuration = duration;
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function _hash(address referrerAddress, bytes32 nodehash, uint256 referralCount, uint256 signedAt) public view returns (bytes32) {
        return _hashTypedDataV4(keccak256(abi.encode(_REFERRAL_TYPEHASH, referrerAddress, nodehash, referralCount, signedAt)));
    }

    function verifyReferral(address referrerAddress, bytes32 nodehash, uint256 referralCount, uint256 signedAt, bytes calldata signature) external view whenNotPaused returns (bool) {
        return block.timestamp < signedAt + sigValidDuration && _verifySignature(_hash(referrerAddress, nodehash, referralCount, signedAt), signature);
    }

    function getReferralCommisionFee(uint256 price, uint256 referralCount) external view returns (uint256, uint256) {
        uint256 curLevel = 1;
        (uint256 minimumReferralCount, uint256 referrerRate, uint256 refereeRate) = referralHub.comissionCharts(curLevel);
        while (referralCount > minimumReferralCount && curLevel <= 10) {
            (, referrerRate, refereeRate) = referralHub.comissionCharts(curLevel);
            (minimumReferralCount, , ) = referralHub.comissionCharts(++curLevel);
        }
        uint256 referrerFee = (price * referrerRate) / 100;
        uint256 refereeFee = (price * refereeRate) / 100;
        return (referrerFee, refereeFee);
    }

    function _verifySignature(bytes32 hash, bytes calldata signature) private view returns (bool) {
        return ECDSA.recover(hash, signature) == spaceid_signer;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "./IReferralHub.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../registry/SID.sol";
import "../resolvers/profiles/AddrResolver.sol";
import "../resolvers/profiles/NameResolver.sol";
import "../registry/IReverseRegistrar.sol";

contract ReferralHub is IReferralHub, Ownable, ReentrancyGuard {
    // ReferralHub controllers that can update referral count and related states.
    mapping(address => bool) public controllers;

    // Commission configuration
    struct Comission {
        // The number of minimum referrals that is required for the rate.
        uint256 minimumReferralCount;
        // Percentage of registration fee that will be deposited to referrer.
        uint256 referrer;
        // Percentage of registration fee that will be discounted to referee.
        uint256 referee;
    }
    //map comission chart to a level
    mapping(uint256 => Comission) public comissionCharts;
    // map from refferral domain name nodehash to the number of referrals.
    mapping(bytes32 => uint256) public referralCount;
    // map address to the amount of bonus.
    mapping(address => uint256) public referralBalance;
    // Map partner's domain's nodehash to customized commission rate.
    mapping(bytes32 => Comission) public partnerComissionCharts;

    bytes32 constant ADDR_REVERSE_NODE = 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2;
    bytes32 constant lookup = 0x3031323334353637383961626364656600000000000000000000000000000000;

    SID immutable sid;

    constructor(SID _sid) {
        sid = _sid;
        comissionCharts[1] = Comission(0, 5, 0);
        comissionCharts[2] = Comission(30, 8, 0);
        comissionCharts[3] = Comission(100, 11, 0);
        comissionCharts[4] = Comission(600, 15, 0);
        comissionCharts[5] = Comission(100000000, 15, 0);
        comissionCharts[6] = Comission(100000000, 15, 0);
        comissionCharts[7] = Comission(100000000, 15, 0);
        comissionCharts[8] = Comission(100000000, 15, 0);
        comissionCharts[9] = Comission(100000000, 15, 0);
        comissionCharts[10] = Comission(100000000, 15, 0);
    }

    modifier onlyController() {
        require(controllers[msg.sender], "Not a authorized controller");
        _;
    }

    modifier validLevel(uint256 _level) {
        require(_level >= 1 && _level <= 10, "Invalid level");
        _;
    }

    function getNodehash(string calldata name, string calldata tld) public pure returns (bytes32) {
        bytes32 nameHash = keccak256(bytes(name));
        bytes32 tldHash = keccak256(abi.encodePacked(bytes32(0), keccak256(bytes(tld))));
        return keccak256(abi.encodePacked(tldHash, nameHash));
    }

    function getReverseNodehash(address addr) public pure returns (bytes32) {
        return keccak256(abi.encodePacked(ADDR_REVERSE_NODE, sha3HexAddress(addr)));
    }

    /**
     * @dev An optimised function to compute the sha3 of the lower-case
     *      hexadecimal representation of an Ethereum address.
     * @param addr The address to hash
     * @return ret The SHA3 hash of the lower-case hexadecimal encoding of the
     *         input address.
     */
    function sha3HexAddress(address addr) private pure returns (bytes32 ret) {
        assembly {
            for {
                let i := 40
            } gt(i, 0) {

            } {
                i := sub(i, 1)
                mstore8(i, byte(and(addr, 0xf), lookup))
                addr := div(addr, 0x10)
                i := sub(i, 1)
                mstore8(i, byte(and(addr, 0xf), lookup))
                addr := div(addr, 0x10)
            }
            ret := keccak256(0, 40)
        }
    }

    function isReferralEligible(bytes32 nodeHash) external view override returns (bool, address) {
        address resolverAddress = sid.resolver(nodeHash);
        if (resolverAddress == address(0)) {
            return (false, address(0));
        }
        AddrResolver resolver = AddrResolver(resolverAddress);
        address resolvedAddress = resolver.addr(nodeHash);
        bytes32 reverseNodeHash = getReverseNodehash(resolvedAddress);
        address reverseResolverAddress = sid.resolver(reverseNodeHash);

        if (reverseResolverAddress == address(0)) {
            return (false, address(0));
        }

        return (true, resolvedAddress);
    }

    function isPartner(bytes32 nodeHash) public view returns (bool) {
        return partnerComissionCharts[nodeHash].referrer > 0 || partnerComissionCharts[nodeHash].referee > 0;
    }

    function getReferralCommisionFee(uint256 price, bytes32 nodeHash) public view returns (uint256, uint256) {
        uint256 referrerRate = 0;
        uint256 refereeRate = 0;
        uint256 level = 1;
        if (isPartner(nodeHash)) {
            referrerRate = partnerComissionCharts[nodeHash].referrer;
            refereeRate = partnerComissionCharts[nodeHash].referee;
        } else {
            (level, referrerRate, refereeRate) = _getComissionChart(referralCount[nodeHash]);
        }
        uint256 referrerFee = (price * referrerRate) / 100;
        uint256 refereeFee = (price * refereeRate) / 100;
        return (referrerFee, refereeFee);
    }

    function setPartnerComissionChart(
        string calldata name,
        string calldata tld,
        uint256 minimumReferralCount,
        uint256 referrerRate,
        uint256 refereeRate
    ) external onlyOwner {
        bytes32 nodeHash = getNodehash(name, tld);
        partnerComissionCharts[nodeHash] = Comission(minimumReferralCount, referrerRate, refereeRate);
    }

    function addNewReferralRecord(bytes32 referrerNodeHash) external override onlyController {
        referralCount[referrerNodeHash] += 1;
        emit NewReferralRecord(referrerNodeHash);
    }

    function _getReferralCount(bytes32 referrerNodeHash) internal view returns (uint256) {
        return referralCount[referrerNodeHash];
    }

    function _getComissionChart(uint256 referralAmount)
        internal
        view
        returns (
            uint256,
            uint256,
            uint256
        )
    {
        uint256 curLevel = 1;
        uint256 referrerRate;
        uint256 refereeRate;
        uint256 level;
        while (referralAmount >= comissionCharts[curLevel].minimumReferralCount && curLevel <= 10)  {
            referrerRate = comissionCharts[curLevel].referrer;
            refereeRate = comissionCharts[curLevel].referee;
            level = curLevel;
            curLevel += 1;
        }
        return (level, referrerRate, refereeRate);
    }

    function getReferralDetails(bytes32 referrerNodeHash)
        external
        view
        override
        returns (
            uint256,
            uint256,
            uint256,
            uint256
        )
    {
        uint256 referralNum = _getReferralCount(referrerNodeHash);
        (uint256 level, uint256 referrerRate, uint256 refereeRate) = _getComissionChart(referralNum);
        return (referralNum, level, referrerRate, refereeRate);
    }

    function setComissionChart(
        uint256 level,
        uint256 minimumAmount,
        uint256 referrerRate,
        uint256 refereeRate
    ) external onlyOwner validLevel(level) {
        comissionCharts[level] = Comission(minimumAmount, referrerRate, refereeRate);
    }

    function deposit(address _referrer) external payable onlyController{
        require(msg.value > 0, "Invalid amount");
        referralBalance[_referrer] += msg.value;
        emit depositRecord(_referrer, msg.value);
    }

    function withdraw() external nonReentrant{
        uint256 amount = referralBalance[msg.sender];
        require(amount > 0, "Insufficient balance");
        referralBalance[msg.sender] = 0;
        payable(msg.sender).transfer(amount);
        emit withdrawRecord(msg.sender, amount);
    }

    function addController(address controller) external override onlyOwner {
        controllers[controller] = true;
        emit ControllerAdded(controller);
    }

    function removeController(address controller) external override onlyOwner {
        controllers[controller] = false;
        emit ControllerRemoved(controller);
    }
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface ISidPriceOracle {
    struct Price {
        uint256 base;
        uint256 premium;
        uint256 usedPoint;
    }

    function giftCardPriceInBNB(uint256[] memory ids, uint256[] memory amounts) external view returns (Price calldata);

    function domainPriceInBNB(
        string calldata name,
        uint256 expires,
        uint256 duration
    ) external view returns (Price calldata);

    function domainPriceWithPointRedemptionInBNB(
        string calldata name,
        uint256 expires,
        uint duration,
        address owner
    ) external view returns (Price calldata);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "./SidGiftCardRegistrar.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./SidGiftCardVoucher.sol";

contract SidGiftCardLedger is Ownable {
    SidGiftCardRegistrar public registrar;
    SidGiftCardVoucher public voucher;
    mapping(address => uint256) public balances;
    mapping(address => bool) public controllers;

    event ControllerAdded(address indexed controller);
    event ControllerRemoved(address indexed controller);

    constructor(SidGiftCardRegistrar _registrar, SidGiftCardVoucher _voucher) {
        registrar = _registrar;
        voucher = _voucher;
    }

    modifier onlyController() {
        require(controllers[msg.sender], "Not a authorized controller");
        _;
    }

    function balanceOf(address account) public view returns (uint256) {
        return balances[account];
    }

    function redeem(uint256[] calldata ids, uint256[] calldata amounts) external {
        registrar.batchBurn(msg.sender, ids, amounts);
        uint256 totalValue = voucher.totalValue(ids, amounts);
        balances[msg.sender] += totalValue;
    }

    function deduct(address account, uint256 amount) public onlyController {
        uint256 fromBalance = balances[account];
        require(fromBalance >= amount, "Insufficient balance");
        balances[account] = fromBalance - amount;
    }

    function addController(address controller) external onlyOwner {
        require(controller != address(0), "address can not be zero!");
        controllers[controller] = true;
        emit ControllerAdded(controller);
    }

    function removeController(address controller) external onlyOwner {
        require(controller != address(0), "address can not be zero!");
        controllers[controller] = false;
        emit ControllerRemoved(controller);
    }
}

pragma solidity >=0.8.4;

import "./SID.sol";
import "./IReverseRegistrar.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "../root/Controllable.sol";

abstract contract NameResolver {
    function setName(bytes32 node, string memory name) public virtual;
}

bytes32 constant lookup = 0x3031323334353637383961626364656600000000000000000000000000000000;

bytes32 constant ADDR_REVERSE_NODE = 0x91d1777781884d03a6757a803996e38de2a42967fb37eeaca72729271025a9e2;

// namehash('addr.reverse')

contract ReverseRegistrar is Ownable, Controllable, IReverseRegistrar {
    SID public immutable sid;
    NameResolver public defaultResolver;

    event ReverseClaimed(address indexed addr, bytes32 indexed node);

    /**
     * @dev Constructor
     * @param sidAddr The address of the SID registry.
     */
    constructor(SID sidAddr) {
        sid = sidAddr;

        // Assign ownership of the reverse record to our deployer
        ReverseRegistrar oldRegistrar = ReverseRegistrar(
            sidAddr.owner(ADDR_REVERSE_NODE)
        );
        if (address(oldRegistrar) != address(0x0)) {
            oldRegistrar.claim(msg.sender);
        }
    }

    modifier authorised(address addr) {
        require(
            addr == msg.sender ||
                controllers[msg.sender] ||
                sid.isApprovedForAll(addr, msg.sender) ||
                ownsContract(addr),
            "ReverseRegistrar: Caller is not a controller or authorised by address or the address itself"
        );
        _;
    }

    function setDefaultResolver(address resolver) public override onlyOwner {
        require(
            address(resolver) != address(0),
            "ReverseRegistrar: Resolver address must not be 0"
        );
        defaultResolver = NameResolver(resolver);
    }

    /**
     * @dev Transfers ownership of the reverse SID record associated with the
     *      calling account.
     * @param owner The address to set as the owner of the reverse record in SID.
     * @return The SID node hash of the reverse record.
     */
    function claim(address owner) public override returns (bytes32) {
        return claimForAddr(msg.sender, owner, address(defaultResolver));
    }

    /**
     * @dev Transfers ownership of the reverse SID record associated with the
     *      calling account.
     * @param addr The reverse record to set
     * @param owner The address to set as the owner of the reverse record in SID.
     * @return The SID node hash of the reverse record.
     */
    function claimForAddr(
        address addr,
        address owner,
        address resolver
    ) public override authorised(addr) returns (bytes32) {
        bytes32 labelHash = sha3HexAddress(addr);
        bytes32 reverseNode = keccak256(
            abi.encodePacked(ADDR_REVERSE_NODE, labelHash)
        );
        emit ReverseClaimed(addr, reverseNode);
        sid.setSubnodeRecord(ADDR_REVERSE_NODE, labelHash, owner, resolver, 0);
        return reverseNode;
    }

    /**
     * @dev Transfers ownership of the reverse SID record associated with the
     *      calling account.
     * @param owner The address to set as the owner of the reverse record in SID.
     * @param resolver The address of the resolver to set; 0 to leave unchanged.
     * @return The SID node hash of the reverse record.
     */
    function claimWithResolver(address owner, address resolver)
        public
        override
        returns (bytes32)
    {
        return claimForAddr(msg.sender, owner, resolver);
    }

    /**
     * @dev Sets the `name()` record for the reverse SID record associated with
     * the calling account. First updates the resolver to the default reverse
     * resolver if necessary.
     * @param name The name to set for this address.
     * @return The SID node hash of the reverse record.
     */
    function setName(string memory name) public override returns (bytes32) {
        return
            setNameForAddr(
                msg.sender,
                msg.sender,
                address(defaultResolver),
                name
            );
    }

    /**
     * @dev Sets the `name()` record for the reverse SID record associated with
     * the account provided. First updates the resolver to the default reverse
     * resolver if necessary.
     * Only callable by controllers and authorised users
     * @param addr The reverse record to set
     * @param owner The owner of the reverse node
     * @param name The name to set for this address.
     * @return The SID node hash of the reverse record.
     */
    function setNameForAddr(
        address addr,
        address owner,
        address resolver,
        string memory name
    ) public override returns (bytes32) {
        bytes32 node = claimForAddr(addr, owner, resolver);
        NameResolver(resolver).setName(node, name);
        return node;
    }

    /**
     * @dev Returns the node hash for a given account's reverse records.
     * @param addr The address to hash
     * @return The SID node hash.
     */
    function node(address addr) public pure override returns (bytes32) {
        return
            keccak256(
                abi.encodePacked(ADDR_REVERSE_NODE, sha3HexAddress(addr))
            );
    }

    /**
     * @dev An optimised function to compute the sha3 of the lower-case
     *      hexadecimal representation of an Ethereum address.
     * @param addr The address to hash
     * @return ret The SHA3 hash of the lower-case hexadecimal encoding of the
     *         input address.
     */
    function sha3HexAddress(address addr) private pure returns (bytes32 ret) {
        assembly {
            for {
                let i := 40
            } gt(i, 0) {

            } {
                i := sub(i, 1)
                mstore8(i, byte(and(addr, 0xf), lookup))
                addr := div(addr, 0x10)
                i := sub(i, 1)
                mstore8(i, byte(and(addr, 0xf), lookup))
                addr := div(addr, 0x10)
            }

            ret := keccak256(0, 40)
        }
    }

    function ownsContract(address addr) internal view returns (bool) {
        try Ownable(addr).owner() returns (address owner) {
            return owner == msg.sender;
        } catch {
            return false;
        }
    }
}

pragma solidity >=0.8.4;
import "../price-oracle/ISidPriceOracle.sol";
import "../struct/SidStruct.sol";
interface IRegistrarController {

    event NameRegistered(string name, bytes32 indexed label, address indexed owner, uint cost, uint expires);

    event NameRenewed(string name, bytes32 indexed label, uint cost, uint expires);

    event NewPriceOracle(address indexed oracle);

    event NewTreasuryManager(address indexed treasuryManager);
    
    function rentPrice(string calldata name, uint256 duration) external view returns (ISidPriceOracle.Price memory);

    /**
     * rent price with point redemption
     * @param name domain name
     * @param duration registration duration
     * @param registerAddress address of the registrant
     */
    function rentPriceWithPoint(string calldata name, uint256 duration, address registerAddress) external view returns (ISidPriceOracle.Price memory);

    /**
     * bulk rent price without point redemption
     * @param names domain names
     * @param duration registration duration
     */
    function bulkRentPrice(string[] calldata names, uint256 duration) external view returns (uint256);

    function valid(string calldata name) external pure returns (bool);

    function available(string calldata name) external view returns (bool);

    function register(string calldata name, address owner, uint duration) external payable;

    function registerWithConfigAndPoint(string calldata name, address owner, uint duration, address resolver, bool isUsePoints, bool isSetPrimaryName, ReferralInfo memory referralInfo) external payable;

    function bulkRegister(string[] calldata names, address owner, uint duration, address resolver, bool isUsePoints, bool isSetPrimaryName, ReferralInfo memory referralInfo) external payable;

    function bulkRenew(string[] calldata names, uint duration, bool isUsePoints) external payable;

    function renew(string calldata name, uint duration) external payable;

    function renewWithPoint(string calldata name, uint duration, bool isUsePoints) external payable;
}

File 10 of 53 : SidStruct.sol
pragma solidity >=0.8.4;

struct ReferralInfo {
    address referrerAddress;
    bytes32 referrerNodehash;
    uint256 referralAmount;
    uint256 signedAt;
    bytes signature;
}

struct RegInfo {
    address owner;
    uint duration;
    address resolver;
    bool isUsePoints;
    bool isSetPrimaryName;
    uint256 paidFee;
}

//SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

import "./profiles/IABIResolver.sol";
import "./profiles/IAddressResolver.sol";
import "./profiles/IAddrResolver.sol";
import "./profiles/IContentHashResolver.sol";
import "./profiles/IDNSRecordResolver.sol";
import "./profiles/IDNSZoneResolver.sol";
import "./profiles/IInterfaceResolver.sol";
import "./profiles/INameResolver.sol";
import "./profiles/IPubkeyResolver.sol";
import "./profiles/ITextResolver.sol";
import "./ISupportsInterface.sol";

/**
 * A generic resolver interface which includes all the functions including the ones deprecated
 */
interface Resolver is
    ISupportsInterface,
    IABIResolver,
    IAddressResolver,
    IAddrResolver,
    IContentHashResolver,
    IDNSRecordResolver,
    IDNSZoneResolver,
    IInterfaceResolver,
    INameResolver,
    IPubkeyResolver,
    ITextResolver
{
    /* Deprecated events */
    event ContentChanged(bytes32 indexed node, bytes32 hash);

    function setABI(
        bytes32 node,
        uint256 contentType,
        bytes calldata data
    ) external;

    function setAddr(bytes32 node, address addr) external;

    function setAddr(
        bytes32 node,
        uint256 coinType,
        bytes calldata a
    ) external;

    function setContenthash(bytes32 node, bytes calldata hash) external;

    function setDnsrr(bytes32 node, bytes calldata data) external;

    function setName(bytes32 node, string calldata _name) external;

    function setPubkey(
        bytes32 node,
        bytes32 x,
        bytes32 y
    ) external;

    function setText(
        bytes32 node,
        string calldata key,
        string calldata value
    ) external;

    function setInterface(
        bytes32 node,
        bytes4 interfaceID,
        address implementer
    ) external;

    function multicall(bytes[] calldata data)
        external
        returns (bytes[] memory results);

    /* Deprecated functions */
    function content(bytes32 node) external view returns (bytes32);

    function multihash(bytes32 node) external view returns (bytes memory);

    function setContent(bytes32 node, bytes32 hash) external;

    function setMultihash(bytes32 node, bytes calldata hash) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 14 of 53 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

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

pragma solidity >=0.8.4;

interface SID {
    // Logged when the owner of a node assigns a new owner to a subnode.
    event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);

    // Logged when the owner of a node transfers ownership to a new account.
    event Transfer(bytes32 indexed node, address owner);

    // Logged when the resolver for a node changes.
    event NewResolver(bytes32 indexed node, address resolver);

    // Logged when the TTL of a node changes
    event NewTTL(bytes32 indexed node, uint64 ttl);

    // Logged when an operator is added or removed.
    event ApprovalForAll(
        address indexed owner,
        address indexed operator,
        bool approved
    );

    function setRecord(
        bytes32 node,
        address owner,
        address resolver,
        uint64 ttl
    ) external;

    function setSubnodeRecord(
        bytes32 node,
        bytes32 label,
        address owner,
        address resolver,
        uint64 ttl
    ) external;

    function setSubnodeOwner(
        bytes32 node,
        bytes32 label,
        address owner
    ) external returns (bytes32);

    function setResolver(bytes32 node, address resolver) external;

    function setOwner(bytes32 node, address owner) external;

    function setTTL(bytes32 node, uint64 ttl) external;

    function setApprovalForAll(address operator, bool approved) external;

    function owner(bytes32 node) external view returns (address);

    function resolver(bytes32 node) external view returns (address);

    function ttl(bytes32 node) external view returns (uint64);

    function recordExists(bytes32 node) external view returns (bool);

    function isApprovedForAll(address owner, address operator)
        external
        view
        returns (bool);
}

import "../registry/SID.sol";
import "./IBaseRegistrar.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

interface IBaseRegistrar is IERC721 {

    event ControllerAdded(address indexed controller);
    event ControllerRemoved(address indexed controller);
    event NameMigrated(
        uint256 indexed id,
        address indexed owner,
        uint256 expires
    );
    event NameRegistered(
        uint256 indexed id,
        address indexed owner,
        uint256 expires
    );
    event NameRenewed(uint256 indexed id, uint256 expires);
    // Authorises a controller, who can register and renew domains.
    function addController(address controller) external;

    // Revoke controller permission for an address.
    function removeController(address controller) external;

    // Set the resolver for the TLD this registrar manages.
    function setResolver(address resolver) external;

    // Returns the expiration timestamp of the specified label hash.
    function nameExpires(uint256 id) external view returns (uint256);

    // Returns true iff the specified name is available for registration.
    function available(uint256 id) external view returns (bool);

    /**
     * @dev Register a name.
     */
    function register(
        uint256 id,
        address owner,
        uint256 duration
    ) external returns (uint256);

    function renew(uint256 id, uint256 duration) external returns (uint256);

    /**
     * @dev Reclaim ownership of a name in SID, if you own it in the registrar.
     */
    function reclaim(uint256 id, address owner) external;
}

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping(address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}

// 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 23 of 53 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

// 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;
    }
}

// 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());
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;
    address private immutable _CACHED_THIS;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 27)
        }
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }
        if (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

pragma solidity >=0.8.4;

interface IReverseRegistrar {
    function setDefaultResolver(address resolver) external;

    function claim(address owner) external returns (bytes32);

    function claimForAddr(
        address addr,
        address owner,
        address resolver
    ) external returns (bytes32);

    function claimWithResolver(address owner, address resolver)
        external
        returns (bytes32);

    function setName(string memory name) external returns (bytes32);

    function setNameForAddr(
        address addr,
        address owner,
        address resolver,
        string memory name
    ) external returns (bytes32);

    function node(address addr) external pure returns (bytes32);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface IReferralHub {
    event ControllerAdded(address indexed controller);
    event ControllerRemoved(address indexed controller);
    event NewReferralRecord(bytes32 indexed referralNodeHash);
    event depositRecord(address indexed addr, uint256 amount);
    event withdrawRecord(address indexed addr, uint256 amount);
    

    //Authorises a controller, who can issue a gift card.
    function addController(address controller) external;

    // Revoke controller permission for an address.
    function removeController(address controller) external;

    //check if a domain name is eligible for referral program
    function isReferralEligible(
        bytes32 nodeHash
    ) external view returns (bool, address);

    //add a referral count for a given referrer
    function addNewReferralRecord(bytes32 referrerNodeHash) external;

    //get a domain's referral count, referral comission and referee comission
    function getReferralDetails(bytes32 referrerNodeHash)
        external
        view
        returns (
            uint256,
            uint256,
            uint256,
            uint256
        );

    //set partner comission chart
    function setPartnerComissionChart(
        string calldata name,
        string calldata tld,
        uint256 minimumReferralCount,
        uint256 referrerComission,
        uint256 refereeComission
    ) external;

    function getReferralCommisionFee(uint256 price, bytes32 nodeHash) external view returns (uint256, uint256);

    function deposit(address _referrer) external payable;

    function withdraw() external;
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

import "../ResolverBase.sol";
import "./IAddrResolver.sol";
import "./IAddressResolver.sol";

abstract contract AddrResolver is IAddrResolver, IAddressResolver, ResolverBase {
    uint constant private COIN_TYPE_ETH = 60;

    mapping(bytes32=>mapping(uint=>bytes)) _addresses;

    /**
     * Sets the address associated with an ENS node.
     * May only be called by the owner of that node in the ENS registry.
     * @param node The node to update.
     * @param a The address to set.
     */
    function setAddr(bytes32 node, address a) virtual external authorised(node) {
        setAddr(node, COIN_TYPE_ETH, addressToBytes(a));
    }

    /**
     * Returns the address associated with an ENS node.
     * @param node The ENS node to query.
     * @return The associated address.
     */
    function addr(bytes32 node) virtual override public view returns (address payable) {
        bytes memory a = addr(node, COIN_TYPE_ETH);
        if(a.length == 0) {
            return payable(0);
        }
        return bytesToAddress(a);
    }

    function setAddr(bytes32 node, uint coinType, bytes memory a) virtual public authorised(node) {
        emit AddressChanged(node, coinType, a);
        if(coinType == COIN_TYPE_ETH) {
            emit AddrChanged(node, bytesToAddress(a));
        }
        _addresses[node][coinType] = a;
    }

    function addr(bytes32 node, uint coinType) virtual override public view returns(bytes memory) {
        return _addresses[node][coinType];
    }

    function supportsInterface(bytes4 interfaceID) virtual override public pure returns(bool) {
        return interfaceID == type(IAddrResolver).interfaceId || interfaceID == type(IAddressResolver).interfaceId || super.supportsInterface(interfaceID);
    }

    function bytesToAddress(bytes memory b) internal pure returns(address payable a) {
        require(b.length == 20);
        assembly {
            a := div(mload(add(b, 32)), exp(256, 12))
        }
    }

    function addressToBytes(address a) internal pure returns(bytes memory b) {
        b = new bytes(20);
        assembly {
            mstore(add(b, 32), mul(a, exp(256, 12)))
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

import "../ResolverBase.sol";
import "./INameResolver.sol";

abstract contract NameResolver is INameResolver, ResolverBase {
    mapping(bytes32=>string) names;

    /**
     * Sets the name associated with an ENS node, for reverse records.
     * May only be called by the owner of that node in the ENS registry.
     * @param node The node to update.
     */
    function setName(bytes32 node, string calldata newName) virtual external authorised(node) {
        names[node] = newName;
        emit NameChanged(node, newName);
    }

    /**
     * Returns the name associated with an ENS node, for reverse records.
     * Defined in EIP181.
     * @param node The ENS node to query.
     * @return The associated name.
     */
    function name(bytes32 node) virtual override external view returns (string memory) {
        return names[node];
    }

    function supportsInterface(bytes4 interfaceID) virtual override public pure returns(bool) {
        return interfaceID == type(INameResolver).interfaceId || super.supportsInterface(interfaceID);
    }
}

File 33 of 53 : ResolverBase.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

import "./SupportsInterface.sol";

abstract contract ResolverBase is SupportsInterface {
    function isAuthorised(bytes32 node) internal virtual view returns(bool);

    modifier authorised(bytes32 node) {
        require(isAuthorised(node));
        _;
    }
}

File 34 of 53 : IAddrResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

/**
 * Interface for the legacy (ETH-only) addr function.
 */
interface IAddrResolver {
    event AddrChanged(bytes32 indexed node, address a);

    /**
     * Returns the address associated with an ENS node.
     * @param node The ENS node to query.
     * @return The associated address.
     */
    function addr(bytes32 node) external view returns (address payable);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

/**
 * Interface for the new (multicoin) addr function.
 */
interface IAddressResolver {
    event AddressChanged(bytes32 indexed node, uint coinType, bytes newAddress);

    function addr(bytes32 node, uint coinType) external view returns(bytes memory);
}

File 36 of 53 : SupportsInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "./ISupportsInterface.sol";

abstract contract SupportsInterface is ISupportsInterface {
    function supportsInterface(bytes4 interfaceID) virtual override public pure returns(bool) {
        return interfaceID == type(ISupportsInterface).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface ISupportsInterface {
    function supportsInterface(bytes4 interfaceID) external pure returns(bool);
}

File 38 of 53 : INameResolver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface INameResolver {
    event NameChanged(bytes32 indexed node, string name);

    /**
     * Returns the name associated with an ENS node, for reverse records.
     * Defined in EIP181.
     * @param node The ENS node to query.
     * @return The associated name.
     */
    function name(bytes32 node) external view returns (string memory);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./ISidGiftCardRegistrar.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

contract SidGiftCardRegistrar is ERC1155, ISidGiftCardRegistrar, Ownable, Pausable {
    mapping(address => bool) public controllers;

    constructor() ERC1155("") {}

    modifier onlyController() {
        require(controllers[msg.sender], "Not a authorized controller");
        _;
    }

    function setURI(string calldata newURI) external onlyOwner {
        _setURI(newURI);
    }

    function uri(uint256 _id) public view virtual override(ERC1155) returns (string memory) {
        return string(abi.encodePacked(ERC1155.uri(_id), Strings.toString(_id)));
    }

    function name() public view virtual returns (string memory) {
        return "SPACE ID Gift Card";
    }

    function symbol() public view virtual returns (string memory) {
        return "SIDGC";
    }

    function register(
        address to,
        uint256 id,
        uint256 amount
    ) external onlyController whenNotPaused returns (uint256, uint256) {
        super._mint(to, id, amount, "");
        return (id, amount);
    }

    function batchRegister(
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts
    ) external onlyController whenNotPaused {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        for (uint256 i = 0; i < ids.length; i++) {
            if (amounts[i] > 0) {
                super._mint(to, ids[i], amounts[i], "");
            }
        }
    }

    function batchBurn(
        address account,
        uint256[] calldata ids,
        uint256[] calldata amounts
    ) external onlyController whenNotPaused {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        for (uint256 i = 0; i < ids.length; i++) {
            if (amounts[i] > 0) {
                super._burn(account, ids[i], amounts[i]);
            }
        }
    }

    function addController(address controller) external override onlyOwner {
        require(controller != address(0), "address can not be zero!");
        controllers[controller] = true;
        emit ControllerAdded(controller);
    }

    function removeController(address controller) external override onlyOwner {
        require(controller != address(0), "address can not be zero!");
        controllers[controller] = false;
        emit ControllerRemoved(controller);
    }

    function pause() external onlyOwner {
        _pause();
    }

    function unpause() external onlyOwner {
        _unpause();
    }

    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) public virtual whenNotPaused override(ERC1155, IERC1155) {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        for (uint256 i = 0; i < ids.length; i++) {
            if (amounts[i] > 0) {
                super.safeTransferFrom(from, to, ids[i], amounts[i], data);
            }
        }
    }
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "@openzeppelin/contracts/access/Ownable.sol";

contract SidGiftCardVoucher is Ownable {
    uint256 public constant THREE_DIGIT_VOUCHER = 0;
    uint256 public constant FOUR_DIGIT_VOUCHER = 1;
    uint256 public constant FIVE_DIGIT_VOUCHER = 2;

    uint256 public constant THREE_DIGIT_VOUCHER_VALUE = 650 * (10**18);
    uint256 public constant FOUR_DIGIT_VOUCHER_VALUE = 160 * (10**18);
    uint256 public constant FIVE_DIGIT_VOUCHER_VALUE = 5 * (10**18);

    mapping(uint256 => uint256) public voucherValues;

    constructor() {
        voucherValues[THREE_DIGIT_VOUCHER] = THREE_DIGIT_VOUCHER_VALUE;
        voucherValues[FOUR_DIGIT_VOUCHER] = FOUR_DIGIT_VOUCHER_VALUE;
        voucherValues[FIVE_DIGIT_VOUCHER] = FIVE_DIGIT_VOUCHER_VALUE;
    }

    function addCustomizedVoucher(uint256 tokenId, uint256 price) external onlyOwner {
        require(voucherValues[tokenId] == 0, "voucher already exsits");
        voucherValues[tokenId] = price;
    }
    
    function totalValue(uint256[] calldata ids, uint256[] calldata amounts) external view returns (uint256) {
        uint256 total = 0;
        for (uint256 i = 0; i < ids.length; i++) {
            total += voucherValues[ids[i]] * amounts[i];
        }
        return total;
    }

    function isValidVoucherIds(uint256[] calldata id) external view returns (bool) {
        for (uint256 i = 0; i < id.length; i++) {
            if (voucherValues[id[i]] == 0) {
                return false;
            }
        }
        return true;
    }
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";

interface ISidGiftCardRegistrar is IERC1155 {
    event ControllerAdded(address indexed controller);
    event ControllerRemoved(address indexed controller);

    //Authorises a controller, who can issue a gift card.
    function addController(address controller) external;

    // Revoke controller permission for an address.
    function removeController(address controller) external;

    //Register new gift card voucher
    function register(
        address to,
        uint256 id,
        uint256 amount
    ) external returns (uint256, uint256);

    //batch register new gift card voucher
    function batchRegister(
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts
    ) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
    using Address for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

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

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: balance query for the zero address");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC1155-isApprovedForAll}.
     */
    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[account][operator];
    }

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not owner nor approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: transfer caller is not owner nor approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, _asSingletonArray(id), _asSingletonArray(amount), data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, _asSingletonArray(id), _asSingletonArray(amount), data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), _asSingletonArray(id), _asSingletonArray(amount), "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits a {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
        @dev Handles the receipt of a single ERC1155 token type. This function is
        called at the end of a `safeTransferFrom` after the balance has been updated.
        To accept the transfer, this must return
        `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
        (i.e. 0xf23a6e61, or its own function selector).
        @param operator The address which initiated the transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param id The ID of the token being transferred
        @param value The amount of tokens being transferred
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
    */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
        @dev Handles the receipt of a multiple ERC1155 token types. This function
        is called at the end of a `safeBatchTransferFrom` after the balances have
        been updated. To accept the transfer(s), this must return
        `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
        (i.e. 0xbc197c81, or its own function selector).
        @param operator The address which initiated the batch transfer (i.e. msg.sender)
        @param from The address which previously owned the token
        @param ids An array containing ids of each token being transferred (order and length must match values array)
        @param values An array containing amounts of each token being transferred (order and length must match ids array)
        @param data Additional data with no specified format
        @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
    */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURI is IERC1155 {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/Ownable.sol";

contract Controllable is Ownable {
    mapping(address => bool) public controllers;

    event ControllerChanged(address indexed controller, bool enabled);

    modifier onlyController {
        require(
            controllers[msg.sender],
            "Controllable: Caller is not a controller"
        );
        _;
    }

    function setController(address controller, bool enabled) public onlyOwner {
        controllers[controller] = enabled;
        emit ControllerChanged(controller, enabled);
    }
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

import "./IABIResolver.sol";
import "../ResolverBase.sol";

interface IABIResolver {
    event ABIChanged(bytes32 indexed node, uint256 indexed contentType);
    /**
     * Returns the ABI associated with an ENS node.
     * Defined in EIP205.
     * @param node The ENS node to query
     * @param contentTypes A bitwise OR of the ABI formats accepted by the caller.
     * @return contentType The content type of the return value
     * @return data The ABI data
     */
    function ABI(bytes32 node, uint256 contentTypes) external view returns (uint256, bytes memory);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface IDNSZoneResolver {
    // DNSZonehashChanged is emitted whenever a given node's zone hash is updated.
    event DNSZonehashChanged(bytes32 indexed node, bytes lastzonehash, bytes zonehash);

    /**
     * zonehash obtains the hash for the zone.
     * @param node The ENS node to query.
     * @return The associated contenthash.
     */
    function zonehash(bytes32 node) external view returns (bytes memory);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface IDNSRecordResolver {
    // DNSRecordChanged is emitted whenever a given node/name/resource's RRSET is updated.
    event DNSRecordChanged(bytes32 indexed node, bytes name, uint16 resource, bytes record);
    // DNSRecordDeleted is emitted whenever a given node/name/resource's RRSET is deleted.
    event DNSRecordDeleted(bytes32 indexed node, bytes name, uint16 resource);
    // DNSZoneCleared is emitted whenever a given node's zone information is cleared.
    event DNSZoneCleared(bytes32 indexed node);

    /**
     * Obtain a DNS record.
     * @param node the namehash of the node for which to fetch the record
     * @param name the keccak-256 hash of the fully-qualified name for which to fetch the record
     * @param resource the ID of the resource as per https://en.wikipedia.org/wiki/List_of_DNS_record_types
     * @return the DNS record in wire format if present, otherwise empty
     */
    function dnsRecord(bytes32 node, bytes32 name, uint16 resource) external view returns (bytes memory);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface IInterfaceResolver {
    event InterfaceChanged(bytes32 indexed node, bytes4 indexed interfaceID, address implementer);

    /**
     * Returns the address of a contract that implements the specified interface for this name.
     * If an implementer has not been set for this interfaceID and name, the resolver will query
     * the contract at `addr()`. If `addr()` is set, a contract exists at that address, and that
     * contract implements EIP165 and returns `true` for the specified interfaceID, its address
     * will be returned.
     * @param node The ENS node to query.
     * @param interfaceID The EIP 165 interface ID to check for.
     * @return The address that implements this interface, or 0 if the interface is unsupported.
     */
    function interfaceImplementer(bytes32 node, bytes4 interfaceID) external view returns (address);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface IContentHashResolver {
    event ContenthashChanged(bytes32 indexed node, bytes hash);

    /**
     * Returns the contenthash associated with an ENS node.
     * @param node The ENS node to query.
     * @return The associated contenthash.
     */
    function contenthash(bytes32 node) external view returns (bytes memory);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface IPubkeyResolver {
    event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);

    /**
     * Returns the SECP256k1 public key associated with an ENS node.
     * Defined in EIP 619.
     * @param node The ENS node to query
     * @return x The X coordinate of the curve point for the public key.
     * @return y The Y coordinate of the curve point for the public key.
     */
    function pubkey(bytes32 node) external view returns (bytes32 x, bytes32 y);
}

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

interface ITextResolver {
    event TextChanged(bytes32 indexed node, string indexed indexedKey, string key);

    /**
     * Returns the text data associated with an ENS node and key.
     * @param node The ENS node to query.
     * @param key The text data key to query.
     * @return The associated text data.
     */
    function text(bytes32 node, string calldata key) external view returns (string memory);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract BaseRegistrarImplementation","name":"_base","type":"address"},{"internalType":"contract ISidPriceOracle","name":"_prices","type":"address"},{"internalType":"contract SidGiftCardLedger","name":"_giftCardLedger","type":"address"},{"internalType":"contract ReferralHub","name":"_referralHub","type":"address"},{"internalType":"contract ReferralVerifier","name":"_referralVerifier","type":"address"},{"internalType":"contract ReverseRegistrar","name":"_reverseRegistrar","type":"address"},{"internalType":"address","name":"_treasuryManager","type":"address"},{"internalType":"uint256","name":"_version","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":true,"internalType":"bytes32","name":"label","type":"bytes32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expires","type":"uint256"}],"name":"NameRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":true,"internalType":"bytes32","name":"label","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"expires","type":"uint256"}],"name":"NameRenewed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oracle","type":"address"}],"name":"NewPriceOracle","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"treasuryManager","type":"address"}],"name":"NewTreasuryManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"MIN_REGISTRATION_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"available","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string[]","name":"names","type":"string[]"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"address","name":"resolver","type":"address"},{"internalType":"bool","name":"isUseGiftCard","type":"bool"},{"internalType":"bool","name":"isSetPrimaryName","type":"bool"},{"components":[{"internalType":"address","name":"referrerAddress","type":"address"},{"internalType":"bytes32","name":"referrerNodehash","type":"bytes32"},{"internalType":"uint256","name":"referralAmount","type":"uint256"},{"internalType":"uint256","name":"signedAt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct ReferralInfo","name":"referralInfo","type":"tuple"}],"name":"bulkRegister","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string[]","name":"names","type":"string[]"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"bool","name":"isUsePoints","type":"bool"}],"name":"bulkRenew","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string[]","name":"names","type":"string[]"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"bulkRentPrice","outputs":[{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"register","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"address","name":"resolver","type":"address"},{"internalType":"bool","name":"isUsePoints","type":"bool"},{"internalType":"bool","name":"isSetPrimaryName","type":"bool"},{"components":[{"internalType":"address","name":"referrerAddress","type":"address"},{"internalType":"bytes32","name":"referrerNodehash","type":"bytes32"},{"internalType":"uint256","name":"referralAmount","type":"uint256"},{"internalType":"uint256","name":"signedAt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct ReferralInfo","name":"referralInfo","type":"tuple"}],"name":"registerWithConfigAndPoint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"renew","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"bool","name":"isUsePoints","type":"bool"}],"name":"renewWithPoint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"rentPrice","outputs":[{"components":[{"internalType":"uint256","name":"base","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"usedPoint","type":"uint256"}],"internalType":"struct ISidPriceOracle.Price","name":"price","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"address","name":"registerAddress","type":"address"}],"name":"rentPriceWithPoint","outputs":[{"components":[{"internalType":"uint256","name":"base","type":"uint256"},{"internalType":"uint256","name":"premium","type":"uint256"},{"internalType":"uint256","name":"usedPoint","type":"uint256"}],"internalType":"struct ISidPriceOracle.Price","name":"price","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ISidPriceOracle","name":"_prices","type":"address"}],"name":"setPriceOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasuryManager","type":"address"}],"name":"setTreasuryManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"subfix","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryManager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"valid","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c060405260046080819052631731373160e11b60a09081526200002791600a91906200013d565b503480156200003557600080fd5b50604051620034bc380380620034bc8339810160408190526200005891620001fc565b6200006333620000ed565b60018055600280546001600160a01b03199081166001600160a01b039a8b1617909155600480548216988a1698909817909755600380548816968916969096179095556005805487169488169490941790935560068054861692871692909217909155600780548516918616919091179055600880549093169316929092179055600955620002ee565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8280546200014b90620002b1565b90600052602060002090601f0160209004810192826200016f5760008555620001ba565b82601f106200018a57805160ff1916838001178555620001ba565b82800160010185558215620001ba579182015b82811115620001ba5782518255916020019190600101906200019d565b50620001c8929150620001cc565b5090565b5b80821115620001c85760008155600101620001cd565b6001600160a01b0381168114620001f957600080fd5b50565b600080600080600080600080610100898b0312156200021a57600080fd5b88516200022781620001e3565b60208a01519098506200023a81620001e3565b60408a01519097506200024d81620001e3565b60608a01519096506200026081620001e3565b60808a01519095506200027381620001e3565b60a08a01519094506200028681620001e3565b60c08a01519093506200029981620001e3565b8092505060e089015190509295985092959890939650565b600181811c90821680620002c657607f821691505b60208210811415620002e857634e487b7160e01b600052602260045260246000fd5b50919050565b6131be80620002fe6000396000f3fe60806040526004361061016a5760003560e01c80639791c097116100cb578063d62949d31161007f578063f2fde38b11610059578063f2fde38b146103a5578063fe47a9f2146103c5578063fefee5e1146103e557600080fd5b8063d62949d314610350578063d8b7f1c014610372578063dde2b21f1461038557600080fd5b8063aeb8ce9b116100b0578063aeb8ce9b146102fd578063bf31e5301461031d578063d393c8711461033d57600080fd5b80639791c097146102ba578063acf1a841146102ea57600080fd5b80635994f5231161012257806383e7f6ff1161010757806383e7f6ff146102425780638a95b09f146102845780638da5cb5b1461029c57600080fd5b80635994f5231461021a578063715018a61461022d57600080fd5b80633cea70d9116101535780633cea70d914610199578063530e784f146101d657806354fd4d50146101f657600080fd5b806339b94c581461016f5780633ccfd60b14610184575b600080fd5b61018261017d366004612740565b6103f8565b005b34801561019057600080fd5b506101826104c3565b3480156101a557600080fd5b506008546101b9906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101e257600080fd5b506101826101f13660046127b4565b610645565b34801561020257600080fd5b5061020c60095481565b6040519081526020016101cd565b6101826102283660046129b4565b610701565b34801561023957600080fd5b50610182610859565b34801561024e57600080fd5b5061026261025d366004612a79565b6108bf565b60408051825181526020808401519082015291810151908201526060016101cd565b34801561029057600080fd5b5061020c6301e1338081565b3480156102a857600080fd5b506000546001600160a01b03166101b9565b3480156102c657600080fd5b506102da6102d5366004612ac5565b6109fe565b60405190151581526020016101cd565b6101826102f8366004612a79565b610e27565b34801561030957600080fd5b506102da610318366004612ac5565b610ee6565b34801561032957600080fd5b5061020c610338366004612b07565b610fa2565b61018261034b366004612b3f565b611018565b34801561035c57600080fd5b506103656110af565b6040516101cd9190612c12565b610182610380366004612c25565b61113d565b34801561039157600080fd5b506102626103a0366004612c65565b6111ac565b3480156103b157600080fd5b506101826103c03660046127b4565b6112ee565b3480156103d157600080fd5b506101826103e03660046127b4565b6113d0565b6101826103f3366004612cb9565b61149f565b6000610407858585853461151a565b9050803411156104bc5760003361041e8334612d21565b6040515b60006040518083038185875af1925050503d806000811461045f576040519150601f19603f3d011682016040523d82523d6000602084013e610464565b606091505b50509050806104ba5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064015b60405180910390fd5b505b5050505050565b6008546001600160a01b031633146105435760405162461bcd60e51b815260206004820152602260248201527f4f6e6c79207472656173757279206d616e616765722063616e2077697468647260448201527f617700000000000000000000000000000000000000000000000000000000000060648201526084016104b1565b600260015414156105965760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104b1565b60026001556008546040516000916001600160a01b03169047908381818185875af1925050503d80600081146105e8576040519150601f19603f3d011682016040523d82523d6000602084013e6105ed565b606091505b505090508061063e5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064016104b1565b5060018055565b6000546001600160a01b0316331461069f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104b1565b600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517ff261845a790fe29bbd6631e2ca4a5bdc83e6eed7c3271d9590d97287e00e912390600090a250565b3460005b888110156107a157600061077f8b8b8481811061072457610724612d38565b90506020028101906107369190612d67565b6040518060c001604052808d6001600160a01b031681526020018c81526020018b6001600160a01b031681526020018a1515815260200189151581526020018781525087611757565b905061078b8184612d21565b925050808061079990612dcc565b915050610705565b50801561084e576000336001600160a01b0316826040515b60006040518083038185875af1925050503d80600081146107f6576040519150601f19603f3d011682016040523d82523d6000602084013e6107fb565b606091505b505090508061084c5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064016104b1565b505b505050505050505050565b6000546001600160a01b031633146108b35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104b1565b6108bd6000611d6d565b565b6108e360405180606001604052806000815260200160008152602001600081525090565b600084846040516108f5929190612e05565b604051908190038120600480546002547fd6e4fa860000000000000000000000000000000000000000000000000000000085529184018390529193506001600160a01b039182169263d831223c928992899291169063d6e4fa8690602401602060405180830381865afa158015610970573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109949190612e15565b876040518563ffffffff1660e01b81526004016109b49493929190612e77565b606060405180830381865afa1580156109d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f59190612e9e565b95945050505050565b60006003610a4184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611dd592505050565b1015610a4f57506000610e21565b600083838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509394505050505b60028251610a989190612d21565b811015610e1a57818181518110610ab157610ab1612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167fe200000000000000000000000000000000000000000000000000000000000000148015610b69575081610b0e826001612efa565b81518110610b1e57610b1e612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f8000000000000000000000000000000000000000000000000000000000000000145b15610cc35781610b7a826002612efa565b81518110610b8a57610b8a612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f8b000000000000000000000000000000000000000000000000000000000000001480610c41575081610be6826002612efa565b81518110610bf657610bf6612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f8c00000000000000000000000000000000000000000000000000000000000000145b80610cae575081610c53826002612efa565b81518110610c6357610c63612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f8d00000000000000000000000000000000000000000000000000000000000000145b15610cbe57600092505050610e21565b610e08565b818181518110610cd557610cd5612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167fef000000000000000000000000000000000000000000000000000000000000001415610e085781610d30826001612efa565b81518110610d4057610d40612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167fbb00000000000000000000000000000000000000000000000000000000000000148015610df8575081610d9d826002612efa565b81518110610dad57610dad612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167fbf00000000000000000000000000000000000000000000000000000000000000145b15610e0857600092505050610e21565b80610e1281612dcc565b915050610a8a565b5060019150505b92915050565b6000610e3784848460003461151a565b905080341115610ee057600033610e4e8334612d21565b604051600081818185875af1925050503d8060008114610e8a576040519150601f19603f3d011682016040523d82523d6000602084013e610e8f565b606091505b50509050806104bc5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064016104b1565b50505050565b6000808383604051610ef9929190612e05565b60405180910390209050610f0d84846109fe565b8015610f9a57506002546040517f96e494e8000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b03909116906396e494e890602401602060405180830381865afa158015610f76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9a9190612f12565b949350505050565b6000805b83811015611010576000610fdd868684818110610fc557610fc5612d38565b9050602002810190610fd79190612d67565b866108bf565b60208101518151919250610ff091612efa565b610ffa9084612efa565b925050808061100890612dcc565b915050610fa6565b509392505050565b600061040785856040518060c00160405280876001600160a01b0316815260200186815260200160006001600160a01b03168152602001600015158152602001600015158152602001348152506040518060a0016040528060006001600160a01b031681526020016000801b8152602001600081526020016000815260200160405180602001604052806000815250815250611757565b600a80546110bc90612f2f565b80601f01602080910402602001604051908101604052809291908181526020018280546110e890612f2f565b80156111355780601f1061110a57610100808354040283529160200191611135565b820191906000526020600020905b81548152906001019060200180831161111857829003601f168201915b505050505081565b600061118d89896040518060c001604052808b6001600160a01b031681526020018a8152602001896001600160a01b03168152602001881515815260200187151581526020013481525085611757565b90508034111561084e576000336111a48334612d21565b6040516107b9565b6111d060405180606001604052806000815260200160008152602001600081525090565b600085856040516111e2929190612e05565b604051908190038120600480546002547fd6e4fa860000000000000000000000000000000000000000000000000000000085529184018390529193506001600160a01b0391821692635b7f4779928a928a9291169063d6e4fa8690602401602060405180830381865afa15801561125d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112819190612e15565b88886040518663ffffffff1660e01b81526004016112a3959493929190612f83565b606060405180830381865afa1580156112c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e49190612e9e565b9695505050505050565b6000546001600160a01b031633146113485760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104b1565b6001600160a01b0381166113c45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104b1565b6113cd81611d6d565b50565b6000546001600160a01b0316331461142a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104b1565b6001600160a01b03811661143d57600080fd5b600880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517fb5dc0e9c1936b5f549de73a1a5e47b42c3a2d5c3e230587217c158cc2de5bd5790600090a250565b3460005b848110156114fe5760006114dc8787848181106114c2576114c2612d38565b90506020028101906114d49190612d67565b87878761151a565b90506114e88184612d21565b92505080806114f690612dcc565b9150506114a3565b5080156104bc576000336001600160a01b031682604051610422565b60006002600154141561156f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104b1565b60026001556040805160608101825260008082526020820181905291810191909152831561162c576115a3878787336111ac565b60035460408281015190517f4705532100000000000000000000000000000000000000000000000000000000815233600482015260248101919091529192506001600160a01b031690634705532190604401600060405180830381600087803b15801561160f57600080fd5b505af1158015611623573d6000803e3d6000fd5b5050505061163a565b6116378787876108bf565b90505b6020810151815161164b9190612efa565b91508183101561165a57600080fd5b6000878760405161166c929190612e05565b6040519081900381206002547fc475abff00000000000000000000000000000000000000000000000000000000835260048301829052602483018990529092506000916001600160a01b039091169063c475abff906044016020604051808303816000875af11580156116e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117079190612e15565b9050817f3da24c024582931cfaf8267d8ed24d13a82a8068d5bd337d30ec45cea4e506ae8a8a878560405161173f9493929190612e77565b60405180910390a25050506001805595945050505050565b6000600260015414156117ac5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104b1565b60026001819055506117c8858585602001518660600151611fdc565b9050600085856040516117dc929190612e05565b60408051918290039091209085015190915081906000906001600160a01b031615611bf05760025460208701516040517ffca247ac0000000000000000000000000000000000000000000000000000000081526004810185905230602482015260448101919091526001600160a01b039091169063fca247ac906064016020604051808303816000875af1158015611878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189c9190612e15565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663ddf7fcb06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119179190612e15565b6040805160208101929092528101859052606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815282825280516020918201206002547fb1e8eb9500000000000000000000000000000000000000000000000000000000855292519094506001600160a01b039092169263b1e8eb9592600480830193928290030181865afa1580156119be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e29190612fbd565b60408089015190517f1896f70a000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b039182166024820152911690631896f70a90604401600060405180830381600087803b158015611a4a57600080fd5b505af1158015611a5e573d6000803e3d6000fd5b50505050604087810151885191517fd5fa2b00000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03928316602482015291169063d5fa2b0090604401600060405180830381600087803b158015611acc57600080fd5b505af1158015611ae0573d6000803e3d6000fd5b505060025489516040517f28ed4f6c000000000000000000000000000000000000000000000000000000008152600481018890526001600160a01b039182166024820152911692506328ed4f6c9150604401600060405180830381600087803b158015611b4c57600080fd5b505af1158015611b60573d6000803e3d6000fd5b505060025489516040517f23b872dd0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03918216602482015260448101889052911692506323b872dd9150606401600060405180830381600087803b158015611bd257600080fd5b505af1158015611be6573d6000803e3d6000fd5b5050505050611c91565b600254865160208801516040517ffca247ac000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b039283166024820152604481019190915291169063fca247ac906064016020604051808303816000875af1158015611c6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8e9190612e15565b90505b85600001516001600160a01b0316837fca6abbe9d7f11422cb6ca7629fbf6fe9efb1c621f71ce8f02b9f2a230097404f8a8a8886604051611cd59493929190612e77565b60405180910390a384516001600160a01b031615611d1257611d0f8486600001518760200151886040015189606001518a60800151612218565b93505b856080015115611d5e57611d5e88888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050895191506125c19050565b50505060018055949350505050565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8051600090819081905b80821015611fd3576000858381518110611dfb57611dfb612d38565b01602001517fff000000000000000000000000000000000000000000000000000000000000001690507f8000000000000000000000000000000000000000000000000000000000000000811015611e5e57611e57600184612efa565b9250611fc0565b7fe0000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161015611eb357611e57600284612efa565b7ff0000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161015611f0857611e57600384612efa565b7ff8000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161015611f5d57611e57600484612efa565b7ffc000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161015611fb257611e57600584612efa565b611fbd600684612efa565b92505b5082611fcb81612dcc565b935050611ddf565b50909392505050565b6000611fe88585610ee6565b611ff157600080fd5b61201560405180606001604052806000815260200160008152602001600081525090565b82156121d7576003546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561207d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120a19190612e15565b90506120af878787336111ac565b60035460408281015190517f4705532100000000000000000000000000000000000000000000000000000000815233600482015260248101919091529193506001600160a01b031690634705532190604401600060405180830381600087803b15801561211b57600080fd5b505af115801561212f573d6000803e3d6000fd5b5050505080600014806121c557506003546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561219e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c29190612e15565b81115b6121d1576121d1612fda565b506121e5565b6121e28686866108bf565b90505b602081015181516000916121f891612efa565b90506301e1338085101561220b57600080fd5b803410156112e457600080fd5b6006546040517fbecd725c0000000000000000000000000000000000000000000000000000000081526000916001600160a01b03169063becd725c9061226a9089908990899089908990600401613009565b602060405180830381865afa158015612287573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ab9190612f12565b6122f75760405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420726566657272616c207369676e617475726500000000000060448201526064016104b1565b6005546040517f0fededb20000000000000000000000000000000000000000000000000000000081526004810187905260009182916001600160a01b0390911690630fededb290602401602060405180830381865afa15801561235e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123829190612f12565b1561241d576005546040517fbe64b069000000000000000000000000000000000000000000000000000000008152600481018b9052602481018990526001600160a01b039091169063be64b069906044016040805180830381865afa1580156123ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124139190613048565b90925090506124af565b6006546040517f0f95767e000000000000000000000000000000000000000000000000000000008152600481018b9052602481018890526001600160a01b0390911690630f95767e906044016040805180830381865afa158015612485573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a99190613048565b90925090505b6005546040517f6cc6b278000000000000000000000000000000000000000000000000000000008152600481018990526001600160a01b0390911690636cc6b27890602401600060405180830381600087803b15801561250e57600080fd5b505af1158015612522573d6000803e3d6000fd5b5050505060008211156125aa576005546040517ff340fa010000000000000000000000000000000000000000000000000000000081526001600160a01b038a811660048301529091169063f340fa019084906024016000604051808303818588803b15801561259057600080fd5b505af11580156125a4573d6000803e3d6000fd5b50505050505b6125b4818a612d21565b9998505050505050505050565b600754604080517f828eab0e00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163828eab0e9160048083019260209291908290030181865afa158015612624573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126489190612fbd565b6007546040519192506001600160a01b031690637a806d6b90849081908590612678908990600a9060200161306c565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016126a69493929190613154565b6020604051808303816000875af11580156126c5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee09190612e15565b60008083601f8401126126fb57600080fd5b50813567ffffffffffffffff81111561271357600080fd5b60208301915083602082850101111561272b57600080fd5b9250929050565b80151581146113cd57600080fd5b6000806000806060858703121561275657600080fd5b843567ffffffffffffffff81111561276d57600080fd5b612779878288016126e9565b90955093505060208501359150604085013561279481612732565b939692955090935050565b6001600160a01b03811681146113cd57600080fd5b6000602082840312156127c657600080fd5b81356127d18161279f565b9392505050565b60008083601f8401126127ea57600080fd5b50813567ffffffffffffffff81111561280257600080fd5b6020830191508360208260051b850101111561272b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561286f5761286f61281d565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156128bc576128bc61281d565b604052919050565b600060a082840312156128d657600080fd5b6128de61284c565b905081356128eb8161279f565b80825250602080830135818301526040830135604083015260608301356060830152608083013567ffffffffffffffff8082111561292857600080fd5b818501915085601f83011261293c57600080fd5b81358181111561294e5761294e61281d565b61297e847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612875565b9150808252868482850101111561299457600080fd5b808484018584013760008482840101525080608085015250505092915050565b60008060008060008060008060e0898b0312156129d057600080fd5b883567ffffffffffffffff808211156129e857600080fd5b6129f48c838d016127d8565b909a50985060208b01359150612a098261279f565b90965060408a0135955060608a013590612a228261279f565b90945060808a013590612a3482612732565b90935060a08a013590612a4682612732565b90925060c08a01359080821115612a5c57600080fd5b50612a698b828c016128c4565b9150509295985092959890939650565b600080600060408486031215612a8e57600080fd5b833567ffffffffffffffff811115612aa557600080fd5b612ab1868287016126e9565b909790965060209590950135949350505050565b60008060208385031215612ad857600080fd5b823567ffffffffffffffff811115612aef57600080fd5b612afb858286016126e9565b90969095509350505050565b600080600060408486031215612b1c57600080fd5b833567ffffffffffffffff811115612b3357600080fd5b612ab1868287016127d8565b60008060008060608587031215612b5557600080fd5b843567ffffffffffffffff811115612b6c57600080fd5b612b78878288016126e9565b9095509350506020850135612b8c8161279f565b9396929550929360400135925050565b60005b83811015612bb7578181015183820152602001612b9f565b83811115610ee05750506000910152565b60008151808452612be0816020860160208601612b9c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006127d16020830184612bc8565b60008060008060008060008060e0898b031215612c4157600080fd5b883567ffffffffffffffff80821115612c5957600080fd5b6129f48c838d016126e9565b60008060008060608587031215612c7b57600080fd5b843567ffffffffffffffff811115612c9257600080fd5b612c9e878288016126e9565b9095509350506020850135915060408501356127948161279f565b60008060008060608587031215612ccf57600080fd5b843567ffffffffffffffff811115612ce657600080fd5b612779878288016127d8565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082821015612d3357612d33612cf2565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612d9c57600080fd5b83018035915067ffffffffffffffff821115612db757600080fd5b60200191503681900382131561272b57600080fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612dfe57612dfe612cf2565b5060010190565b8183823760009101908152919050565b600060208284031215612e2757600080fd5b5051919050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b606081526000612e8b606083018688612e2e565b6020830194909452506040015292915050565b600060608284031215612eb057600080fd5b6040516060810181811067ffffffffffffffff82111715612ed357612ed361281d565b80604052508251815260208301516020820152604083015160408201528091505092915050565b60008219821115612f0d57612f0d612cf2565b500190565b600060208284031215612f2457600080fd5b81516127d181612732565b600181811c90821680612f4357607f821691505b60208210811415612f7d577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b608081526000612f97608083018789612e2e565b60208301959095525060408101929092526001600160a01b031660609091015292915050565b600060208284031215612fcf57600080fd5b81516127d18161279f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6001600160a01b038616815284602082015283604082015282606082015260a06080820152600061303d60a0830184612bc8565b979650505050505050565b6000806040838503121561305b57600080fd5b505080516020909101519092909150565b60008351602061307f8285838901612b9c565b845491840191600090600181811c908083168061309d57607f831692505b8583108114156130d4577f4e487b710000000000000000000000000000000000000000000000000000000085526022600452602485fd5b8080156130e8576001811461311757613144565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00851688528388019550613144565b60008b81526020902060005b8581101561313c5781548a820152908401908801613123565b505083880195505b50939a9950505050505050505050565b60006001600160a01b0380871683528086166020840152808516604084015250608060608301526112e46080830184612bc856fea26469706673582212209ed40547eb97ea3910df6cd3ccc24ad9332952ecf4d8f08e07afa6c211cbcc3264736f6c634300080c0033000000000000000000000000e3b1d32e43ce8d658368e2cbff95d57ef39be8a60000000000000000000000009a45d1e9000ca0b3aa9b5f0c111aca87e65c1c0a0000000000000000000000007b13756870e4f29482c9519101d916150f5d2390000000000000000000000000e230e8ab92577a2b74c781c0c9614b9474ab3acb000000000000000000000000b5c0075350655e742a4017c9d1d97cf46073f4b1000000000000000000000000c647d0ebeddc9eb8ffa01e992511cc5cbef270d60000000000000000000000000e76a6dc9af8080b48c51e564e964cd15b9d6664000000000000000000000000000000000000000000000000000000000000000c

Deployed Bytecode

0x60806040526004361061016a5760003560e01c80639791c097116100cb578063d62949d31161007f578063f2fde38b11610059578063f2fde38b146103a5578063fe47a9f2146103c5578063fefee5e1146103e557600080fd5b8063d62949d314610350578063d8b7f1c014610372578063dde2b21f1461038557600080fd5b8063aeb8ce9b116100b0578063aeb8ce9b146102fd578063bf31e5301461031d578063d393c8711461033d57600080fd5b80639791c097146102ba578063acf1a841146102ea57600080fd5b80635994f5231161012257806383e7f6ff1161010757806383e7f6ff146102425780638a95b09f146102845780638da5cb5b1461029c57600080fd5b80635994f5231461021a578063715018a61461022d57600080fd5b80633cea70d9116101535780633cea70d914610199578063530e784f146101d657806354fd4d50146101f657600080fd5b806339b94c581461016f5780633ccfd60b14610184575b600080fd5b61018261017d366004612740565b6103f8565b005b34801561019057600080fd5b506101826104c3565b3480156101a557600080fd5b506008546101b9906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101e257600080fd5b506101826101f13660046127b4565b610645565b34801561020257600080fd5b5061020c60095481565b6040519081526020016101cd565b6101826102283660046129b4565b610701565b34801561023957600080fd5b50610182610859565b34801561024e57600080fd5b5061026261025d366004612a79565b6108bf565b60408051825181526020808401519082015291810151908201526060016101cd565b34801561029057600080fd5b5061020c6301e1338081565b3480156102a857600080fd5b506000546001600160a01b03166101b9565b3480156102c657600080fd5b506102da6102d5366004612ac5565b6109fe565b60405190151581526020016101cd565b6101826102f8366004612a79565b610e27565b34801561030957600080fd5b506102da610318366004612ac5565b610ee6565b34801561032957600080fd5b5061020c610338366004612b07565b610fa2565b61018261034b366004612b3f565b611018565b34801561035c57600080fd5b506103656110af565b6040516101cd9190612c12565b610182610380366004612c25565b61113d565b34801561039157600080fd5b506102626103a0366004612c65565b6111ac565b3480156103b157600080fd5b506101826103c03660046127b4565b6112ee565b3480156103d157600080fd5b506101826103e03660046127b4565b6113d0565b6101826103f3366004612cb9565b61149f565b6000610407858585853461151a565b9050803411156104bc5760003361041e8334612d21565b6040515b60006040518083038185875af1925050503d806000811461045f576040519150601f19603f3d011682016040523d82523d6000602084013e610464565b606091505b50509050806104ba5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064015b60405180910390fd5b505b5050505050565b6008546001600160a01b031633146105435760405162461bcd60e51b815260206004820152602260248201527f4f6e6c79207472656173757279206d616e616765722063616e2077697468647260448201527f617700000000000000000000000000000000000000000000000000000000000060648201526084016104b1565b600260015414156105965760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104b1565b60026001556008546040516000916001600160a01b03169047908381818185875af1925050503d80600081146105e8576040519150601f19603f3d011682016040523d82523d6000602084013e6105ed565b606091505b505090508061063e5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064016104b1565b5060018055565b6000546001600160a01b0316331461069f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104b1565b600480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517ff261845a790fe29bbd6631e2ca4a5bdc83e6eed7c3271d9590d97287e00e912390600090a250565b3460005b888110156107a157600061077f8b8b8481811061072457610724612d38565b90506020028101906107369190612d67565b6040518060c001604052808d6001600160a01b031681526020018c81526020018b6001600160a01b031681526020018a1515815260200189151581526020018781525087611757565b905061078b8184612d21565b925050808061079990612dcc565b915050610705565b50801561084e576000336001600160a01b0316826040515b60006040518083038185875af1925050503d80600081146107f6576040519150601f19603f3d011682016040523d82523d6000602084013e6107fb565b606091505b505090508061084c5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064016104b1565b505b505050505050505050565b6000546001600160a01b031633146108b35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104b1565b6108bd6000611d6d565b565b6108e360405180606001604052806000815260200160008152602001600081525090565b600084846040516108f5929190612e05565b604051908190038120600480546002547fd6e4fa860000000000000000000000000000000000000000000000000000000085529184018390529193506001600160a01b039182169263d831223c928992899291169063d6e4fa8690602401602060405180830381865afa158015610970573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109949190612e15565b876040518563ffffffff1660e01b81526004016109b49493929190612e77565b606060405180830381865afa1580156109d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109f59190612e9e565b95945050505050565b60006003610a4184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611dd592505050565b1015610a4f57506000610e21565b600083838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052509394505050505b60028251610a989190612d21565b811015610e1a57818181518110610ab157610ab1612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167fe200000000000000000000000000000000000000000000000000000000000000148015610b69575081610b0e826001612efa565b81518110610b1e57610b1e612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f8000000000000000000000000000000000000000000000000000000000000000145b15610cc35781610b7a826002612efa565b81518110610b8a57610b8a612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f8b000000000000000000000000000000000000000000000000000000000000001480610c41575081610be6826002612efa565b81518110610bf657610bf6612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f8c00000000000000000000000000000000000000000000000000000000000000145b80610cae575081610c53826002612efa565b81518110610c6357610c63612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167f8d00000000000000000000000000000000000000000000000000000000000000145b15610cbe57600092505050610e21565b610e08565b818181518110610cd557610cd5612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167fef000000000000000000000000000000000000000000000000000000000000001415610e085781610d30826001612efa565b81518110610d4057610d40612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167fbb00000000000000000000000000000000000000000000000000000000000000148015610df8575081610d9d826002612efa565b81518110610dad57610dad612d38565b6020910101517fff00000000000000000000000000000000000000000000000000000000000000167fbf00000000000000000000000000000000000000000000000000000000000000145b15610e0857600092505050610e21565b80610e1281612dcc565b915050610a8a565b5060019150505b92915050565b6000610e3784848460003461151a565b905080341115610ee057600033610e4e8334612d21565b604051600081818185875af1925050503d8060008114610e8a576040519150601f19603f3d011682016040523d82523d6000602084013e610e8f565b606091505b50509050806104bc5760405162461bcd60e51b815260206004820152601460248201527f4661696c656420746f2073656e6420457468657200000000000000000000000060448201526064016104b1565b50505050565b6000808383604051610ef9929190612e05565b60405180910390209050610f0d84846109fe565b8015610f9a57506002546040517f96e494e8000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b03909116906396e494e890602401602060405180830381865afa158015610f76573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f9a9190612f12565b949350505050565b6000805b83811015611010576000610fdd868684818110610fc557610fc5612d38565b9050602002810190610fd79190612d67565b866108bf565b60208101518151919250610ff091612efa565b610ffa9084612efa565b925050808061100890612dcc565b915050610fa6565b509392505050565b600061040785856040518060c00160405280876001600160a01b0316815260200186815260200160006001600160a01b03168152602001600015158152602001600015158152602001348152506040518060a0016040528060006001600160a01b031681526020016000801b8152602001600081526020016000815260200160405180602001604052806000815250815250611757565b600a80546110bc90612f2f565b80601f01602080910402602001604051908101604052809291908181526020018280546110e890612f2f565b80156111355780601f1061110a57610100808354040283529160200191611135565b820191906000526020600020905b81548152906001019060200180831161111857829003601f168201915b505050505081565b600061118d89896040518060c001604052808b6001600160a01b031681526020018a8152602001896001600160a01b03168152602001881515815260200187151581526020013481525085611757565b90508034111561084e576000336111a48334612d21565b6040516107b9565b6111d060405180606001604052806000815260200160008152602001600081525090565b600085856040516111e2929190612e05565b604051908190038120600480546002547fd6e4fa860000000000000000000000000000000000000000000000000000000085529184018390529193506001600160a01b0391821692635b7f4779928a928a9291169063d6e4fa8690602401602060405180830381865afa15801561125d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112819190612e15565b88886040518663ffffffff1660e01b81526004016112a3959493929190612f83565b606060405180830381865afa1580156112c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e49190612e9e565b9695505050505050565b6000546001600160a01b031633146113485760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104b1565b6001600160a01b0381166113c45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104b1565b6113cd81611d6d565b50565b6000546001600160a01b0316331461142a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104b1565b6001600160a01b03811661143d57600080fd5b600880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383169081179091556040517fb5dc0e9c1936b5f549de73a1a5e47b42c3a2d5c3e230587217c158cc2de5bd5790600090a250565b3460005b848110156114fe5760006114dc8787848181106114c2576114c2612d38565b90506020028101906114d49190612d67565b87878761151a565b90506114e88184612d21565b92505080806114f690612dcc565b9150506114a3565b5080156104bc576000336001600160a01b031682604051610422565b60006002600154141561156f5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104b1565b60026001556040805160608101825260008082526020820181905291810191909152831561162c576115a3878787336111ac565b60035460408281015190517f4705532100000000000000000000000000000000000000000000000000000000815233600482015260248101919091529192506001600160a01b031690634705532190604401600060405180830381600087803b15801561160f57600080fd5b505af1158015611623573d6000803e3d6000fd5b5050505061163a565b6116378787876108bf565b90505b6020810151815161164b9190612efa565b91508183101561165a57600080fd5b6000878760405161166c929190612e05565b6040519081900381206002547fc475abff00000000000000000000000000000000000000000000000000000000835260048301829052602483018990529092506000916001600160a01b039091169063c475abff906044016020604051808303816000875af11580156116e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117079190612e15565b9050817f3da24c024582931cfaf8267d8ed24d13a82a8068d5bd337d30ec45cea4e506ae8a8a878560405161173f9493929190612e77565b60405180910390a25050506001805595945050505050565b6000600260015414156117ac5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104b1565b60026001819055506117c8858585602001518660600151611fdc565b9050600085856040516117dc929190612e05565b60408051918290039091209085015190915081906000906001600160a01b031615611bf05760025460208701516040517ffca247ac0000000000000000000000000000000000000000000000000000000081526004810185905230602482015260448101919091526001600160a01b039091169063fca247ac906064016020604051808303816000875af1158015611878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189c9190612e15565b90506000600260009054906101000a90046001600160a01b03166001600160a01b031663ddf7fcb06040518163ffffffff1660e01b8152600401602060405180830381865afa1580156118f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119179190612e15565b6040805160208101929092528101859052606001604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815282825280516020918201206002547fb1e8eb9500000000000000000000000000000000000000000000000000000000855292519094506001600160a01b039092169263b1e8eb9592600480830193928290030181865afa1580156119be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e29190612fbd565b60408089015190517f1896f70a000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b039182166024820152911690631896f70a90604401600060405180830381600087803b158015611a4a57600080fd5b505af1158015611a5e573d6000803e3d6000fd5b50505050604087810151885191517fd5fa2b00000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03928316602482015291169063d5fa2b0090604401600060405180830381600087803b158015611acc57600080fd5b505af1158015611ae0573d6000803e3d6000fd5b505060025489516040517f28ed4f6c000000000000000000000000000000000000000000000000000000008152600481018890526001600160a01b039182166024820152911692506328ed4f6c9150604401600060405180830381600087803b158015611b4c57600080fd5b505af1158015611b60573d6000803e3d6000fd5b505060025489516040517f23b872dd0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03918216602482015260448101889052911692506323b872dd9150606401600060405180830381600087803b158015611bd257600080fd5b505af1158015611be6573d6000803e3d6000fd5b5050505050611c91565b600254865160208801516040517ffca247ac000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b039283166024820152604481019190915291169063fca247ac906064016020604051808303816000875af1158015611c6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8e9190612e15565b90505b85600001516001600160a01b0316837fca6abbe9d7f11422cb6ca7629fbf6fe9efb1c621f71ce8f02b9f2a230097404f8a8a8886604051611cd59493929190612e77565b60405180910390a384516001600160a01b031615611d1257611d0f8486600001518760200151886040015189606001518a60800151612218565b93505b856080015115611d5e57611d5e88888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050895191506125c19050565b50505060018055949350505050565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8051600090819081905b80821015611fd3576000858381518110611dfb57611dfb612d38565b01602001517fff000000000000000000000000000000000000000000000000000000000000001690507f8000000000000000000000000000000000000000000000000000000000000000811015611e5e57611e57600184612efa565b9250611fc0565b7fe0000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161015611eb357611e57600284612efa565b7ff0000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161015611f0857611e57600384612efa565b7ff8000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161015611f5d57611e57600484612efa565b7ffc000000000000000000000000000000000000000000000000000000000000007fff0000000000000000000000000000000000000000000000000000000000000082161015611fb257611e57600584612efa565b611fbd600684612efa565b92505b5082611fcb81612dcc565b935050611ddf565b50909392505050565b6000611fe88585610ee6565b611ff157600080fd5b61201560405180606001604052806000815260200160008152602001600081525090565b82156121d7576003546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526000916001600160a01b0316906370a0823190602401602060405180830381865afa15801561207d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120a19190612e15565b90506120af878787336111ac565b60035460408281015190517f4705532100000000000000000000000000000000000000000000000000000000815233600482015260248101919091529193506001600160a01b031690634705532190604401600060405180830381600087803b15801561211b57600080fd5b505af115801561212f573d6000803e3d6000fd5b5050505080600014806121c557506003546040517f70a082310000000000000000000000000000000000000000000000000000000081523360048201526001600160a01b03909116906370a0823190602401602060405180830381865afa15801561219e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c29190612e15565b81115b6121d1576121d1612fda565b506121e5565b6121e28686866108bf565b90505b602081015181516000916121f891612efa565b90506301e1338085101561220b57600080fd5b803410156112e457600080fd5b6006546040517fbecd725c0000000000000000000000000000000000000000000000000000000081526000916001600160a01b03169063becd725c9061226a9089908990899089908990600401613009565b602060405180830381865afa158015612287573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122ab9190612f12565b6122f75760405162461bcd60e51b815260206004820152601a60248201527f496e76616c696420726566657272616c207369676e617475726500000000000060448201526064016104b1565b6005546040517f0fededb20000000000000000000000000000000000000000000000000000000081526004810187905260009182916001600160a01b0390911690630fededb290602401602060405180830381865afa15801561235e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123829190612f12565b1561241d576005546040517fbe64b069000000000000000000000000000000000000000000000000000000008152600481018b9052602481018990526001600160a01b039091169063be64b069906044016040805180830381865afa1580156123ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124139190613048565b90925090506124af565b6006546040517f0f95767e000000000000000000000000000000000000000000000000000000008152600481018b9052602481018890526001600160a01b0390911690630f95767e906044016040805180830381865afa158015612485573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124a99190613048565b90925090505b6005546040517f6cc6b278000000000000000000000000000000000000000000000000000000008152600481018990526001600160a01b0390911690636cc6b27890602401600060405180830381600087803b15801561250e57600080fd5b505af1158015612522573d6000803e3d6000fd5b5050505060008211156125aa576005546040517ff340fa010000000000000000000000000000000000000000000000000000000081526001600160a01b038a811660048301529091169063f340fa019084906024016000604051808303818588803b15801561259057600080fd5b505af11580156125a4573d6000803e3d6000fd5b50505050505b6125b4818a612d21565b9998505050505050505050565b600754604080517f828eab0e00000000000000000000000000000000000000000000000000000000815290516000926001600160a01b03169163828eab0e9160048083019260209291908290030181865afa158015612624573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126489190612fbd565b6007546040519192506001600160a01b031690637a806d6b90849081908590612678908990600a9060200161306c565b6040516020818303038152906040526040518563ffffffff1660e01b81526004016126a69493929190613154565b6020604051808303816000875af11580156126c5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee09190612e15565b60008083601f8401126126fb57600080fd5b50813567ffffffffffffffff81111561271357600080fd5b60208301915083602082850101111561272b57600080fd5b9250929050565b80151581146113cd57600080fd5b6000806000806060858703121561275657600080fd5b843567ffffffffffffffff81111561276d57600080fd5b612779878288016126e9565b90955093505060208501359150604085013561279481612732565b939692955090935050565b6001600160a01b03811681146113cd57600080fd5b6000602082840312156127c657600080fd5b81356127d18161279f565b9392505050565b60008083601f8401126127ea57600080fd5b50813567ffffffffffffffff81111561280257600080fd5b6020830191508360208260051b850101111561272b57600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561286f5761286f61281d565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156128bc576128bc61281d565b604052919050565b600060a082840312156128d657600080fd5b6128de61284c565b905081356128eb8161279f565b80825250602080830135818301526040830135604083015260608301356060830152608083013567ffffffffffffffff8082111561292857600080fd5b818501915085601f83011261293c57600080fd5b81358181111561294e5761294e61281d565b61297e847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612875565b9150808252868482850101111561299457600080fd5b808484018584013760008482840101525080608085015250505092915050565b60008060008060008060008060e0898b0312156129d057600080fd5b883567ffffffffffffffff808211156129e857600080fd5b6129f48c838d016127d8565b909a50985060208b01359150612a098261279f565b90965060408a0135955060608a013590612a228261279f565b90945060808a013590612a3482612732565b90935060a08a013590612a4682612732565b90925060c08a01359080821115612a5c57600080fd5b50612a698b828c016128c4565b9150509295985092959890939650565b600080600060408486031215612a8e57600080fd5b833567ffffffffffffffff811115612aa557600080fd5b612ab1868287016126e9565b909790965060209590950135949350505050565b60008060208385031215612ad857600080fd5b823567ffffffffffffffff811115612aef57600080fd5b612afb858286016126e9565b90969095509350505050565b600080600060408486031215612b1c57600080fd5b833567ffffffffffffffff811115612b3357600080fd5b612ab1868287016127d8565b60008060008060608587031215612b5557600080fd5b843567ffffffffffffffff811115612b6c57600080fd5b612b78878288016126e9565b9095509350506020850135612b8c8161279f565b9396929550929360400135925050565b60005b83811015612bb7578181015183820152602001612b9f565b83811115610ee05750506000910152565b60008151808452612be0816020860160208601612b9c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6020815260006127d16020830184612bc8565b60008060008060008060008060e0898b031215612c4157600080fd5b883567ffffffffffffffff80821115612c5957600080fd5b6129f48c838d016126e9565b60008060008060608587031215612c7b57600080fd5b843567ffffffffffffffff811115612c9257600080fd5b612c9e878288016126e9565b9095509350506020850135915060408501356127948161279f565b60008060008060608587031215612ccf57600080fd5b843567ffffffffffffffff811115612ce657600080fd5b612779878288016127d8565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082821015612d3357612d33612cf2565b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112612d9c57600080fd5b83018035915067ffffffffffffffff821115612db757600080fd5b60200191503681900382131561272b57600080fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612dfe57612dfe612cf2565b5060010190565b8183823760009101908152919050565b600060208284031215612e2757600080fd5b5051919050565b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b606081526000612e8b606083018688612e2e565b6020830194909452506040015292915050565b600060608284031215612eb057600080fd5b6040516060810181811067ffffffffffffffff82111715612ed357612ed361281d565b80604052508251815260208301516020820152604083015160408201528091505092915050565b60008219821115612f0d57612f0d612cf2565b500190565b600060208284031215612f2457600080fd5b81516127d181612732565b600181811c90821680612f4357607f821691505b60208210811415612f7d577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b608081526000612f97608083018789612e2e565b60208301959095525060408101929092526001600160a01b031660609091015292915050565b600060208284031215612fcf57600080fd5b81516127d18161279f565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b6001600160a01b038616815284602082015283604082015282606082015260a06080820152600061303d60a0830184612bc8565b979650505050505050565b6000806040838503121561305b57600080fd5b505080516020909101519092909150565b60008351602061307f8285838901612b9c565b845491840191600090600181811c908083168061309d57607f831692505b8583108114156130d4577f4e487b710000000000000000000000000000000000000000000000000000000085526022600452602485fd5b8080156130e8576001811461311757613144565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00851688528388019550613144565b60008b81526020902060005b8581101561313c5781548a820152908401908801613123565b505083880195505b50939a9950505050505050505050565b60006001600160a01b0380871683528086166020840152808516604084015250608060608301526112e46080830184612bc856fea26469706673582212209ed40547eb97ea3910df6cd3ccc24ad9332952ecf4d8f08e07afa6c211cbcc3264736f6c634300080c0033

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

000000000000000000000000e3b1d32e43ce8d658368e2cbff95d57ef39be8a60000000000000000000000009a45d1e9000ca0b3aa9b5f0c111aca87e65c1c0a0000000000000000000000007b13756870e4f29482c9519101d916150f5d2390000000000000000000000000e230e8ab92577a2b74c781c0c9614b9474ab3acb000000000000000000000000b5c0075350655e742a4017c9d1d97cf46073f4b1000000000000000000000000c647d0ebeddc9eb8ffa01e992511cc5cbef270d60000000000000000000000000e76a6dc9af8080b48c51e564e964cd15b9d6664000000000000000000000000000000000000000000000000000000000000000c

-----Decoded View---------------
Arg [0] : _base (address): 0xE3b1D32e43Ce8d658368e2CBFF95D57Ef39Be8a6
Arg [1] : _prices (address): 0x9a45d1E9000Ca0B3aa9B5F0c111aca87E65c1c0a
Arg [2] : _giftCardLedger (address): 0x7B13756870e4f29482C9519101D916150f5d2390
Arg [3] : _referralHub (address): 0xE230e8ab92577A2b74C781C0C9614B9474ab3ACB
Arg [4] : _referralVerifier (address): 0xB5C0075350655E742A4017c9d1d97cF46073f4B1
Arg [5] : _reverseRegistrar (address): 0xc647d0EbEdDc9Eb8FFa01E992511cC5cBeF270D6
Arg [6] : _treasuryManager (address): 0x0e76a6dC9af8080b48C51E564e964CD15b9D6664
Arg [7] : _version (uint256): 12

-----Encoded View---------------
8 Constructor Arguments found :
Arg [0] : 000000000000000000000000e3b1d32e43ce8d658368e2cbff95d57ef39be8a6
Arg [1] : 0000000000000000000000009a45d1e9000ca0b3aa9b5f0c111aca87e65c1c0a
Arg [2] : 0000000000000000000000007b13756870e4f29482c9519101d916150f5d2390
Arg [3] : 000000000000000000000000e230e8ab92577a2b74c781c0c9614b9474ab3acb
Arg [4] : 000000000000000000000000b5c0075350655e742a4017c9d1d97cf46073f4b1
Arg [5] : 000000000000000000000000c647d0ebeddc9eb8ffa01e992511cc5cbef270d6
Arg [6] : 0000000000000000000000000e76a6dc9af8080b48c51e564e964cd15b9d6664
Arg [7] : 000000000000000000000000000000000000000000000000000000000000000c


Block Transaction Gas Used Reward
view all blocks produced
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
View All Validatorset

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ 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.