Contract 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 3

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xbfcf238510e8604fe1f07a23c8a7eef1fb5b6bb3cb83e2aaf188158802422f1fBulk Commit1061382272023-06-29 14:10:13288 days 10 hrs ago0x3dea08a93d8922a5afbeeb66e10477a9719d2b3e IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0 ETH0.00008787 0.1
0x1fd4730c5ff8e0adc3770f073e2311e97270c2869d568ae3df4d56332ede4c3bBulk Register824099322023-04-20 10:57:26358 days 13 hrs ago0xdede0ed80bfd12446b1c1aa59e4424371d249ea7 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002610418127561 ETH0.0002737 0.1
0x9fa0237858109e6da75b06c610a37462a9faeb7b49b4b5f2646d863591a4fe06Bulk Commit824098312023-04-20 10:57:00358 days 13 hrs ago0xdede0ed80bfd12446b1c1aa59e4424371d249ea7 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0 ETH0.00010433 0.1
0x5cc51621b65d89563d35d253dac7bac9d5827760595bba1cd15eb9a44819e06dBulk Commit824093232023-04-20 10:54:53358 days 13 hrs ago0xfc5edc3a609799d7502f8d2b9fdda220db924e79 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0 ETH0.00010433 0.1
0x7fb2cfc3bef893d94a8f9f23ea7615d924f1de1b0a6db6aebc86d67ab70a9dbdBulk Commit820242722023-04-19 8:06:23359 days 16 hrs ago0xd46906e1a3e3173a427d33636f2bd0cdcaf4719f IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0 ETH0.00009855 0.1
0x0fb8d85a60cc462a819031e983693766a4ed78ac4f22995167817cffecea42adBulk Register820237972023-04-19 8:04:21359 days 16 hrs ago0xa5c597a62f1a23fdc51fa86a42b8cbd87a194eb6 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002463672901529 ETH0.00024995 0.1
0xc00fd570ae15330d7dcd301ee43bc2a42407ca72f8a1b93456a0bb60b7ded555Bulk Commit820236872023-04-19 8:03:53359 days 16 hrs ago0xa5c597a62f1a23fdc51fa86a42b8cbd87a194eb6 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0 ETH0.00009866 0.10219
0x7f03c4bed7bfaf0aca4148af8afc0ca1db86af6e4de6f639a07cc868d6ae955dBulk Register820081352023-04-19 6:59:40359 days 17 hrs ago0x70cae8ad753a1de68892c3b9aa7cae8ecf03e99e IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00024999 0.1
0xa8148ad40057f8964b35abbbdf026789e8f69463b058d6d7ae5477aaa4486e08Bulk Register820080582023-04-19 6:59:21359 days 17 hrs ago0x303170be0ee9a417947aabaeaac1841b34a05860 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025007 0.10003
0x63974f858ab882d7ed5e4bc01e5b9d5244dee5889657d300eaeeb685c0d0e776Bulk Register820080562023-04-19 6:59:21359 days 17 hrs ago0x15bc67fd4af2f124f25428f80d1442451888acb0 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025152 0.10061
0xbc2d914bc7f3b8e54799c7a3ab7b8d6c3dbfbadc2b9866752e0cc5cda65682d2Bulk Register820080542023-04-19 6:59:20359 days 17 hrs ago0x0ed2ad51905c99c8225e5e9ac7dea9ed82608b73 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025026 0.10011
0x07d83a4792c591ebc6fe0878f5df771b2f2789828613edde7969204374c5f839Bulk Register820080522023-04-19 6:59:20359 days 17 hrs ago0x505434e43d0120ce7c7760d699f50271ca33e65b IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025049 0.1002
0x279e8cf339b1b32d15b4dc86b5b18e424d7510f8c2334ad5e408c3d9371c92dcBulk Register820080512023-04-19 6:59:19359 days 17 hrs ago0xa9fa6b9f2a8c5a860bb790f3cc3a045ec5e719dd IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00024998 0.1
0x1a849e0de03aa4553cb138252fcd2d17637a8326eff858b8dc9d956586b82262Bulk Register820080482023-04-19 6:59:19359 days 17 hrs ago0xf95f0c24ee5fa8b32f48830dc1db330be396f656 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.000251 0.10041
0x25250440959891fe28d6da7187c8d309fd41081369b395895fe59a0e8150f817Bulk Register820080462023-04-19 6:59:18359 days 17 hrs ago0xbba889ca102e33699378f88c89c0d4013fa7a18f IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025079 0.10033
0x8e528690d08288fb401d35df135e91aa0c905307d2f36d654953a491a858aaf5Bulk Register820080432023-04-19 6:59:17359 days 17 hrs ago0xe6ccbe7e2a6bd0d9a892317c1f873dedd9336872 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025255 0.10103
0xb81ca3b99dc42d99eb4abb0b949728bfc14820b7f28bbbae23068739b9f7a1a2Bulk Register820080432023-04-19 6:59:17359 days 17 hrs ago0x234f7b8a41347f437f597beba6f08b5f1b30f294 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025256 0.10103
0xc1c20ef00c2d4b2a29f608c95cd8465c2ab67fa8fc978a79539ff5d98dfb8c28Bulk Register820080422023-04-19 6:59:17359 days 17 hrs ago0xe55f06603c4662c4b0ffc762c09562e4ce19adda IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025236 0.10095
0x162ced03b27f5ad8d74030b0ba49c3e9b3b7e2de0e46184ccf165af11d86b4ccBulk Register820080412023-04-19 6:59:17359 days 17 hrs ago0x4e45ceb7db49cb6d94900fc05847852eae410b9a IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.0002522 0.10088
0xd5cb66790ce0b6389ee86257764eca28ff914abfc6d4f8f10b8d733fb217690eBulk Register820080412023-04-19 6:59:17359 days 17 hrs ago0x7d86b002c4c0ede198a6f4a64a30f4e376be1fb3 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025219 0.10088
0xdb95185f865fc1164526d42ebf5718e57e2b771c13cb29153c62b768df0dc624Bulk Register820080402023-04-19 6:59:17359 days 17 hrs ago0xc5bb52e8cf285bd553f09ed4d19b66458c3a49c2 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025466 0.10187
0x4b06c76fa0d53a254908ac752a7af94b9f4f8e7b17a5966d17a7bb5c1b586d5dBulk Register820080402023-04-19 6:59:17359 days 17 hrs ago0x0486d1d86662a864d911061592335e1f7cd04876 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025466 0.10187
0xc9b4885dfdcdffa4c99d42d04c96394396dd314248ac000c5ebf279d777dcbf6Bulk Register820080402023-04-19 6:59:17359 days 17 hrs ago0xa5458d10624cd75a7f7edea585d2ed2145597d34 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025467 0.10187
0x310bd9bed9487031f68f86c0ca24f5eff4aff4ee9167fe2c3c7f35836e0acac3Bulk Register820080402023-04-19 6:59:17359 days 17 hrs ago0xa4870602d47cfcb4cbbf74d109bfd260c09dca51 IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.00025467 0.10187
0x876c0cc398de2cad59a702b1287005ca3fa22dd1cea825858d2e4c9b10303b3dBulk Register820080392023-04-19 6:59:16359 days 17 hrs ago0x6ecb280b5be110655ff3c32041bca296c47653bc IN  0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a0.002460808013548 ETH0.0002539 0.10157
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x1fd4730c5ff8e0adc3770f073e2311e97270c2869d568ae3df4d56332ede4c3b824099322023-04-20 10:57:26358 days 13 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002559233458393618 ETH
0x310bd9bed9487031f68f86c0ca24f5eff4aff4ee9167fe2c3c7f35836e0acac3820080402023-04-19 6:59:17359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xd91990a1bbb918abf89db2e3809bfd334faeaaacde18fa2c7786863d6c4710bd820080292023-04-19 6:59:14359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xf7ecca0fd6b58025a7fe81d200ca06aac89e02831418e4c4b1c0f4291e747fd4820080262023-04-19 6:59:13359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xe642bf2e7185c96e0ce2ad9da6b436d0eb4504962a55950978979e524ff6b5b5820080252023-04-19 6:59:13359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x33a764036124cfe9df6ad041469966cac83e9a72f985efb022dd446e0fbb3fbc820080242023-04-19 6:59:12359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xf39df75e9c21b223167744f171e9c247ca4029d7e58a9245e53678e4c91d1378820080192023-04-19 6:59:11359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x78a6591cb516b8a899d8c076e526293813e1b8b249baf01efb67849efb76c6ae820080182023-04-19 6:59:11359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x36a7debf6f9c12f9462e4fe90a8527dc6f741ce8b2d472c29afb547881e71830820080172023-04-19 6:59:11359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x9c5a77b8b1590a7ac10c5e4653f33f778cddc80609a858a000f4743a9a7c426a820080172023-04-19 6:59:11359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xa5dd38c4e1a48eb7016aa14afb8ca3c0669781e45618a1b9a45af9bdc1c14880820080172023-04-19 6:59:11359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x22a5d26707d7a6f16dd8415ebd65c50caf35628698f4b9cccbfa6baf15f9db1f820080172023-04-19 6:59:11359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x2dad93048d9b52907b28828c166a0c91da427bdf833ded79066f30a26f8ce23f820080172023-04-19 6:59:11359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x943deb7a35031c879dbcf89c5fbae4915a29923e0f4cf1587dc0973832806eb1820080162023-04-19 6:59:10359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xaa6816dc75afd2d689963c221bc53574ba3692403402359a752ef6cb04779436820080122023-04-19 6:59:09359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x275a61d04c37c1f4881239d590afae6c203138911b36700e288584425b85ae3d820080102023-04-19 6:59:09359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xaab75964dc508b9e3f291a1aed6671ee50c3bbd4a484229447d2a0d91d1661fd820080092023-04-19 6:59:09359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x01435f9455483e6a99218fa42f19ac41da3eef9b44ad494f494237cb81b7f69c820080092023-04-19 6:59:09359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x63b1c1696804d7f8796579ae3b5d2a34ba3a5f21467a7e76fc2a26c9894babbe820080092023-04-19 6:59:09359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x871f6a09879acede1bb66b7ea7e07a49e95ccc910702f86bfa7b61b0670c9a75820080082023-04-19 6:59:08359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xdd86fca6c3060c85b87b501d07fe0eb092d4917c997c4ff296a8cc7ef36a10c6820080072023-04-19 6:59:08359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x4eaf7a40794644f2702b51ea7713972b3019e0e0d461a0c777900884355703f1820080072023-04-19 6:59:08359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x1fa10b345d503c179b06282c90e3ec2589c28363c6a211255f2e4c59c2ff7eb7820080062023-04-19 6:59:08359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0xc3b5a4db68ca354ccd6864227b9d97ceeecd871f3ddcd5175207cb02cefb3edd820080062023-04-19 6:59:08359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
0x29ae1718a6e153de9d82215101cb0eae691759482724eb79d855f219ac854005820080062023-04-19 6:59:08359 days 17 hrs ago 0xe281066e8e4c730ac04d4f2a54fcb5025cd8403a 0xb7da95ec908cba7587b2243ca45d5a2fa92ce6180.002412556876027482 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ARBBulkRegistrarV3

Compiler Version
v0.8.12+commit.f00d7308

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
File 1 of 52 : ARBBulkRegistrarV3.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "./IBulkRegistrarV3.sol";
import "../arbregistrar/ARBRegistrarControllerV5.sol";
import "../price-oracle/ISidPriceOracle.sol";
import {ReferralInfo} from "../struct/SidStruct.sol";

contract ARBBulkRegistrarV3 is IBulkRegistrarV3 {
    ARBRegistrarControllerV5 public immutable registrarController;

    constructor(ARBRegistrarControllerV5 _registrarController) {
        registrarController = _registrarController;
    }

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

    function bulkMakeCommitmentWithConfig(
        string[] calldata name,
        address owner,
        bytes32 secret
    ) external view override returns (bytes32[] memory commitments) {
        commitments = new bytes32[](name.length);
        for (uint256 i = 0; i < name.length; i++) {
            commitments[i] = registrarController.makeCommitment(
                name[i],
                owner,
                secret
            );
        }
        return commitments;
    }

    function commitment(
        bytes32 commit
    ) external view override returns (uint256) {
        return registrarController.commitments(commit);
    }

    function bulkCommit(bytes32[] calldata commitments) external override {
        for (uint256 i = 0; i < commitments.length; i++) {
            registrarController.commit(commitments[i]);
        }
    }

    function bulkRegister(
        string[] calldata names,
        address owner,
        uint duration,
        bytes32 secret,
        address resolver,
        bool isUseGiftCard,
        ReferralInfo memory referralInfo
    ) external payable {
        uint256 cost = 0;
        for (uint256 i = 0; i < names.length; i++) {
            ISidPriceOracle.Price memory price;
            if (isUseGiftCard) {
                price = registrarController.rentPrice(
                    names[i],
                    duration,
                    owner
                );
            } else {
                price = registrarController.rentPrice(names[i], duration);
            }

            registrarController.registerWithConfigAndPoint{
                value: (price.base + price.premium)
            }(
                names[i],
                owner,
                duration,
                secret,
                resolver,
                isUseGiftCard,
                referralInfo
            );
            cost = cost + price.base + price.premium;
        }

        // Send any excess funds back
        if (msg.value > cost) {
            (bool sent, ) = msg.sender.call{value: msg.value - cost}("");
            require(sent, "Failed to send Ether");
        }
    }
}

File 2 of 52 : SidStruct.sol
pragma solidity >=0.8.4;

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

File 3 of 52 : ARBRegistrarControllerV5.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;
import "../price-oracle/ISidPriceOracle.sol";
import "../giftcard/SidGiftCardLedger.sol";

import {BaseRegistrarImplementation} from "./BaseRegistrarImplementation.sol";
import {StringUtils} from "../common/StringUtils.sol";
import {Resolver} from "../resolvers/Resolver.sol";
import {IARBRegistrarControllerV3, ISidPriceOracle} from "./IARBRegistrarControllerV3.sol";

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";

import {ReferralInfo} from "../struct/SidStruct.sol";
import {ReferralHub} from "../referral/ReferralHub.sol";
import {ReferralVerifier} from "../referral/ReferralVerifier.sol";

error CommitmentTooNew(bytes32 commitment);
error CommitmentTooOld(bytes32 commitment);
error NameNotAvailable(string name);
error DurationTooShort(uint256 duration);
error ResolverRequiredWhenDataSupplied();
error UnexpiredCommitmentExists(bytes32 commitment);
error InsufficientValue();
error Unauthorised(bytes32 node);
error MaxCommitmentAgeTooLow();
error MaxCommitmentAgeTooHigh();
error InvalidOwner(address owner);

/**
 * @dev A registrar controller for registering and renewing on public phase.
 */
contract ARBRegistrarControllerV5 is
    Ownable,
    IARBRegistrarControllerV3,
    IERC165,
    ReentrancyGuard
{
    using StringUtils for *;
    using Address for address;

    uint256 public constant MIN_REGISTRATION_DURATION = 365 days;
    uint256 private constant COIN_TYPE_ARB1 = 2147525809;
    uint256 private constant COIN_TYPE_ARB_NOVA = 2147525818;
    BaseRegistrarImplementation immutable base;
    ISidPriceOracle public immutable prices;
    uint256 public immutable minCommitmentAge;
    uint256 public immutable maxCommitmentAge;
    SidGiftCardLedger public immutable giftCardLedger;
    ReferralHub public immutable referralHub;
    ReferralVerifier public immutable referralVerifier;

    mapping(bytes32 => uint256) public commitments;

    event NameRegistered(
        string name,
        bytes32 indexed label,
        address indexed owner,
        uint256 baseCost,
        uint256 premium,
        uint256 expires
    );
    event NameRenewed(
        string name,
        bytes32 indexed label,
        uint256 cost,
        uint256 expires
    );

    event Referral();

    constructor(
        BaseRegistrarImplementation _base,
        ISidPriceOracle _prices,
        SidGiftCardLedger _giftCardLedger,
        ReferralHub _referralHub,
        ReferralVerifier _referralVerifier,
        uint256 _minCommitmentAge,
        uint256 _maxCommitmentAge
    ) {
        if (_maxCommitmentAge <= _minCommitmentAge) {
            revert MaxCommitmentAgeTooLow();
        }

        if (_maxCommitmentAge > block.timestamp) {
            revert MaxCommitmentAgeTooHigh();
        }

        base = _base;
        prices = _prices;
        giftCardLedger = _giftCardLedger;
        minCommitmentAge = _minCommitmentAge;
        maxCommitmentAge = _maxCommitmentAge;
        referralHub = _referralHub;
        referralVerifier = _referralVerifier;
    }

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

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

    function valid(string memory 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 memory name) public view override returns (bool) {
        bytes32 label = keccak256(bytes(name));
        return valid(name) && base.available(uint256(label));
    }

    function makeCommitment(
        string memory name,
        address owner,
        bytes32 secret
    ) public pure override returns (bytes32) {
        bytes32 label = keccak256(bytes(name));
        return keccak256(abi.encodePacked(label, owner, secret));
    }

    function commit(bytes32 commitment) public override {
        if (commitments[commitment] + maxCommitmentAge >= block.timestamp) {
            revert UnexpiredCommitmentExists(commitment);
        }
        commitments[commitment] = block.timestamp;
    }

    function registerWithConfigAndPoint(
        string memory name,
        address owner,
        uint duration,
        bytes32 secret,
        address resolver,
        bool isUsePoints,
        ReferralInfo memory referralInfo
    ) public payable override nonReentrant {
        ISidPriceOracle.Price memory price;
        if (isUsePoints) {
            price = rentPrice(name, duration, owner);
            //deduct points from gift card ledger
            giftCardLedger.deduct(owner, price.usedPoint);
        } else {
            price = rentPrice(name, duration);
        }

        if (msg.value < price.base + price.premium) {
            revert InsufficientValue();
        }

        if (owner == address(0)) {
            revert InvalidOwner(owner);
        }

        _consumeCommitment(name, duration, makeCommitment(name, owner, secret));

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

        // Set this contract as the (temporary) owner, giving it
        // permission to set up the resolver.
        uint256 expires = base.register(tokenId, address(this), duration);

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

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

        // Configure the resolver with Arbitrum One and Arbitrum Nova
        if (owner != address(0)) {
            Resolver(resolver).setAddr(nodehash, COIN_TYPE_ARB1, owner);
            Resolver(resolver).setAddr(nodehash, COIN_TYPE_ARB_NOVA, owner);
        }

        // Now transfer full ownership to the expeceted owner
        base.reclaim(tokenId, owner);
        base.transferFrom(address(this), owner, tokenId);

        emit NameRegistered(
            name,
            keccak256(bytes(name)),
            owner,
            price.base,
            price.premium,
            expires
        );
        
        uint256 cost = price.base + price.premium;
        if (referralInfo.referrerAddress != address(0)) {
            cost = _handleReferral(
                cost,
                referralInfo.referrerAddress,
                referralInfo.referrerNodehash,
                referralInfo.referralAmount,
                referralInfo.signedAt,
                referralInfo.signature
            );
        }

        if (msg.value > (cost)) {
            (bool sent, ) = msg.sender.call{value: msg.value - (cost)}("");
            require(sent, "Failed to send Ether");
        }
    }

    function registerWithConfig(
        string calldata name,
        address owner,
        uint256 duration,
        bytes32 secret,
        address resolver,
        bool reverseRecord
    ) public payable override {
        registerWithConfigAndPoint(
            name,
            owner,
            duration,
            secret,
            resolver,
            reverseRecord,
            ReferralInfo(address(0), bytes32(0), 0, 0, bytes(""))
        );
    }

    function renew(
        string calldata name,
        uint duration
    ) external payable override nonReentrant {
        renewWithPoint(name, duration, false);
    }

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

        // Refund any extra payment
        if (msg.value > cost) {
            (bool sent, ) = msg.sender.call{value: msg.value - cost}("");
            require(sent, "Failed to send Ether");
        }

        emit NameRenewed(name, label, cost, expires);
    }

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

    function supportsInterface(
        bytes4 interfaceID
    ) external pure returns (bool) {
        return
            interfaceID == type(IERC165).interfaceId ||
            interfaceID == type(IARBRegistrarControllerV3).interfaceId;
    }

    /* Internal functions */

    function _consumeCommitment(
        string memory name,
        uint256 duration,
        bytes32 commitment
    ) internal {
        // Require an old enough commitment.
        if (commitments[commitment] + minCommitmentAge > block.timestamp) {
            revert CommitmentTooNew(commitment);
        }

        // If the commitment is too old, or the name is registered, stop
        if (commitments[commitment] + maxCommitmentAge <= block.timestamp) {
            revert CommitmentTooOld(commitment);
        }
        if (!available(name)) {
            revert NameNotAvailable(name);
        }

        delete (commitments[commitment]);

        if (duration < MIN_REGISTRATION_DURATION) {
            revert DurationTooShort(duration);
        }
    }

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

File 4 of 52 : IBulkRegistrarV3.sol
pragma solidity >=0.8.4;
import {ReferralInfo} from "../struct/SidStruct.sol";

interface IBulkRegistrarV3 {
    function bulkRentPrice(string[] calldata names, uint256 duration) external view returns (uint256 total);

    function bulkRegister(string[] calldata names, address owner, uint duration, bytes32 secret, address resolver, bool isUseGiftCard, ReferralInfo calldata referralInfo) external payable;

    function bulkCommit(bytes32[] calldata commitments) external;

    function bulkMakeCommitmentWithConfig(string[] calldata name, address owner, bytes32 secret) external view returns (bytes32[] memory commitments);

    function commitment(bytes32 commit) external view returns (uint256);

}

File 5 of 52 : ISidPriceOracle.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

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

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

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

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

File 6 of 52 : IARBRegistrarControllerV3.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.4;

import "../price-oracle/ISidPriceOracle.sol";
import {ReferralInfo} from "../struct/SidStruct.sol";

interface IARBRegistrarControllerV3 {
    function rentPrice(string memory, uint256)
        external
        view
        returns (ISidPriceOracle.Price memory);

    function available(string memory) external returns (bool);

    function rentPrice(string memory, uint256, address)
        external
        view
        returns (ISidPriceOracle.Price memory);

    function makeCommitment(
        string memory,
        address,
        bytes32
    ) external pure returns (bytes32);

    function commit(bytes32) external;

    function registerWithConfig(
        string calldata,
        address,
        uint256,
        bytes32,
        address,
        bool
    ) external payable;

    function registerWithConfigAndPoint(
        string calldata,
        address,
        uint256,
        bytes32,
        address,
        bool,
        ReferralInfo memory
    ) external payable;

    function renew(string calldata, uint256) external payable;

    function renewWithPoint(string calldata, uint256, bool)
        external
        payable;
}

File 7 of 52 : BaseRegistrarImplementation.sol
pragma solidity >=0.8.4;

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

contract BaseRegistrarImplementation is ERC721, IBaseRegistrar, Ownable {
    // A map of expiry times
    mapping(uint256 => uint) expiries;
    // The arbid registry
    ARBID public arbid;
    // The namehash of the TLD this registrar owns (eg, .arb)
    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;
    uint256 supplyAmount = 0;  

    /**
     * v2.1.3 version of _isApprovedOrOwner which calls ownerOf(tokenId) and takes grace period into conarbideration 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(ARBID _arbid, bytes32 _baseNode) ERC721("SPACE ID .arb Name", "SIDARB ") {
        arbid = _arbid;
        baseNode = _baseNode;
    }

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

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

    function totalSupply() external view returns (uint256) {
        return supplyAmount;
    }
    
    function _mint(address _to, uint256 _tokenId) internal virtual override {
        super._mint(_to, _tokenId);
        supplyAmount = supplyAmount + 1;
    }

    function _burn(uint256 _tokenId) internal virtual override {
        super._burn(_tokenId);
        supplyAmount = supplyAmount - 1;
    }

    /**
     * @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);
        arbid.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);
        arbid.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 {
        arbid.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) {
            arbid.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 arbid, if you own it in the registrar.
     */
    function reclaim(uint256 id, address owner) external override live {
        require(_isApprovedOrOwner(msg.sender, id));
        arbid.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))) : "";
    }
}

File 8 of 52 : ReferralVerifier.sol
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;
    ReferralHub immutable referralHub;
    

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

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

    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(
            keccak256("Referral(address referrerAddress,bytes32 nodehash,uint256 referralCount,uint256 signedAt)"),
            referrerAddress,
            nodehash,
            referralCount,
            signedAt
        )));
    }

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

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

}

File 9 of 52 : ReferralHub.sol
// 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/ARBID.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;

    ARBID immutable arbid;

    constructor(ARBID _arbid) {
        arbid = _arbid;
        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 = arbid.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 = arbid.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);
    }
}

File 10 of 52 : StringUtils.sol
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;
    }
}

File 11 of 52 : SidGiftCardLedger.sol
// 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);
    }
}

File 12 of 52 : Resolver.sol
//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 setAddr(
        bytes32 node,
        uint256 coinType,
        address 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;
}

File 13 of 52 : 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;
    }
}

File 14 of 52 : Address.sol
// 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 15 of 52 : Ownable.sol
// 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);
    }
}

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

pragma solidity ^0.8.0;

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

File 17 of 52 : IBaseRegistrar.sol
import "../registry/ARBID.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;
}

File 18 of 52 : ARBID.sol
pragma solidity >=0.8.4;

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

File 20 of 52 : ERC721.sol
// 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 {}
}

File 21 of 52 : IERC721.sol
// 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;
}

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

pragma solidity ^0.8.0;

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

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

File 23 of 52 : 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);
}

File 24 of 52 : IERC721Metadata.sol
// 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);
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

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

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

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

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

File 27 of 52 : draft-EIP712.sol
// 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);
    }
}

File 28 of 52 : ECDSA.sol
// 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));
    }
}

File 29 of 52 : IReferralHub.sol
// 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;
}

File 30 of 52 : IReverseRegistrar.sol
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);
}

File 31 of 52 : AddrResolver.sol
// 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 {
    uint256 constant private COIN_TYPE_ARB1 = 2147525809;
    uint256 constant private COIN_TYPE_ARB_NOVA = 2147525809;


    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_ARB1, addressToBytes(a));
    }

    function setAddr(bytes32 node, uint coinType, address a) virtual external authorised(node) {
        setAddr(node, coinType, 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_ARB1);
        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);        
        _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)))
        }
    }
}

File 32 of 52 : NameResolver.sol
// 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 52 : IAddressResolver.sol
// 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 34 of 52 : 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 35 of 52 : 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);
}

File 36 of 52 : 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;
    }
}

File 37 of 52 : ISupportsInterface.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

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

File 38 of 52 : 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);
}

File 39 of 52 : SidGiftCardRegistrar.sol
// 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);
            }
        }
    }
}

File 40 of 52 : SidGiftCardVoucher.sol
// 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 = 500 * (10**18);
    uint256 public constant FOUR_DIGIT_VOUCHER_VALUE = 100 * (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;
    }
}

File 41 of 52 : ISidGiftCardRegistrar.sol
// 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;
}

File 42 of 52 : ERC1155.sol
// 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;
    }
}

File 43 of 52 : IERC1155.sol
// 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;
}

File 44 of 52 : IERC1155Receiver.sol
// 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);
}

File 45 of 52 : IERC1155MetadataURI.sol
// 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);
}

File 46 of 52 : IABIResolver.sol
// 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);
}

File 47 of 52 : IContentHashResolver.sol
// 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);
}

File 48 of 52 : IDNSRecordResolver.sol
// 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);
}

File 49 of 52 : IDNSZoneResolver.sol
// 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);
}

File 50 of 52 : IInterfaceResolver.sol
// 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);
}

File 51 of 52 : ITextResolver.sol
// 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);
}

File 52 of 52 : IPubkeyResolver.sol
// 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);
}

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

Contract ABI

[{"inputs":[{"internalType":"contract ARBRegistrarControllerV5","name":"_registrarController","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"bytes32[]","name":"commitments","type":"bytes32[]"}],"name":"bulkCommit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"name","type":"string[]"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"bytes32","name":"secret","type":"bytes32"}],"name":"bulkMakeCommitmentWithConfig","outputs":[{"internalType":"bytes32[]","name":"commitments","type":"bytes32[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string[]","name":"names","type":"string[]"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"bytes32","name":"secret","type":"bytes32"},{"internalType":"address","name":"resolver","type":"address"},{"internalType":"bool","name":"isUseGiftCard","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"}],"name":"bulkRentPrice","outputs":[{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"commit","type":"bytes32"}],"name":"commitment","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registrarController","outputs":[{"internalType":"contract ARBRegistrarControllerV5","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60a060405234801561001057600080fd5b5060405161114738038061114783398101604081905261002f91610040565b6001600160a01b0316608052610070565b60006020828403121561005257600080fd5b81516001600160a01b038116811461006957600080fd5b9392505050565b60805161108b6100bc60003960008181610135015281816101b40152818161027d01528181610340015281816105670152818161069101528181610727015261082d015261108b6000f3fe6080604052600436106100655760003560e01c8063bf31e53011610043578063bf31e530146100e3578063ceae4ad914610103578063f9cd32c51461012357600080fd5b80636c24945a1461006a578063744af1ca1461007f5780639fcb0985146100b5575b600080fd5b61007d610078366004610a04565b61017c565b005b34801561008b57600080fd5b5061009f61009a366004610b88565b610513565b6040516100ac9190610be4565b60405180910390f35b3480156100c157600080fd5b506100d56100d0366004610c28565b61065f565b6040519081526020016100ac565b3480156100ef57600080fd5b506100d56100fe366004610c41565b610717565b34801561010f57600080fd5b5061007d61011e366004610c8d565b610820565b34801561012f57600080fd5b506101577f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100ac565b6000805b88811015610440576101ac60405180606001604052806000815260200160008152602001600081525090565b841561027b577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166344d31f068c8c8581811061020057610200610ccf565b90506020028101906102129190610cfe565b8b8d6040518563ffffffff1660e01b81526004016102339493929190610dac565b606060405180830381865afa158015610250573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102749190610ded565b905061033e565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166383e7f6ff8c8c858181106102c9576102c9610ccf565b90506020028101906102db9190610cfe565b8b6040518463ffffffff1660e01b81526004016102fa93929190610e49565b606060405180830381865afa158015610317573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033b9190610ded565b90505b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d37095608260200151836000015161038e9190610e9c565b8d8d868181106103a0576103a0610ccf565b90506020028101906103b29190610cfe565b8d8d8d8d8d8d6040518a63ffffffff1660e01b81526004016103db989796959493929190610eb4565b6000604051808303818588803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b50505060208301518351909250610420915085610e9c565b61042a9190610e9c565b925050808061043890610faf565b915050610180565b5080341115610508576000336104568334610fe8565b604051600081818185875af1925050503d8060008114610492576040519150601f19603f3d011682016040523d82523d6000602084013e610497565b606091505b5050905080610506576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4661696c656420746f2073656e64204574686572000000000000000000000000604482015260640160405180910390fd5b505b505050505050505050565b60608367ffffffffffffffff81111561052e5761052e61095d565b604051908082528060200260200182016040528015610557578160200160208202803683370190505b50905060005b84811015610656577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f49826be8787848181106105b3576105b3610ccf565b90506020028101906105c59190610cfe565b87876040518563ffffffff1660e01b81526004016105e69493929190610fff565b602060405180830381865afa158015610603573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610627919061103c565b82828151811061063957610639610ccf565b60209081029190910101528061064e81610faf565b91505061055d565b50949350505050565b6040517f839df945000000000000000000000000000000000000000000000000000000008152600481018290526000907f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063839df94590602401602060405180830381865afa1580156106ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610711919061103c565b92915050565b6000805b838110156108185760007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166383e7f6ff87878581811061077357610773610ccf565b90506020028101906107859190610cfe565b876040518463ffffffff1660e01b81526004016107a493929190610e49565b606060405180830381865afa1580156107c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e59190610ded565b602081015181519192506107f891610e9c565b6108029084610e9c565b925050808061081090610faf565b91505061071b565b509392505050565b60005b818110156108e3577f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663f14fcbc884848481811061087957610879610ccf565b905060200201356040518263ffffffff1660e01b815260040161089e91815260200190565b600060405180830381600087803b1580156108b857600080fd5b505af11580156108cc573d6000803e3d6000fd5b5050505080806108db90610faf565b915050610823565b505050565b60008083601f8401126108fa57600080fd5b50813567ffffffffffffffff81111561091257600080fd5b6020830191508360208260051b850101111561092d57600080fd5b9250929050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461095857600080fd5b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160a0810167ffffffffffffffff811182821017156109af576109af61095d565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156109fc576109fc61095d565b604052919050565b60008060008060008060008060e0898b031215610a2057600080fd5b883567ffffffffffffffff80821115610a3857600080fd5b610a448c838d016108e8565b909a50985060209150610a588b8301610934565b975060408b0135965060608b01359550610a7460808c01610934565b945060a08b01358015158114610a8957600080fd5b935060c08b013581811115610a9d57600080fd5b8b0160a0818e031215610aaf57600080fd5b610ab761098c565b610ac082610934565b815283820135848201526040820135604082015260608201356060820152608082013583811115610af057600080fd5b8083019250508d601f830112610b0557600080fd5b813583811115610b1757610b1761095d565b610b47857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016109b5565b93508084528e85828501011115610b5d57600080fd5b8085840186860137600085828601015250826080820152809450505050509295985092959890939650565b60008060008060608587031215610b9e57600080fd5b843567ffffffffffffffff811115610bb557600080fd5b610bc1878288016108e8565b9095509350610bd4905060208601610934565b9396929550929360400135925050565b6020808252825182820181905260009190848201906040850190845b81811015610c1c57835183529284019291840191600101610c00565b50909695505050505050565b600060208284031215610c3a57600080fd5b5035919050565b600080600060408486031215610c5657600080fd5b833567ffffffffffffffff811115610c6d57600080fd5b610c79868287016108e8565b909790965060209590950135949350505050565b60008060208385031215610ca057600080fd5b823567ffffffffffffffff811115610cb757600080fd5b610cc3858286016108e8565b90969095509350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610d3357600080fd5b83018035915067ffffffffffffffff821115610d4e57600080fd5b60200191503681900382131561092d57600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b606081526000610dc0606083018688610d63565b905083602083015273ffffffffffffffffffffffffffffffffffffffff8316604083015295945050505050565b600060608284031215610dff57600080fd5b6040516060810181811067ffffffffffffffff82111715610e2257610e2261095d565b80604052508251815260208301516020820152604083015160408201528091505092915050565b604081526000610e5d604083018587610d63565b9050826020830152949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115610eaf57610eaf610e6d565b500190565b60e081526000610ec860e083018a8c610d63565b602073ffffffffffffffffffffffffffffffffffffffff808b1682860152896040860152886060860152808816608086015286151560a086015260c085840381870152818751168452828701518385015260408701516040850152606087015160608501526080870151915060a0608085015281518060a086015260005b81811015610f61578381018501518682018401528401610f46565b81811115610f725760008383880101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016939093019092019c9b505050505050505050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610fe157610fe1610e6d565b5060010190565b600082821015610ffa57610ffa610e6d565b500390565b606081526000611013606083018688610d63565b73ffffffffffffffffffffffffffffffffffffffff949094166020830152506040015292915050565b60006020828403121561104e57600080fd5b505191905056fea264697066735822122080ffeeee97a2e2cbaf6f2f54482ea96019ddd9eac2c36220660bd8e987beb17c64736f6c634300080c0033000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce618

Deployed Bytecode

0x6080604052600436106100655760003560e01c8063bf31e53011610043578063bf31e530146100e3578063ceae4ad914610103578063f9cd32c51461012357600080fd5b80636c24945a1461006a578063744af1ca1461007f5780639fcb0985146100b5575b600080fd5b61007d610078366004610a04565b61017c565b005b34801561008b57600080fd5b5061009f61009a366004610b88565b610513565b6040516100ac9190610be4565b60405180910390f35b3480156100c157600080fd5b506100d56100d0366004610c28565b61065f565b6040519081526020016100ac565b3480156100ef57600080fd5b506100d56100fe366004610c41565b610717565b34801561010f57600080fd5b5061007d61011e366004610c8d565b610820565b34801561012f57600080fd5b506101577f000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce61881565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100ac565b6000805b88811015610440576101ac60405180606001604052806000815260200160008152602001600081525090565b841561027b577f000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce61873ffffffffffffffffffffffffffffffffffffffff166344d31f068c8c8581811061020057610200610ccf565b90506020028101906102129190610cfe565b8b8d6040518563ffffffff1660e01b81526004016102339493929190610dac565b606060405180830381865afa158015610250573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102749190610ded565b905061033e565b7f000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce61873ffffffffffffffffffffffffffffffffffffffff166383e7f6ff8c8c858181106102c9576102c9610ccf565b90506020028101906102db9190610cfe565b8b6040518463ffffffff1660e01b81526004016102fa93929190610e49565b606060405180830381865afa158015610317573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061033b9190610ded565b90505b7f000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce61873ffffffffffffffffffffffffffffffffffffffff1663d37095608260200151836000015161038e9190610e9c565b8d8d868181106103a0576103a0610ccf565b90506020028101906103b29190610cfe565b8d8d8d8d8d8d6040518a63ffffffff1660e01b81526004016103db989796959493929190610eb4565b6000604051808303818588803b1580156103f457600080fd5b505af1158015610408573d6000803e3d6000fd5b50505060208301518351909250610420915085610e9c565b61042a9190610e9c565b925050808061043890610faf565b915050610180565b5080341115610508576000336104568334610fe8565b604051600081818185875af1925050503d8060008114610492576040519150601f19603f3d011682016040523d82523d6000602084013e610497565b606091505b5050905080610506576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4661696c656420746f2073656e64204574686572000000000000000000000000604482015260640160405180910390fd5b505b505050505050505050565b60608367ffffffffffffffff81111561052e5761052e61095d565b604051908082528060200260200182016040528015610557578160200160208202803683370190505b50905060005b84811015610656577f000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce61873ffffffffffffffffffffffffffffffffffffffff1663f49826be8787848181106105b3576105b3610ccf565b90506020028101906105c59190610cfe565b87876040518563ffffffff1660e01b81526004016105e69493929190610fff565b602060405180830381865afa158015610603573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610627919061103c565b82828151811061063957610639610ccf565b60209081029190910101528061064e81610faf565b91505061055d565b50949350505050565b6040517f839df945000000000000000000000000000000000000000000000000000000008152600481018290526000907f000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce61873ffffffffffffffffffffffffffffffffffffffff169063839df94590602401602060405180830381865afa1580156106ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610711919061103c565b92915050565b6000805b838110156108185760007f000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce61873ffffffffffffffffffffffffffffffffffffffff166383e7f6ff87878581811061077357610773610ccf565b90506020028101906107859190610cfe565b876040518463ffffffff1660e01b81526004016107a493929190610e49565b606060405180830381865afa1580156107c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107e59190610ded565b602081015181519192506107f891610e9c565b6108029084610e9c565b925050808061081090610faf565b91505061071b565b509392505050565b60005b818110156108e3577f000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce61873ffffffffffffffffffffffffffffffffffffffff1663f14fcbc884848481811061087957610879610ccf565b905060200201356040518263ffffffff1660e01b815260040161089e91815260200190565b600060405180830381600087803b1580156108b857600080fd5b505af11580156108cc573d6000803e3d6000fd5b5050505080806108db90610faf565b915050610823565b505050565b60008083601f8401126108fa57600080fd5b50813567ffffffffffffffff81111561091257600080fd5b6020830191508360208260051b850101111561092d57600080fd5b9250929050565b803573ffffffffffffffffffffffffffffffffffffffff8116811461095857600080fd5b919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160a0810167ffffffffffffffff811182821017156109af576109af61095d565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156109fc576109fc61095d565b604052919050565b60008060008060008060008060e0898b031215610a2057600080fd5b883567ffffffffffffffff80821115610a3857600080fd5b610a448c838d016108e8565b909a50985060209150610a588b8301610934565b975060408b0135965060608b01359550610a7460808c01610934565b945060a08b01358015158114610a8957600080fd5b935060c08b013581811115610a9d57600080fd5b8b0160a0818e031215610aaf57600080fd5b610ab761098c565b610ac082610934565b815283820135848201526040820135604082015260608201356060820152608082013583811115610af057600080fd5b8083019250508d601f830112610b0557600080fd5b813583811115610b1757610b1761095d565b610b47857fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016109b5565b93508084528e85828501011115610b5d57600080fd5b8085840186860137600085828601015250826080820152809450505050509295985092959890939650565b60008060008060608587031215610b9e57600080fd5b843567ffffffffffffffff811115610bb557600080fd5b610bc1878288016108e8565b9095509350610bd4905060208601610934565b9396929550929360400135925050565b6020808252825182820181905260009190848201906040850190845b81811015610c1c57835183529284019291840191600101610c00565b50909695505050505050565b600060208284031215610c3a57600080fd5b5035919050565b600080600060408486031215610c5657600080fd5b833567ffffffffffffffff811115610c6d57600080fd5b610c79868287016108e8565b909790965060209590950135949350505050565b60008060208385031215610ca057600080fd5b823567ffffffffffffffff811115610cb757600080fd5b610cc3858286016108e8565b90969095509350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610d3357600080fd5b83018035915067ffffffffffffffff821115610d4e57600080fd5b60200191503681900382131561092d57600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b606081526000610dc0606083018688610d63565b905083602083015273ffffffffffffffffffffffffffffffffffffffff8316604083015295945050505050565b600060608284031215610dff57600080fd5b6040516060810181811067ffffffffffffffff82111715610e2257610e2261095d565b80604052508251815260208301516020820152604083015160408201528091505092915050565b604081526000610e5d604083018587610d63565b9050826020830152949350505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60008219821115610eaf57610eaf610e6d565b500190565b60e081526000610ec860e083018a8c610d63565b602073ffffffffffffffffffffffffffffffffffffffff808b1682860152896040860152886060860152808816608086015286151560a086015260c085840381870152818751168452828701518385015260408701516040850152606087015160608501526080870151915060a0608085015281518060a086015260005b81811015610f61578381018501518682018401528401610f46565b81811115610f725760008383880101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016939093019092019c9b505050505050505050505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415610fe157610fe1610e6d565b5060010190565b600082821015610ffa57610ffa610e6d565b500390565b606081526000611013606083018688610d63565b73ffffffffffffffffffffffffffffffffffffffff949094166020830152506040015292915050565b60006020828403121561104e57600080fd5b505191905056fea264697066735822122080ffeeee97a2e2cbaf6f2f54482ea96019ddd9eac2c36220660bd8e987beb17c64736f6c634300080c0033

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

000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce618

-----Decoded View---------------
Arg [0] : _registrarController (address): 0xB7dA95Ec908Cba7587b2243CA45D5A2Fa92cE618

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000b7da95ec908cba7587b2243ca45d5a2fa92ce618


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