Contract 0xa7a9a8156c24c4b0ca910c3ba842d1f1ac7200ef 1

 

Contract Overview

Faraland: KNIGHT Token
Balance:
1,528.2814267428222998 BNB

BNB Value:
$520,960.57 (@ $340.88/BNB)

Token:
Txn Hash
Block
From
To
Value [Txn Fee]
0x7f810742a892737db44846f3f42bc45945335524e0044debbff67c94708f4cd896689202021-08-01 21:42:241 min ago0xe3b8612ca85ab1b847de18980bc3c01e0645e41c IN  Faraland: KNIGHT Token0 BNB0.00012034
0xc4e77c988e7b27dfef29f50913a0c4d000a224cb6113a2d30e8271e5aa97b0ec96689182021-08-01 21:42:181 min ago0xa2b25d0ce872b0bc48becca0291520e5c04d3529 IN  Faraland: KNIGHT Token0 BNB0.000427435
0x5ea3732c22c2e16be1794b9d9b3b7aa77783165598840b486c2cd806627da4c496689042021-08-01 21:41:362 mins ago0xa2b25d0ce872b0bc48becca0291520e5c04d3529 IN  Faraland: KNIGHT Token0 BNB0.000174275
0xf964d10ec376c395a154ab9954ab35b237c3bb1f586ed6cac03c982a900a324296688542021-08-01 21:39:065 mins ago0xf5a02a167a6d00481a0bf5b25b21db7989ef939b IN  Faraland: KNIGHT Token0 BNB0.00015497
0x989757f5af5f66a9f2d06594f3484b64b8f84fdfb0bd790d0d0370a115a4659c96688492021-08-01 21:38:515 mins ago0x7ca3bf04064638ae8dbda800b7022842defe7efa IN  Faraland: KNIGHT Token1 BNB0.00042501
0x9934d0536357ac34d73bd1f0d46be0a8e45f93c2b45516928e53a86cd07f653296688452021-08-01 21:38:395 mins ago0xa2b25d0ce872b0bc48becca0291520e5c04d3529 IN  Faraland: KNIGHT Token0 BNB0.000253395
0x9680c70cd14ca6ac40baf7e2ccc8ed2da39f0b809bb5dae3f61093fef642af6296688352021-08-01 21:38:096 mins ago0x0f551f367adb8bb1e3d79f580e5c00d7247a06ef IN  Faraland: KNIGHT Token0.7 BNB0.00024128
0x0662481d889e01f6cdf8be5a57579cf53b2bd0676c17eda42e891ad747995b7196687882021-08-01 21:35:488 mins ago0x2de6f905a3bbbc8581d3305c20a9768799783fab IN  Faraland: KNIGHT Token0 BNB0.00012034
0x641d82bb2008b3ffb1d046c81afbbbd0cae5b90b4ebbb288b544fbedc435e3ec96687652021-08-01 21:34:399 mins ago0x8798333fbf79c1d401514b775ced8b345f6a5337 IN  Faraland: KNIGHT Token0 BNB0.00022997
0x7fa892ce2d63fc6bc0cad672e40427f73861ff3c7fcd0f9584fc7998b68e022d96686712021-08-01 21:29:3814 mins ago0xc71c722f9853b8da1b1149947538f1ad8c18b7f8 IN  Faraland: KNIGHT Token0 BNB0.00015497
0x3a3829ba99ae5330f1bcce63e95e3fbeb832aee9705b380d3a549341ab0bdfb396686552021-08-01 21:28:4015 mins ago0xc71c722f9853b8da1b1149947538f1ad8c18b7f8 IN  Faraland: KNIGHT Token0 BNB0.00015497
0x6dff724b396e5a2b79e25805acd9757a01091cd8070fe9111e888fa463982a6f96686442021-08-01 21:28:0516 mins ago0xc71c722f9853b8da1b1149947538f1ad8c18b7f8 IN  Faraland: KNIGHT Token0 BNB0.00015497
0xa7b83ce571e5e61c7d3bc095a32d61ba675d0a4a469d55a47ccb4f3a9651db5396686372021-08-01 21:27:3516 mins ago0xc2b333e6aa1f76795604be85077b4d1699fe5ef4 IN  Faraland: KNIGHT Token0.92 BNB0.00024128
0xddd4a5d2a8d3e306b289518e58667b73256dc58bd6dd653cf842541ff6cbccbb96686282021-08-01 21:27:0617 mins ago0xc2b333e6aa1f76795604be85077b4d1699fe5ef4 IN  Faraland: KNIGHT Token0 BNB0.00012034
0xed1a08fd408586f03525fdeda2b8e961fa8c828b92e6f78f90b8b82c12afff7096686132021-08-01 21:26:1517 mins ago0xd0ea5844385f5907532f7fbacb6460fd358c570c IN  Faraland: KNIGHT Token0.5 BNB0.00016628
0xbd89819af4839e3e47a6dd150b3c351cb33f3a82ebca87ac2d2cc79b83f634e596686132021-08-01 21:26:1517 mins ago0xf5a02a167a6d00481a0bf5b25b21db7989ef939b IN  Faraland: KNIGHT Token0 BNB0.00015503
0xb99b54b8459e7855683c1b9a5b88ee198855fc5c41807f63a4f7b59e97f4d6a096685932021-08-01 21:25:1119 mins ago0xd0ea5844385f5907532f7fbacb6460fd358c570c IN  Faraland: KNIGHT Token3 BNB0.00024128
0x7dd3e47a954a8ead14cb7a69a315c92bff366d3f2642204ca056205ad39c73f496685922021-08-01 21:25:0819 mins ago0x0e2736214fdc16dc49b264fe17eb62d22404b7c0 IN  Faraland: KNIGHT Token0 BNB0.00012034
0x56665dcd3190a3e503fc1446db6e44342cc90362d815c8aa5333d16fae448c9896685622021-08-01 21:23:2820 mins ago0xe3b8612ca85ab1b847de18980bc3c01e0645e41c IN  Faraland: KNIGHT Token6 BNB0.00024128
0xae0523c82779cf6b64f2c06be1c831dc0963f45e91b78fe904b548237fa0a8ff96685132021-08-01 21:20:4723 mins ago0x0e2736214fdc16dc49b264fe17eb62d22404b7c0 IN  Faraland: KNIGHT Token0.5 BNB0.00024128
0xff488e7a8080b32ea45165f03525d7193e7c3a7d0e29f862b6cc8af1bb113bdf96685002021-08-01 21:20:0624 mins ago0xd0ea5844385f5907532f7fbacb6460fd358c570c IN  Faraland: KNIGHT Token0.3 BNB0.00016628
0x9f7f886eeed31772df0c99af6e17cc7e79e6b4eb6f98e2db649de0af6602327796684862021-08-01 21:19:2224 mins ago0xd0ea5844385f5907532f7fbacb6460fd358c570c IN  Faraland: KNIGHT Token0 BNB0.00012034
0x363135c4f2dbd80fdaf5675595e17dd17df5ba364957c60afd8ee6ffc34fd76c96684542021-08-01 21:17:3126 mins ago0xd0ea5844385f5907532f7fbacb6460fd358c570c IN  Faraland: KNIGHT Token2.5 BNB0.00024128
0xa2f60af18b9b65b9c8fa21194ba946d9ba07c38c408050ff557acb03c9a8aace96684522021-08-01 21:17:2526 mins ago0xf5a02a167a6d00481a0bf5b25b21db7989ef939b IN  Faraland: KNIGHT Token0 BNB0.00015497
0xa079a2488498df2cb51cdeb38a436ca64baf286ce1c10090b5f018f2b8214bb396684432021-08-01 21:16:5027 mins ago0xc3156068e552c52eb8086fe2608435f784670aa4 IN  Faraland: KNIGHT Token0 BNB0.00012034
[ Download CSV Export 

OVERVIEW

Faraland is an NFT project aiming to achieve true play to earn term. Users can use their hero in many unique ways from equipping them with powerful weapons or shining armors to recruiting troop and raising pet. All of them is in the form of NFT.

Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x7f810742a892737db44846f3f42bc45945335524e0044debbff67c94708f4cd896689202021-08-01 21:42:241 min ago Faraland: KNIGHT Token0xe3b8612ca85ab1b847de18980bc3c01e0645e41c6 BNB
0x989757f5af5f66a9f2d06594f3484b64b8f84fdfb0bd790d0d0370a115a4659c96688492021-08-01 21:38:515 mins ago Faraland: KNIGHT TokenFaraland: Deployer0.02 BNB
0x989757f5af5f66a9f2d06594f3484b64b8f84fdfb0bd790d0d0370a115a4659c96688492021-08-01 21:38:515 mins ago Faraland: KNIGHT Token0xf023bb523943cdab604ff49f7f73a7c67078dede0.9778 BNB
0x0662481d889e01f6cdf8be5a57579cf53b2bd0676c17eda42e891ad747995b7196687882021-08-01 21:35:488 mins ago Faraland: KNIGHT Token0x2de6f905a3bbbc8581d3305c20a9768799783fab0.2 BNB
0xddd4a5d2a8d3e306b289518e58667b73256dc58bd6dd653cf842541ff6cbccbb96686282021-08-01 21:27:0617 mins ago Faraland: KNIGHT Token0xc2b333e6aa1f76795604be85077b4d1699fe5ef40.79 BNB
0x7dd3e47a954a8ead14cb7a69a315c92bff366d3f2642204ca056205ad39c73f496685922021-08-01 21:25:0819 mins ago Faraland: KNIGHT Token0x0e2736214fdc16dc49b264fe17eb62d22404b7c00.5 BNB
0x9f7f886eeed31772df0c99af6e17cc7e79e6b4eb6f98e2db649de0af6602327796684862021-08-01 21:19:2224 mins ago Faraland: KNIGHT Token0xd0ea5844385f5907532f7fbacb6460fd358c570c5 BNB
0xa079a2488498df2cb51cdeb38a436ca64baf286ce1c10090b5f018f2b8214bb396684432021-08-01 21:16:5027 mins ago Faraland: KNIGHT Token0xc3156068e552c52eb8086fe2608435f784670aa40.1 BNB
0x9e4f76709dfed519dc0f7fc29f468cbf65ab7315d81f7b3c8dfd06444df8596696684312021-08-01 21:16:1328 mins ago Faraland: KNIGHT Token0xd0ea5844385f5907532f7fbacb6460fd358c570c2.6 BNB
0x3a7fecc5aa35746c526fe8dbddf8b2767442cd91c534e4d0b139815426109f4896683652021-08-01 21:12:4031 mins ago Faraland: KNIGHT TokenFaraland: Deployer0.02 BNB
0x3a7fecc5aa35746c526fe8dbddf8b2767442cd91c534e4d0b139815426109f4896683652021-08-01 21:12:4031 mins ago Faraland: KNIGHT Token0x3700933de66554a4c31c32b92d7e1db206637a340.9778 BNB
0x45f215bb988a149a7394a7fb8eaf2c6a32b0046bc8be6e208ca98a7f63c4e53796681682021-08-01 21:02:2841 mins ago Faraland: KNIGHT TokenFaraland: Deployer0.0184 BNB
0x45f215bb988a149a7394a7fb8eaf2c6a32b0046bc8be6e208ca98a7f63c4e53796681682021-08-01 21:02:2841 mins ago Faraland: KNIGHT Token0xc53a9d4a73ed7327e55445341e298abccca132580.899576 BNB
0x95bcceb26ee3072cf0dceb76ac16a82ec6b3525b74be3ba4bc0a6d749594913e96680282021-08-01 20:55:2848 mins ago Faraland: KNIGHT TokenFaraland: Deployer0.02 BNB
0x95bcceb26ee3072cf0dceb76ac16a82ec6b3525b74be3ba4bc0a6d749594913e96680282021-08-01 20:55:2848 mins ago Faraland: KNIGHT Token0x011752d712d2191b86d627d0b8710df877b4fc150.9778 BNB
0xce4b33f58802889b352356e1b82b77be734ee4013738e893bbf46343ffa99ab496679592021-08-01 20:52:0152 mins ago Faraland: KNIGHT Token0x0c74dd41d42d7938d46b30f004b83cea0f306e250.7 BNB
0xaa167aef5d481335d8b61da5b9d14fc8be053683efdbaedfa4d128dce8bd627a96679512021-08-01 20:51:3752 mins ago Faraland: KNIGHT Token0x0c74dd41d42d7938d46b30f004b83cea0f306e251.05 BNB
0xbfe0be740e8975aaa4576cf68c9d33448bb856f64ede41b919a03aac06e0054596679482021-08-01 20:51:2852 mins ago Faraland: KNIGHT Token0x53f28c99aef9c1d9852b70a9abc8b988fb9b464145 BNB
0xe16092f47b0f04086a1aebe8de910ca73a8780bc7a9a6f4d891ed9e7efc6cbe596678942021-08-01 20:48:4655 mins ago Faraland: KNIGHT TokenFaraland: Deployer0.4 BNB
0xe16092f47b0f04086a1aebe8de910ca73a8780bc7a9a6f4d891ed9e7efc6cbe596678942021-08-01 20:48:4655 mins ago Faraland: KNIGHT Token0x8919da7422a94f393e5b7d26f1c5b5a305631b3619.556 BNB
0x0897e6deb358b60ab6a6efa7fc0c4e2b002a045dfe5382ba53898a16ad80f8a896677942021-08-01 20:43:461 hr ago Faraland: KNIGHT Token0x6976e36cd9e24c0bbc26ae95702b735186aa0be80.051 BNB
0x4d8fbbef40598dd574afa1d80fdcadb5eb987604df35b18bf9347694a6c0f32796677772021-08-01 20:42:551 hr 1 min ago Faraland: KNIGHT Token0x7b76feecab353a68bf59e56558c6e3aef15173630.6 BNB
0x7e96a49be0ded68b0e1feedcbd33216485f1cbd862dfaead447db2c9a85cf02d96676952021-08-01 20:38:491 hr 5 mins ago Faraland: KNIGHT TokenFaraland: Deployer0.0334 BNB
0x7e96a49be0ded68b0e1feedcbd33216485f1cbd862dfaead447db2c9a85cf02d96676952021-08-01 20:38:491 hr 5 mins ago Faraland: KNIGHT Token0xe3b8612ca85ab1b847de18980bc3c01e0645e41c1.632926 BNB
0x144eb6a29046b1cd44d6525c0323e17e4149203d7a0f73f740fa79fa2e9e08c896674952021-08-01 20:28:431 hr 15 mins ago Faraland: KNIGHT Token0xe85c0e4211e26c42cf23b99bab32444070a28b141.5 BNB
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MoonKnight

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 322 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 21 : MoonKnight.sol
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "../interfaces/IMoonKnight.sol";
import "../interfaces/IEquipment.sol";
import "../interfaces/IPet.sol";
import "../utils/AcceptedToken.sol";

contract MoonKnight is IMoonKnight, ERC721, AcceptedToken, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using EnumerableSet for EnumerableSet.UintSet;

    uint private constant BPS = 10000;

    IEquipment public equipmentContract;
    IPet public petContract;

    uint public floorPriceInBps = 200;
    uint public marketFeeInBps = 22;
    uint public serviceFeeInToken = 1e20;
    uint public maxLevel = 100;
    string private _uri;

    Version[] public versions;
    mapping(uint => uint) public knightsOnSale;
    mapping(uint => mapping(address => uint)) public knightsWithOffers;
    mapping(string => bool) public reservedNames;

    Knight[] private _knights;
    mapping(uint => uint) private _knightsWithPet;
    mapping(uint => EnumerableSet.UintSet) private _knightSkills;

    constructor(
        IEquipment equipmentAddress,
        IERC20 tokenAddress,
        string memory baseURI,
        uint maxSupply,
        uint salePrice,
        uint startTime,
        uint revealTime,
        string memory provenance
    ) ERC721("MoonKnight", "KNIGHT") AcceptedToken(tokenAddress) {
        equipmentContract = equipmentAddress;
        _uri = baseURI;
        versions.push(Version(0, 0, maxSupply, salePrice, startTime, revealTime, provenance));
    }

    modifier onlyKnightOwner(uint knightId) {
        require(ownerOf(knightId) == msg.sender, "MoonKnight: not knight owner");
        _;
    }

    function setEquipmentContract(IEquipment equipmentAddress) external onlyOwner {
        require(address(equipmentAddress) != address(0));
        equipmentContract = equipmentAddress;
    }

    function setPetContract(IPet petAddress) external onlyOwner {
        require(address(petAddress) != address(0));
        petContract = petAddress;
    }

    function setFloorPriceAndMarketFeeInBps(uint floorPrice, uint marketFee) external onlyOwner {
        require(floorPrice + marketFee <= BPS);
        floorPriceInBps = floorPrice;
        marketFeeInBps = marketFee;
    }

    function setServiceFee(uint value) external onlyOwner {
        serviceFeeInToken = value;
    }

    function setMaxLevel(uint newMaxLevel) external onlyOwner {
        require(newMaxLevel > maxLevel);
        maxLevel = newMaxLevel;
    }

    function setBaseURI(string memory baseURI) external onlyOwner {
        _uri = baseURI;
    }

    function addNewVersion(
        uint maxSupply,
        uint salePrice,
        uint startTime,
        uint revealTime,
        string memory provenance
    ) external onlyOwner {
        uint latestVersionId = getLatestVersion();
        Version memory latestVersion = versions[latestVersionId];

        require(latestVersion.currentSupply == latestVersion.maxSupply);

        versions.push(Version(0, 0, maxSupply, salePrice, startTime, revealTime, provenance));
        emit NewVersionAdded(latestVersionId + 1);
    }

    function claimMoonKnight(uint versionId, uint amount) external override payable {
        Version storage version = versions[versionId];
        uint floorPrice = version.salePrice * 1000 / BPS;

        require(amount > 0 && amount <= 50, "MoonKnight: amount out of range");
        require(block.timestamp >= version.startTime, "MoonKnight: Sale has not started");
        require(version.currentSupply + amount <= version.maxSupply, "MoonKnight: sold out");
        require(msg.value == version.salePrice * amount, "MoonKnight: incorrect value");

        for (uint i = 0; i < amount; i++) {
            uint knightId = _createKnight(floorPrice);
            _safeMint(msg.sender, knightId);
        }

        version.currentSupply += amount;

        (bool isSuccess,) = owner().call{value: msg.value - (floorPrice * amount)}("");
        require(isSuccess);

        if (version.startingIndex == 0 && (version.currentSupply == version.maxSupply || block.timestamp >= version.revealTime)) {
            _finalizeStartingIndex(versionId, version);
        }
    }

    function changeKnightName(
        uint knightId,
        string memory newName
    ) external override onlyKnightOwner(knightId) collectTokenAsFee(serviceFeeInToken, owner()) {
        require(_validateStr(newName), "MoonKnight: invalid name");
        require(reservedNames[newName] == false, "MoonKnight: name already exists");

        Knight storage knight = _knights[knightId];

        // If already named, de-reserve current name
        if (bytes(knight.name).length > 0) {
            reservedNames[knight.name] = false;
        }

        knight.name = newName;
        reservedNames[newName] = true;

        emit NameChanged(knightId, newName);
    }

    function equipItems(uint knightId, uint[] memory itemIds) external override onlyKnightOwner(knightId) {
        _setKnightEquipment(knightId, itemIds, false);

        equipmentContract.putItemsIntoStorage(msg.sender, itemIds);

        emit ItemsEquipped(knightId, itemIds);
    }

    function removeItems(uint knightId, uint[] memory itemIds) external override onlyKnightOwner(knightId) {
        _setKnightEquipment(knightId, itemIds, true);

        equipmentContract.returnItems(msg.sender, itemIds);

        emit ItemsUnequipped(knightId, itemIds);
    }

    function addFloorPriceToKnight(uint knightId) external override payable {
        Knight storage knight = _knights[knightId];
        uint newFloorPrice = knight.floorPrice + msg.value;

        require(msg.value > 0, "MoonKnight: no value sent");
        require(newFloorPrice <= 100 ether, "MoonKnight: cannot add more");
        require(acceptedToken.balanceOf(msg.sender) >= serviceFeeInToken, "MoonKnight: insufficient token balance");

        knight.floorPrice = newFloorPrice;
        acceptedToken.safeTransferFrom(msg.sender, owner(), serviceFeeInToken);

        emit KnightPriceIncreased(knightId, newFloorPrice, serviceFeeInToken);
    }

    function sacrificeKnight(uint knightId) external override nonReentrant onlyKnightOwner(knightId) {
        Knight storage knight = _knights[knightId];
        uint amount = knight.floorPrice;

        knight.floorPrice = 0;
        _burn(knightId);

        (bool isSuccess,) = msg.sender.call{value: amount}("");
        require(isSuccess);
    }

    function list(uint knightId, uint price) external override onlyKnightOwner(knightId) {
        require(price >= _knights[knightId].floorPrice, "MoonKnight: under floor price");

        knightsOnSale[knightId] = price;

        emit KnightListed(knightId, price);
    }

    function delist(uint knightId) external override onlyKnightOwner(knightId) {
        require(knightsOnSale[knightId] > 0, "MoonKnight: not listed");

        knightsOnSale[knightId] = 0;

        emit KnightDelisted(knightId);
    }

    function buy(uint knightId) external override payable nonReentrant {
        uint price = knightsOnSale[knightId];
        address seller = ownerOf(knightId);
        address buyer = msg.sender;

        require(price > 0, "MoonKnight: not on sale");
        require(msg.value == price, "MoonKnight: incorrect value");
        require(buyer != seller, "MoonKnight: cannot buy your own Knight");

        _makeTransaction(knightId, buyer, seller, price);

        emit KnightBought(knightId, buyer, seller, price);
    }

    function offer(uint knightId, uint offerValue) external override nonReentrant payable {
        address buyer = msg.sender;
        uint currentOffer = knightsWithOffers[knightId][buyer];
        bool needRefund = offerValue < currentOffer;
        uint requiredValue = needRefund ? 0 : offerValue - currentOffer;

        require(buyer != ownerOf(knightId), "MoonKnight: owner cannot offer");
        require(offerValue != currentOffer, "MoonKnight: same offer");
        require(msg.value == requiredValue, "MoonKnight: sent value incorrect");

        knightsWithOffers[knightId][buyer] = offerValue;

        if (needRefund) {
            uint returnedValue = currentOffer - offerValue;

            (bool success,) = buyer.call{value: returnedValue}("");
            require(success);
        }

        emit KnightOffered(knightId, buyer, offerValue);
    }

    function takeOffer(
        uint knightId,
        address buyer,
        uint minPrice
    ) external override nonReentrant onlyKnightOwner(knightId) {
        uint offeredValue = knightsWithOffers[knightId][buyer];
        address seller = msg.sender;

        require(offeredValue >= _knights[knightId].floorPrice, "MoonKnight: under floor price");
        require(offeredValue >= minPrice, "MoonKnight: less than min price");
        require(buyer != seller, "MoonKnight: cannot buy your own Knight");

        knightsWithOffers[knightId][buyer] = 0;

        _makeTransaction(knightId, buyer, seller, offeredValue);

        emit KnightBought(knightId, buyer, seller, offeredValue);
    }

    function cancelOffer(uint knightId) external override nonReentrant {
        address sender = msg.sender;
        uint offerValue = knightsWithOffers[knightId][sender];

        require(offerValue > 0, "MoonKnight: no offer found");

        knightsWithOffers[knightId][sender] = 0;

        (bool success,) = sender.call{value: offerValue}("");
        require(success);

        emit KnightOfferCanceled(knightId, sender);
    }

    function learnSkill(uint knightId, uint skillId) external override onlyKnightOwner(knightId) {
        IEquipment.ItemType itemType = equipmentContract.getItemType(skillId);
        EnumerableSet.UintSet storage skills = _knightSkills[knightId];

        require(itemType == IEquipment.ItemType.SKILL_BOOK, "MoonKnight: invalid skill book");

        bool isSuccess = skills.add(skillId);
        if (!isSuccess) revert("MoonKnight: already learned");

        uint[] memory skillIds = new uint[](1);
        skillIds[0] = skillId;
        equipmentContract.putItemsIntoStorage(msg.sender, skillIds);

        emit SkillLearned(knightId, skillId);
    }

    function adoptPet(uint knightId, uint petId) external override onlyKnightOwner(knightId) {
        require(petContract.ownerOf(petId) == msg.sender, "MoonKnight: not pet owner");

        _knightsWithPet[knightId] = petId;
        petContract.bindPet(petId);

        emit PetAdopted(knightId, petId);
    }

    function abandonPet(uint knightId) external override onlyKnightOwner(knightId) {
        uint petId = _knightsWithPet[knightId];

        require(petId != 0, "MoonKnight: no pet");

        _knightsWithPet[knightId] = 0;
        petContract.releasePet(petId);

        emit PetReleased(knightId, petId);
    }

    function levelUp(uint knightId, uint amount) external override onlyOperator {
        Knight storage knight = _knights[knightId];
        uint newLevel = knight.level + amount;

        require(amount > 0);
        require(newLevel <= maxLevel, "MoonKnight: max level reached");

        knight.level = newLevel;

        emit KnightLeveledUp(knightId, newLevel, amount);
    }

    function finalizeDuelResult(
        uint winningKnightId,
        uint losingKnightId,
        uint penaltyInBps
    ) external override onlyOperator {
        require(penaltyInBps <= BPS);

        Knight storage winningKnight = _knights[winningKnightId];
        Knight storage losingKnight = _knights[losingKnightId];
        uint baseFloorPrice = winningKnight.floorPrice > losingKnight.floorPrice ? losingKnight.floorPrice : winningKnight.floorPrice;

        uint penaltyAmount = baseFloorPrice * penaltyInBps / BPS;

        winningKnight.floorPrice += penaltyAmount;
        losingKnight.floorPrice -= penaltyAmount;

        emit DuelConcluded(winningKnightId, losingKnightId, penaltyAmount);
    }

    function getKnight(uint knightId) external view override returns (
        string memory name,
        uint level,
        uint floorPrice,
        uint pet,
        uint[] memory skills,
        uint[9] memory equipment
    ) {
        Knight memory knight = _knights[knightId];

        uint skillCount = _knightSkills[knightId].length();
        uint[] memory skillIds = new uint[](skillCount);
        for (uint i = 0; i < skillCount; i++) {
            skillIds[i] = _knightSkills[knightId].at(i);
        }

        name = knight.name;
        level = knight.level;
        floorPrice = knight.floorPrice;
        pet = _knightsWithPet[knightId];
        skills = skillIds;
        equipment = [
            knight.mainWeapon,
            knight.subWeapon,
            knight.headgear,
            knight.armor,
            knight.footwear,
            knight.pants,
            knight.gloves,
            knight.mount,
            knight.troop
        ];
    }

    function getKnightLevel(uint knightId) external view override returns (uint) {
        return _knights[knightId].level;
    }

    function getLatestVersion() public view returns (uint) {
        return versions.length - 1;
    }

    function totalSupply() external view returns (uint) {
        return _knights.length;
    }

    function _baseURI() internal view override returns (string memory) {
        return _uri;
    }

    function _makeTransaction(uint knightId, address buyer, address seller, uint price) private {
        Knight storage knight = _knights[knightId];
        uint floorPrice = price * floorPriceInBps / BPS;
        uint marketFee = price * marketFeeInBps / BPS;
        uint newPrice = knight.floorPrice + floorPrice;

        knightsOnSale[knightId] = 0;
        knight.floorPrice = newPrice;

        (bool transferToSeller,) = seller.call{value: price - (floorPrice + marketFee)}("");
        require(transferToSeller);

        (bool transferToTreasury,) = owner().call{value: marketFee}("");
        require(transferToTreasury);

        _transfer(seller, buyer, knightId);

        emit KnightPriceIncreased(knightId, newPrice, floorPrice);
    }

    function _createKnight(uint floorPrice) private returns (uint knightId) {
        _knights.push(Knight("", 1, floorPrice, 0, 0, 0, 0, 0, 0, 0, 0, 0));
        knightId = _knights.length - 1;
        emit KnightCreated(knightId, floorPrice);
    }

    function _setKnightEquipment(uint knightId, uint[] memory itemIds, bool isRemove) private {
        require(knightsOnSale[knightId] == 0, "MoonKnight: cannot change items while on sale");
        require(itemIds.length > 0, "MoonKnight: no item");

        Knight storage knight = _knights[knightId];
        bool[] memory itemSet = new bool[](9);

        for (uint i = 0; i < itemIds.length; i++) {
            uint itemId = itemIds[i];
            uint updatedItemId = isRemove ? 0 : itemId;
            IEquipment.ItemType itemType = equipmentContract.getItemType(itemId);

            require(itemId != 0, "MoonKnight: invalid itemId");
            require(itemType != IEquipment.ItemType.SKILL_BOOK, "MoonKnight: cannot equip skill book");
            require(!itemSet[uint(itemType)], "MoonKnight: duplicate itemType");

            if (itemType == IEquipment.ItemType.MAIN_WEAPON) {
                require(isRemove ? knight.mainWeapon == itemId : knight.mainWeapon == 0, "MoonKnight : invalid mainWeapon");
                knight.mainWeapon = updatedItemId;
                itemSet[uint(IEquipment.ItemType.MAIN_WEAPON)] = true;
            } else if (itemType == IEquipment.ItemType.SUB_WEAPON) {
                require(isRemove ? knight.subWeapon == itemId : knight.subWeapon == 0, "MoonKnight : invalid subWeapon");
                knight.subWeapon = updatedItemId;
                itemSet[uint(IEquipment.ItemType.SUB_WEAPON)] = true;
            } else if (itemType == IEquipment.ItemType.HEADGEAR) {
                require(isRemove ? knight.headgear == itemId : knight.headgear == 0, "MoonKnight : invalid headgear");
                knight.headgear = updatedItemId;
                itemSet[uint(IEquipment.ItemType.HEADGEAR)] = true;
            } else if (itemType == IEquipment.ItemType.ARMOR) {
                require(isRemove ? knight.armor == itemId : knight.armor == 0, "MoonKnight : invalid armor");
                knight.armor = updatedItemId;
                itemSet[uint(IEquipment.ItemType.ARMOR)] = true;
            } else if (itemType == IEquipment.ItemType.FOOTWEAR) {
                require(isRemove ? knight.footwear == itemId : knight.footwear == 0, "MoonKnight : invalid footwear");
                knight.footwear = updatedItemId;
                itemSet[uint(IEquipment.ItemType.FOOTWEAR)] = true;
            } else if (itemType == IEquipment.ItemType.PANTS) {
                require(isRemove ? knight.pants == itemId : knight.pants == 0, "MoonKnight : invalid pants");
                knight.pants = updatedItemId;
                itemSet[uint(IEquipment.ItemType.PANTS)] = true;
            } else if (itemType == IEquipment.ItemType.GLOVES) {
                require(isRemove ? knight.gloves == itemId : knight.gloves == 0, "MoonKnight : invalid gloves");
                knight.gloves = updatedItemId;
                itemSet[uint(IEquipment.ItemType.GLOVES)] = true;
            } else if (itemType == IEquipment.ItemType.MOUNT) {
                require(isRemove ? knight.mount == itemId : knight.mount == 0, "MoonKnight : invalid mount");
                knight.mount = updatedItemId;
                itemSet[uint(IEquipment.ItemType.MOUNT)] = true;
            } else if (itemType == IEquipment.ItemType.TROOP) {
                require(isRemove ? knight.troop == itemId : knight.troop == 0, "MoonKnight : invalid troop");
                knight.troop = updatedItemId;
                itemSet[uint(IEquipment.ItemType.TROOP)] = true;
            }
        }
    }

    function _finalizeStartingIndex(uint versionId, Version storage version) private {
        uint startingIndex = uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp))) % version.maxSupply;
        if (startingIndex == 0) startingIndex = startingIndex + 1;
        version.startingIndex = startingIndex;

        emit StartingIndexFinalized(versionId, startingIndex);
    }

    /**
     * @dev Check if the name string is valid (Alphanumeric and spaces without leading or trailing space)
     */
    function _validateStr(string memory str) internal pure returns (bool) {
        bytes memory b = bytes(str);
        if (b.length < 1) return false;
        if (b.length > 20) return false;

        // Leading space
        if (b[0] == 0x20) return false;

        // Trailing space
        if (b[b.length - 1] == 0x20) return false;

        bytes1 lastChar = b[0];

        for (uint i; i < b.length; i++) {
            bytes1 char = b[i];

            // Cannot contain continuous spaces
            if (char == 0x20 && lastChar == 0x20) return false;

            if (
                !(char >= 0x30 && char <= 0x39) && //9-0
                !(char >= 0x41 && char <= 0x5A) && //A-Z
                !(char >= 0x61 && char <= 0x7A) && //a-z
                !(char == 0x20) //space
            ) {
                return false;
            }

            lastChar = char;
        }

        return true;
    }
}

File 2 of 21 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "./extensions/IERC721Enumerable.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}. 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 || ERC721.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 {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_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 || ERC721.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 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(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    // solhint-disable-next-line no-inline-assembly
                    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` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * 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 3 of 21 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `sender` to `recipient` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 5 of 21 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

            bytes32 lastvalue = set._values[lastIndex];

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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


    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

File 6 of 21 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor () {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), 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 {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor () {
        _status = _NOT_ENTERED;
    }

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

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

        _;

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

File 8 of 21 : IMoonKnight.sol
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IMoonKnight {
    struct Knight {
        string name;
        uint level;
        uint floorPrice;
        uint mainWeapon;
        uint subWeapon;
        uint headgear;
        uint armor;
        uint footwear;
        uint pants;
        uint gloves;
        uint mount;
        uint troop;
    }

    struct Version {
        uint startingIndex;
        uint currentSupply;
        uint maxSupply;
        uint salePrice;
        uint startTime;
        uint revealTime;
        string provenance; // This is the provenance record of all MoonKnight artworks in existence.
    }

    event KnightCreated(uint indexed knightId, uint floorPrice);
    event KnightListed(uint indexed knightId, uint price);
    event KnightDelisted(uint indexed knightId);
    event KnightBought(uint indexed knightId, address buyer, address seller, uint price);
    event KnightOffered(uint indexed knightId, address buyer, uint price);
    event KnightOfferCanceled(uint indexed knightId, address buyer);
    event KnightPriceIncreased(uint indexed knightId, uint floorPrice, uint increasedAmount);
    event NameChanged(uint indexed knightId, string newName);
    event PetAdopted(uint indexed knightId, uint indexed petId);
    event PetReleased(uint indexed knightId, uint indexed petId);
    event SkillLearned(uint indexed knightId, uint indexed skillId);
    event ItemsEquipped(uint indexed knightId, uint[] itemIds);
    event ItemsUnequipped(uint indexed knightId, uint[] itemIds);
    event KnightLeveledUp(uint indexed knightId, uint level, uint amount);
    event DuelConcluded(uint indexed winningKnightId, uint indexed losingKnightId, uint penaltyAmount);
    event StartingIndexFinalized(uint versionId, uint startingIndex);
    event NewVersionAdded(uint versionId);

    /**
     * @notice Claims moon knights when it's on presale phase.
     */
    function claimMoonKnight(uint versionId, uint amount) external payable;

    /**
     * @notice Changes a knight's name.
     *
     * Requirements:
     * - `newName` must be a valid string.
     * - `newName` is not duplicated to other.
     * - Token required: `serviceFeeInToken`.
     */
    function changeKnightName(uint knightId, string memory newName) external;

    /**
     * @notice Anyone can call this function to manually add `floorPrice` to a knight.
     *
     * Requirements:
     * - `msg.value` must not be zero.
     * - knight's `floorPrice` must be under `floorPriceCap`.
     * - Token required: `serviceFeeInToken` * value
     */
    function addFloorPriceToKnight(uint knightId) external payable;

    /**
     * @notice Owner equips items to their knight by burning ERC1155 Equipment NFTs.
     *
     * Requirements:
     * - caller must be owner of the knight.
     */
    function equipItems(uint knightId, uint[] memory itemIds) external;

    /**
     * @notice Owner removes items from their knight. ERC1155 Equipment NFTs are minted back to the owner.
     *
     * Requirements:
     * - caller must be owner of the knight.
     */
    function removeItems(uint knightId, uint[] memory itemIds) external;

    /**
     * @notice Burns a knight to claim its `floorPrice`.
     *
     * - Not financial advice: DONT DO THAT.
     * - Remember to remove all items before calling this function.
     */
    function sacrificeKnight(uint knightId) external;

    /**
     * @notice Lists a knight on sale.
     *
     * Requirements:
     * - `price` cannot be under knight's `floorPrice`.
     * - Caller must be the owner of the knight.
     */
    function list(uint knightId, uint price) external;

    /**
     * @notice Delist a knight on sale.
     */
    function delist(uint knightId) external;

    /**
     * @notice Instant buy a specific knight on sale.
     *
     * Requirements:
     * - Target knight must be currently on sale.
     * - Sent value must be exact the same as current listing price.
     */
    function buy(uint knightId) external payable;

    /**
     * @notice Gives offer for a knight.
     *
     * Requirements:
     * - Owner cannot offer.
     */
    function offer(uint knightId, uint offerValue) external payable;

    /**
     * @notice Owner take an offer to sell their knight.
     *
     * Requirements:
     * - Cannot take offer under knight's `floorPrice`.
     * - Offer value must be at least equal to `minPrice`.
     */
    function takeOffer(uint knightId, address offerAddr, uint minPrice) external;

    /**
     * @notice Cancels an offer for a specific knight.
     */
    function cancelOffer(uint knightId) external;

    /**
     * @notice Learns a skill for given Knight.
     */
    function learnSkill(uint knightId, uint skillId) external;

    /**
     * @notice Adopts a Pet.
     */
    function adoptPet(uint knightId, uint petId) external;

    /**
     * @notice Abandons a Pet attached to a Knight.
     */
    function abandonPet(uint knightId) external;

    /**
     * @notice Operators can level up a Knight
     */
    function levelUp(uint knightId, uint amount) external;

    /**
     * @notice Finalizes the battle aftermath of 2 knights.
     */
    function finalizeDuelResult(uint winningKnightId, uint losingKnightId, uint penaltyInBps) external;

    /**
     * @notice Gets knight information.
     */
    function getKnight(uint knightId) external view returns (
        string memory name,
        uint level,
        uint floorPrice,
        uint pet,
        uint[] memory skills,
        uint[9] memory equipment
    );

    /**
     * @notice Gets current level of given knight.
     */
    function getKnightLevel(uint knightId) external view returns (uint);
}

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

pragma solidity ^0.8.0;

interface IEquipment {
    enum ItemType { MAIN_WEAPON, SUB_WEAPON, HEADGEAR, ARMOR, FOOTWEAR, PANTS, GLOVES, MOUNT, TROOP, SKILL_BOOK }
    enum Rarity { COMMON, UNCOMMON, RARE, EPIC, LEGENDARY, MYTHICAL }

    struct Item {
        string name;
        uint16 maxSupply;
        uint16 minted;
        uint16 burnt;
        uint8 tier;
        uint8 upgradeAmount;
        ItemType itemType;
        Rarity rarity;
    }

    event ItemCreated(uint indexed itemId, string name, uint16 maxSupply, ItemType itemType, Rarity rarity);
    event ItemUpgradable(uint indexed itemId, uint indexed nextTierItemId, uint8 upgradeAmount);

    /**
     * @notice Create an item.
     */
    function createItem(string memory name, uint16 maxSupply, ItemType itemType, Rarity rarity) external;

    /**
     * @notice Add next tier item to existing one.
     */
    function addNextTierItem(uint itemId, uint8 upgradeAmount) external;

    /**
     * @notice Burns the same items to upgrade its tier.
     *
     * Requirements:
     * - sufficient token balance.
     * - Item must have its next tier.
     * - Sender's balance must have at least `upgradeAmount`
     */
    function upgradeItem(uint itemId) external;

    /**
     * @notice Pays some fee to get random items.
     */
    function rollEquipmentGacha(uint vendorId, uint amount) external;

    /**
     * @notice Mints items and returns true if it's run out of stock.
     */
    function mint(address account, uint itemId, uint16 amount) external returns (bool);

    /**
     * @notice Burns ERC1155 equipment since it is equipped to the knight.
     */
    function putItemsIntoStorage(address account, uint[] memory itemIds) external;

    /**
     * @notice Returns ERC1155 equipment back to the owner.
     */
    function returnItems(address account, uint[] memory itemIds) external;

    /**
     * @notice Gets item information.
     */
    function getItem(uint itemId) external view returns (Item memory item);

    /**
     * @notice Gets item type.
     */
    function getItemType(uint itemId) external view returns (ItemType);

    /**
     * @notice Check if item is out of stock.
     */
    function isOutOfStock(uint itemId, uint16 amount) external view returns (bool);
}

File 10 of 21 : IPet.sol
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IPet {
    /**
     * @notice Temporarily burn a pet.
     */
    function bindPet(uint petId) external;

    /**
     * @notice Release given pet back into user inventory.
     */
    function releasePet(uint petId) external;

    /**
     * @notice Gets owner of given pet.
     */
    function ownerOf(uint petId) external view returns (address);
}

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

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Context.sol";
import "./PermissionGroup.sol";

contract AcceptedToken is PermissionGroup {
    using SafeERC20 for IERC20;

    // Token to be used in the ecosystem.
    IERC20 public acceptedToken;

    constructor(IERC20 tokenAddress) {
        acceptedToken = tokenAddress;
    }

    modifier collectTokenAsFee(uint amount, address destAddr) {
        require(acceptedToken.balanceOf(msg.sender) >= amount, "AcceptedToken: insufficient token balance");
        _;
        acceptedToken.safeTransferFrom(msg.sender, destAddr, amount);
    }

    /**
     * @dev Sets accepted token using in the ecosystem.
     */
    function setAcceptedTokenContract(IERC20 tokenAddr) external onlyOwner {
        require(address(tokenAddr) != address(0));
        acceptedToken = tokenAddr;
    }
}

File 12 of 21 : IERC721.sol
// SPDX-License-Identifier: MIT

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 13 of 21 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

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 14 of 21 : IERC721Metadata.sol
// SPDX-License-Identifier: MIT

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 15 of 21 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {

    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

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

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

File 16 of 21 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

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

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

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

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

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

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

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

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

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

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

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

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

pragma solidity ^0.8.0;

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

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

File 18 of 21 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant alphabet = "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] = alphabet[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

}

File 19 of 21 : ERC165.sol
// SPDX-License-Identifier: MIT

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 20 of 21 : IERC165.sol
// SPDX-License-Identifier: MIT

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 21 of 21 : PermissionGroup.sol
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

contract PermissionGroup is Ownable {
    // List of authorized address to perform some restricted actions
    mapping(address => bool) public operators;

    modifier onlyOperator() {
        require(operators[msg.sender], "PermissionGroup: not operator");
        _;
    }

    /**
     * @notice Adds an address as operator.
     */
    function addOperator(address operator) external onlyOwner {
        operators[operator] = true;
    }

    /**
    * @notice Removes an address as operator.
    */
    function removeOperator(address operator) external onlyOwner {
        operators[operator] = false;
    }
}

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

Contract ABI

[{"inputs":[{"internalType":"contract IEquipment","name":"equipmentAddress","type":"address"},{"internalType":"contract IERC20","name":"tokenAddress","type":"address"},{"internalType":"string","name":"baseURI","type":"string"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"revealTime","type":"uint256"},{"internalType":"string","name":"provenance","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"winningKnightId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"losingKnightId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"penaltyAmount","type":"uint256"}],"name":"DuelConcluded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"itemIds","type":"uint256[]"}],"name":"ItemsEquipped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"itemIds","type":"uint256[]"}],"name":"ItemsUnequipped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"KnightBought","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"floorPrice","type":"uint256"}],"name":"KnightCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"KnightDelisted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"level","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"KnightLeveledUp","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"KnightListed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"}],"name":"KnightOfferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"}],"name":"KnightOffered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"floorPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"increasedAmount","type":"uint256"}],"name":"KnightPriceIncreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":false,"internalType":"string","name":"newName","type":"string"}],"name":"NameChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"versionId","type":"uint256"}],"name":"NewVersionAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"petId","type":"uint256"}],"name":"PetAdopted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"petId","type":"uint256"}],"name":"PetReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"knightId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"skillId","type":"uint256"}],"name":"SkillLearned","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"versionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"startingIndex","type":"uint256"}],"name":"StartingIndexFinalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"abandonPet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"acceptedToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"addFloorPriceToKnight","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"revealTime","type":"uint256"},{"internalType":"string","name":"provenance","type":"string"}],"name":"addNewVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"addOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"uint256","name":"petId","type":"uint256"}],"name":"adoptPet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"cancelOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"string","name":"newName","type":"string"}],"name":"changeKnightName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"versionId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"claimMoonKnight","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"delist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"}],"name":"equipItems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"equipmentContract","outputs":[{"internalType":"contract IEquipment","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"winningKnightId","type":"uint256"},{"internalType":"uint256","name":"losingKnightId","type":"uint256"},{"internalType":"uint256","name":"penaltyInBps","type":"uint256"}],"name":"finalizeDuelResult","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"floorPriceInBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"getKnight","outputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"level","type":"uint256"},{"internalType":"uint256","name":"floorPrice","type":"uint256"},{"internalType":"uint256","name":"pet","type":"uint256"},{"internalType":"uint256[]","name":"skills","type":"uint256[]"},{"internalType":"uint256[9]","name":"equipment","type":"uint256[9]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"getKnightLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLatestVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"knightsOnSale","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"knightsWithOffers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"uint256","name":"skillId","type":"uint256"}],"name":"learnSkill","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"levelUp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"}],"name":"list","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"marketFeeInBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"uint256","name":"offerValue","type":"uint256"}],"name":"offer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"operators","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"petContract","outputs":[{"internalType":"contract IPet","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"uint256[]","name":"itemIds","type":"uint256[]"}],"name":"removeItems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"removeOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"reservedNames","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"}],"name":"sacrificeKnight","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"serviceFeeInToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"tokenAddr","type":"address"}],"name":"setAcceptedTokenContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IEquipment","name":"equipmentAddress","type":"address"}],"name":"setEquipmentContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"floorPrice","type":"uint256"},{"internalType":"uint256","name":"marketFee","type":"uint256"}],"name":"setFloorPriceAndMarketFeeInBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxLevel","type":"uint256"}],"name":"setMaxLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IPet","name":"petAddress","type":"address"}],"name":"setPetContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setServiceFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"knightId","type":"uint256"},{"internalType":"address","name":"buyer","type":"address"},{"internalType":"uint256","name":"minPrice","type":"uint256"}],"name":"takeOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"versions","outputs":[{"internalType":"uint256","name":"startingIndex","type":"uint256"},{"internalType":"uint256","name":"currentSupply","type":"uint256"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"revealTime","type":"uint256"},{"internalType":"string","name":"provenance","type":"string"}],"stateMutability":"view","type":"function"}]

608060405260c8600c556016600d5568056bc75e2d63100000600e556064600f553480156200002d57600080fd5b50604051620065023803806200650283398101604081905262000050916200043a565b604080518082018252600a815269135bdbdb92db9a59da1d60b21b60208083019182528351808501909452600684526512d39251d21560d21b9084015281518a9391620000a19160009190620002e1565b508051620000b7906001906020840190620002e1565b5050506000620000cc620002dd60201b60201c565b600680546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600880546001600160a01b03199081166001600160a01b03938416179091556001600955600a8054909116918a16919091179055855162000163906010906020890190620002e1565b506040805160e08101825260008082526020808301828152938301898152606084018981526080850189815260a0860189815260c08701898152601180546001810182559752875160079097027f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c68810197885598517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c698a015593517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6a89015591517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6b880155517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6c870155517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6d86015551805193949293620002cc937f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6e01929190910190620002e1565b50505050505050505050506200055f565b3390565b828054620002ef90620004f3565b90600052602060002090601f0160209004810192826200031357600085556200035e565b82601f106200032e57805160ff19168380011785556200035e565b828001600101855582156200035e579182015b828111156200035e57825182559160200191906001019062000341565b506200036c92915062000370565b5090565b5b808211156200036c576000815560010162000371565b600082601f83011262000398578081fd5b81516001600160401b0380821115620003b557620003b562000530565b604051601f8301601f19908116603f01168101908282118183101715620003e057620003e062000530565b81604052838152602092508683858801011115620003fc578485fd5b8491505b838210156200041f578582018301518183018401529082019062000400565b838211156200043057848385830101525b9695505050505050565b600080600080600080600080610100898b03121562000457578384fd5b8851620004648162000546565b60208a0151909850620004778162000546565b60408a01519097506001600160401b038082111562000494578586fd5b620004a28c838d0162000387565b975060608b0151965060808b0151955060a08b0151945060c08b0151935060e08b0151915080821115620004d4578283fd5b50620004e38b828c0162000387565b9150509295985092959890939650565b600181811c908216806200050857607f821691505b602082108114156200052a57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146200055c57600080fd5b50565b615f93806200056f6000396000f3fe60806040526004361061038c5760003560e01c806370a08231116101dc578063b3517b9311610102578063cc06c359116100a0578063e985e9c51161006f578063e985e9c514610a9b578063ef706adf14610ae4578063f2fde38b14610b04578063ff611a9a14610b2457600080fd5b8063cc06c35914610a32578063d96a094a14610a48578063db2e5bde14610a5b578063dc2b045d14610a7b57600080fd5b8063b88d4fde116100dc578063b88d4fde1461098d578063c0b83d28146109ad578063c467e7e9146109da578063c87b56dd14610a1257600080fd5b8063b3517b931461093a578063b5a045f71461094d578063b856717a1461096d57600080fd5b8063964bc33f1161017a578063a22cb46511610149578063a22cb465146108c4578063a51dabd0146108e4578063a68aa726146108fa578063ac8a584a1461091a57600080fd5b8063964bc33f146108515780639870d7fe146108715780639997e13714610891578063a1920586146108b157600080fd5b8063785ea864116101b6578063785ea864146107cb57806387aee00e146107eb5780638da5cb5b1461081e57806395d89b411461083c57600080fd5b806370a0823114610783578063715018a6146107a35780637363e025146107b857600080fd5b8063344f1ba5116102c1578063559b1ef61161025f5780636352211e1161022e5780636352211e146106f25780636644a3501461071257806368436f1014610728578063693339631461076357600080fd5b8063559b1ef61461066057806355f804b31461068057806359c656be146106a05780635cdf76f8146106d257600080fd5b8063451c3d801161029b578063451c3d80146105e057806350fd7367146106005780635226dc931461062057806352d68d6c1461064057600080fd5b8063344f1ba51461058057806340fac938146105a057806342842e0e146105c057600080fd5b8063119f0ef81161032e5780631872ef12116103085780631872ef121461050a57806323b872dd1461052a57806327b3a3851461054a57806331debdb91461056057600080fd5b8063119f0ef8146104a557806313e7c9d8146104c557806318160ddd146104f557600080fd5b8063082459fa1161036a578063082459fa14610420578063095ea7b3146104425780630b3fdf17146104625780630e6d1de91461048257600080fd5b806301ffc9a71461039157806306fdde03146103c6578063081812fc146103e8575b600080fd5b34801561039d57600080fd5b506103b16103ac3660046157bb565b610b44565b60405190151581526020015b60405180910390f35b3480156103d257600080fd5b506103db610b96565b6040516103bd9190615c23565b3480156103f457600080fd5b50610408610403366004615845565b610c28565b6040516001600160a01b0390911681526020016103bd565b34801561042c57600080fd5b5061044061043b366004615899565b610cc2565b005b34801561044e57600080fd5b5061044061045d366004615774565b610f2d565b34801561046e57600080fd5b5061044061047d366004615845565b611061565b34801561048e57600080fd5b50610497611180565b6040519081526020016103bd565b3480156104b157600080fd5b50600a54610408906001600160a01b031681565b3480156104d157600080fd5b506103b16104e036600461561a565b60076020526000908152604090205460ff1681565b34801561050157600080fd5b50601554610497565b34801561051657600080fd5b5061044061052536600461561a565b611197565b34801561053657600080fd5b5061044061054536600461568a565b611214565b34801561055657600080fd5b50610497600e5481565b34801561056c57600080fd5b5061044061057b3660046159b8565b61128f565b34801561058c57600080fd5b5061044061059b366004615845565b6112fa565b3480156105ac57600080fd5b506104406105bb3660046159b8565b611355565b3480156105cc57600080fd5b506104406105db36600461568a565b6115c7565b3480156105ec57600080fd5b50600854610408906001600160a01b031681565b34801561060c57600080fd5b5061044061061b3660046159b8565b6115e2565b34801561062c57600080fd5b5061044061063b3660046159b8565b6116e7565b34801561064c57600080fd5b5061044061065b36600461561a565b611834565b34801561066c57600080fd5b5061044061067b3660046158bf565b6118b1565b34801561068c57600080fd5b5061044061069b366004615812565b611982565b3480156106ac57600080fd5b506106c06106bb366004615845565b6119e1565b6040516103bd96959493929190615c36565b3480156106de57600080fd5b506104406106ed366004615845565b611caa565b3480156106fe57600080fd5b5061040861070d366004615845565b611cf7565b34801561071e57600080fd5b50610497600c5481565b34801561073457600080fd5b506103b1610743366004615812565b805160208183018101805160148252928201919093012091525460ff1681565b34801561076f57600080fd5b5061044061077e3660046159b8565b611d6e565b34801561078f57600080fd5b5061049761079e36600461561a565b611f13565b3480156107af57600080fd5b50610440611f9a565b6104406107c63660046159b8565b61202c565b3480156107d757600080fd5b506104406107e6366004615845565b6122ef565b3480156107f757600080fd5b5061080b610806366004615845565b612413565b6040516103bd9796959493929190615d32565b34801561082a57600080fd5b506006546001600160a01b0316610408565b34801561084857600080fd5b506103db6124ed565b34801561085d57600080fd5b5061044061086c366004615845565b6124fc565b34801561087d57600080fd5b5061044061088c36600461561a565b6125c4565b34801561089d57600080fd5b50600b54610408906001600160a01b031681565b6104406108bf3660046159b8565b612630565b3480156108d057600080fd5b506104406108df366004615747565b612895565b3480156108f057600080fd5b50610497600d5481565b34801561090657600080fd5b5061044061091536600461561a565b61295a565b34801561092657600080fd5b5061044061093536600461561a565b6129d7565b610440610948366004615845565b612a40565b34801561095957600080fd5b50610440610968366004615973565b612c7c565b34801561097957600080fd5b506104406109883660046158bf565b612f74565b34801561099957600080fd5b506104406109a83660046156ca565b613045565b3480156109b957600080fd5b506104976109c8366004615845565b60126020526000908152604090205481565b3480156109e657600080fd5b506104976109f5366004615875565b601360209081526000928352604080842090915290825290205481565b348015610a1e57600080fd5b506103db610a2d366004615845565b6130c7565b348015610a3e57600080fd5b50610497600f5481565b610440610a56366004615845565b6131a2565b348015610a6757600080fd5b50610440610a763660046159d9565b613376565b348015610a8757600080fd5b50610440610a96366004615a04565b6134fc565b348015610aa757600080fd5b506103b1610ab6366004615652565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b348015610af057600080fd5b50610440610aff366004615845565b613821565b348015610b1057600080fd5b50610440610b1f36600461561a565b61397e565b348015610b3057600080fd5b50610497610b3f366004615845565b613a87565b60006001600160e01b031982166380ac58cd60e01b1480610b7557506001600160e01b03198216635b5e139f60e01b145b80610b9057506301ffc9a760e01b6001600160e01b03198316145b92915050565b606060008054610ba590615e35565b80601f0160208091040260200160405190810160405280929190818152602001828054610bd190615e35565b8015610c1e5780601f10610bf357610100808354040283529160200191610c1e565b820191906000526020600020905b815481529060010190602001808311610c0157829003601f168201915b5050505050905090565b6000818152600260205260408120546001600160a01b0316610ca65760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b60026009541415610d035760405162461bcd60e51b815260206004820152601f6024820152600080516020615f1e8339815191526044820152606401610c9d565b60026009558233610d1382611cf7565b6001600160a01b031614610d395760405162461bcd60e51b8152600401610c9d90615cfb565b60008481526013602090815260408083206001600160a01b03871684529091529020546015805433919087908110610d8157634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c020160020154821015610de25760405162461bcd60e51b815260206004820152601d60248201527f4d6f6f6e4b6e696768743a20756e64657220666c6f6f722070726963650000006044820152606401610c9d565b83821015610e325760405162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e4b6e696768743a206c657373207468616e206d696e207072696365006044820152606401610c9d565b806001600160a01b0316856001600160a01b03161415610ea35760405162461bcd60e51b815260206004820152602660248201527f4d6f6f6e4b6e696768743a2063616e6e6f742062757920796f7572206f776e2060448201526512db9a59da1d60d21b6064820152608401610c9d565b60008681526013602090815260408083206001600160a01b0389168452909152812055610ed286868385613ac3565b604080516001600160a01b0380881682528316602082015290810183905286907f8e5b24f8b069110da0f44ac86e8883213e03a2290268235615824c0e86280d47906060015b60405180910390a25050600160095550505050565b6000610f3882611cf7565b9050806001600160a01b0316836001600160a01b03161415610fa65760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610c9d565b336001600160a01b0382161480610fe057506001600160a01b038116600090815260056020908152604080832033845290915290205460ff165b6110525760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610c9d565b61105c8383613c91565b505050565b600260095414156110a25760405162461bcd60e51b815260206004820152601f6024820152600080516020615f1e8339815191526044820152606401610c9d565b600260095580336110b282611cf7565b6001600160a01b0316146110d85760405162461bcd60e51b8152600401610c9d90615cfb565b6000601583815481106110fb57634e487b7160e01b600052603260045260246000fd5b6000918252602082206002600c909202019081018054929055915061111f84613cff565b604051600090339083908381818185875af1925050503d8060008114611161576040519150601f19603f3d011682016040523d82523d6000602084013e611166565b606091505b505090508061117457600080fd5b50506001600955505050565b60115460009061119290600190615df2565b905090565b6006546001600160a01b031633146111df5760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b6001600160a01b0381166111f257600080fd5b600880546001600160a01b0319166001600160a01b0392909216919091179055565b61121e3382613d9a565b6112845760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610c9d565b61105c838383613e91565b6006546001600160a01b031633146112d75760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b6127106112e48284615da7565b11156112ef57600080fd5b600c91909155600d55565b6006546001600160a01b031633146113425760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b600f54811161135057600080fd5b600f55565b813361136082611cf7565b6001600160a01b0316146113865760405162461bcd60e51b8152600401610c9d90615cfb565b600a5460405163c19a4ef560e01b8152600481018490526000916001600160a01b03169063c19a4ef59060240160206040518083038186803b1580156113cb57600080fd5b505afa1580156113df573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061140391906157f3565b6000858152601760205260409020909150600982600981111561143657634e487b7160e01b600052602160045260246000fd5b146114835760405162461bcd60e51b815260206004820152601e60248201527f4d6f6f6e4b6e696768743a20696e76616c696420736b696c6c20626f6f6b00006044820152606401610c9d565b600061148f8286614031565b9050806114de5760405162461bcd60e51b815260206004820152601b60248201527f4d6f6f6e4b6e696768743a20616c7265616479206c6561726e656400000000006044820152606401610c9d565b60408051600180825281830190925260009160208083019080368337019050509050858160008151811061152257634e487b7160e01b600052603260045260246000fd5b6020908102919091010152600a5460405163bf0d3f7560e01b81526001600160a01b039091169063bf0d3f759061155f9033908590600401615bee565b600060405180830381600087803b15801561157957600080fd5b505af115801561158d573d6000803e3d6000fd5b50506040518892508991507fccf19ad398faa1e99163ffe5bcc2e588dba13c8c500d65c61260f52dbc4dbdec90600090a350505050505050565b61105c83838360405180602001604052806000815250613045565b81336115ed82611cf7565b6001600160a01b0316146116135760405162461bcd60e51b8152600401610c9d90615cfb565b6015838154811061163457634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c0201600201548210156116955760405162461bcd60e51b815260206004820152601d60248201527f4d6f6f6e4b6e696768743a20756e64657220666c6f6f722070726963650000006044820152606401610c9d565b600083815260126020526040908190208390555183907fbbfc0cdc6e5f417a8ed325a749156d2b5656913de94bcc8e46cf968d79fbd4aa906116da9085815260200190565b60405180910390a2505050565b3360009081526007602052604090205460ff166117465760405162461bcd60e51b815260206004820152601d60248201527f5065726d697373696f6e47726f75703a206e6f74206f70657261746f720000006044820152606401610c9d565b60006015838154811061176957634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c02019050600082826001015461178b9190615da7565b90506000831161179a57600080fd5b600f548111156117ec5760405162461bcd60e51b815260206004820152601d60248201527f4d6f6f6e4b6e696768743a206d6178206c6576656c20726561636865640000006044820152606401610c9d565b60018201819055604080518281526020810185905285917ff8ce76aded20692895cb3987a0f52c19c8ee8c8c9a234f6aec9f9d48d31ba8b4910160405180910390a250505050565b6006546001600160a01b0316331461187c5760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b6001600160a01b03811661188f57600080fd5b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b81336118bc82611cf7565b6001600160a01b0316146118e25760405162461bcd60e51b8152600401610c9d90615cfb565b6118ee8383600161403d565b600a5460405163b112673360e01b81526001600160a01b039091169063b1126733906119209033908690600401615bee565b600060405180830381600087803b15801561193a57600080fd5b505af115801561194e573d6000803e3d6000fd5b50505050827fab405b1cd965024eb3b0d30a7d59cf2f5242cb2d5aefb32eeff6c33f1d52c07f836040516116da9190615c10565b6006546001600160a01b031633146119ca5760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b80516119dd9060109060208401906154eb565b5050565b6060600080600060606119f261556f565b600060158881548110611a1557634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c020160405180610180016040529081600082018054611a3f90615e35565b80601f0160208091040260200160405190810160405280929190818152602001828054611a6b90615e35565b8015611ab85780601f10611a8d57610100808354040283529160200191611ab8565b820191906000526020600020905b815481529060010190602001808311611a9b57829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152602001600482015481526020016005820154815260200160068201548152602001600782015481526020016008820154815260200160098201548152602001600a8201548152602001600b8201548152505090506000611b4e601760008b8152602001908152602001600020614973565b905060008167ffffffffffffffff811115611b7957634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611ba2578160200160208202803683370190505b50905060005b82811015611c055760008b8152601760205260409020611bc8908261497d565b828281518110611be857634e487b7160e01b600052603260045260246000fd5b602090810291909101015280611bfd81615e70565b915050611ba8565b50826000015198508260200151975082604001519650601660008b815260200190815260200160002054955080945060405180610120016040528084606001518152602001846080015181526020018460a0015181526020018460c0015181526020018460e001518152602001846101000151815260200184610120015181526020018461014001518152602001846101600151815250935050505091939550919395565b6006546001600160a01b03163314611cf25760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b600e55565b6000818152600260205260408120546001600160a01b031680610b905760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610c9d565b8133611d7982611cf7565b6001600160a01b031614611d9f5760405162461bcd60e51b8152600401610c9d90615cfb565b600b546040516331a9108f60e11b81526004810184905233916001600160a01b031690636352211e9060240160206040518083038186803b158015611de357600080fd5b505afa158015611df7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e1b9190615636565b6001600160a01b031614611e715760405162461bcd60e51b815260206004820152601960248201527f4d6f6f6e4b6e696768743a206e6f7420706574206f776e6572000000000000006044820152606401610c9d565b60008381526016602052604090819020839055600b549051633e72286560e21b8152600481018490526001600160a01b039091169063f9c8a19490602401600060405180830381600087803b158015611ec957600080fd5b505af1158015611edd573d6000803e3d6000fd5b50506040518492508591507f5f0a58d6dd6d5ca80551306b121d87f079ae2ae169233c018d4a34b22e0be7e090600090a3505050565b60006001600160a01b038216611f7e5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610c9d565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b03163314611fe25760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b6006546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600680546001600160a01b0319169055565b60006011838154811061204f57634e487b7160e01b600052603260045260246000fd5b90600052602060002090600702019050600061271082600301546103e86120769190615dd3565b6120809190615dbf565b9050600083118015612093575060328311155b6120df5760405162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e4b6e696768743a20616d6f756e74206f7574206f662072616e6765006044820152606401610c9d565b81600401544210156121335760405162461bcd60e51b815260206004820181905260248201527f4d6f6f6e4b6e696768743a2053616c6520686173206e6f7420737461727465646044820152606401610c9d565b81600201548383600101546121489190615da7565b11156121965760405162461bcd60e51b815260206004820152601460248201527f4d6f6f6e4b6e696768743a20736f6c64206f75740000000000000000000000006044820152606401610c9d565b8282600301546121a69190615dd3565b34146121f45760405162461bcd60e51b815260206004820152601b60248201527f4d6f6f6e4b6e696768743a20696e636f72726563742076616c756500000000006044820152606401610c9d565b60005b8381101561222957600061220a83614989565b90506122163382614b01565b508061222181615e70565b9150506121f7565b508282600101600082825461223e9190615da7565b90915550506006546000906001600160a01b031661225c8584615dd3565b6122669034615df2565b604051600081818185875af1925050503d80600081146122a2576040519150601f19603f3d011682016040523d82523d6000602084013e6122a7565b606091505b50509050806122b557600080fd5b82541580156122d957508260020154836001015414806122d9575082600501544210155b156122e8576122e88584614b1b565b5050505050565b80336122fa82611cf7565b6001600160a01b0316146123205760405162461bcd60e51b8152600401610c9d90615cfb565b600082815260166020526040902054806123715760405162461bcd60e51b8152602060048201526012602482015271135bdbdb92db9a59da1d0e881b9bc81c195d60721b6044820152606401610c9d565b60008381526016602052604080822091909155600b549051631730b48b60e21b8152600481018390526001600160a01b0390911690635cc2d22c90602401600060405180830381600087803b1580156123c957600080fd5b505af11580156123dd573d6000803e3d6000fd5b50506040518392508591507f9f2ad2e9c967359fde12a00ff405c52926c27b89d77724cc56e6fa3915475b1590600090a3505050565b6011818154811061242357600080fd5b906000526020600020906007020160009150905080600001549080600101549080600201549080600301549080600401549080600501549080600601805461246a90615e35565b80601f016020809104026020016040519081016040528092919081815260200182805461249690615e35565b80156124e35780601f106124b8576101008083540402835291602001916124e3565b820191906000526020600020905b8154815290600101906020018083116124c657829003601f168201915b5050505050905087565b606060018054610ba590615e35565b803361250782611cf7565b6001600160a01b03161461252d5760405162461bcd60e51b8152600401610c9d90615cfb565b6000828152601260205260409020546125885760405162461bcd60e51b815260206004820152601660248201527f4d6f6f6e4b6e696768743a206e6f74206c6973746564000000000000000000006044820152606401610c9d565b6000828152601260205260408082208290555183917fb8374e4567c34cb2d58f7ac4847c3877016109e6d2c890d6a35f08e746125ed191a25050565b6006546001600160a01b0316331461260c5760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b6001600160a01b03166000908152600760205260409020805460ff19166001179055565b600260095414156126715760405162461bcd60e51b815260206004820152601f6024820152600080516020615f1e8339815191526044820152606401610c9d565b60026009556000828152601360209081526040808320338085529252822054909181841090816126aa576126a58386615df2565b6126ad565b60005b90506126b886611cf7565b6001600160a01b0316846001600160a01b031614156127195760405162461bcd60e51b815260206004820152601e60248201527f4d6f6f6e4b6e696768743a206f776e65722063616e6e6f74206f6666657200006044820152606401610c9d565b828514156127695760405162461bcd60e51b815260206004820152601660248201527f4d6f6f6e4b6e696768743a2073616d65206f66666572000000000000000000006044820152606401610c9d565b8034146127b85760405162461bcd60e51b815260206004820181905260248201527f4d6f6f6e4b6e696768743a2073656e742076616c756520696e636f72726563746044820152606401610c9d565b60008681526013602090815260408083206001600160a01b0388168452909152902085905581156128545760006127ef8685615df2565b90506000856001600160a01b03168260405160006040518083038185875af1925050503d806000811461283e576040519150601f19603f3d011682016040523d82523d6000602084013e612843565b606091505b505090508061285157600080fd5b50505b604080516001600160a01b03861681526020810187905287917f6213c17a7c670bb7d839f96fa965d96e3217369d9c641d085e5c14140691b8859101610f18565b6001600160a01b0382163314156128ee5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610c9d565b3360008181526005602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6006546001600160a01b031633146129a25760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b6001600160a01b0381166129b557600080fd5b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6006546001600160a01b03163314612a1f5760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b6001600160a01b03166000908152600760205260409020805460ff19169055565b600060158281548110612a6357634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c020190506000348260020154612a859190615da7565b905060003411612ad75760405162461bcd60e51b815260206004820152601960248201527f4d6f6f6e4b6e696768743a206e6f2076616c75652073656e74000000000000006044820152606401610c9d565b68056bc75e2d63100000811115612b305760405162461bcd60e51b815260206004820152601b60248201527f4d6f6f6e4b6e696768743a2063616e6e6f7420616464206d6f726500000000006044820152606401610c9d565b600e546008546040516370a0823160e01b81523360048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015612b7657600080fd5b505afa158015612b8a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bae919061585d565b1015612c0b5760405162461bcd60e51b815260206004820152602660248201527f4d6f6f6e4b6e696768743a20696e73756666696369656e7420746f6b656e2062604482015265616c616e636560d01b6064820152608401610c9d565b60028201819055612c3f33612c286006546001600160a01b031690565b600e546008546001600160a01b0316929190614bb7565b827f086277eb5274417916ccef96cc09aa48d5982bd87d0d03370427f211e934f59082600e546040516116da929190918252602082015260400190565b8133612c8782611cf7565b6001600160a01b031614612cad5760405162461bcd60e51b8152600401610c9d90615cfb565b600e546006546001600160a01b03166008546040516370a0823160e01b815233600482015283916001600160a01b0316906370a082319060240160206040518083038186803b158015612cff57600080fd5b505afa158015612d13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612d37919061585d565b1015612d975760405162461bcd60e51b815260206004820152602960248201527f4163636570746564546f6b656e3a20696e73756666696369656e7420746f6b656044820152686e2062616c616e636560b81b6064820152608401610c9d565b612da084614c11565b612dec5760405162461bcd60e51b815260206004820152601860248201527f4d6f6f6e4b6e696768743a20696e76616c6964206e616d6500000000000000006044820152606401610c9d565b601484604051612dfc9190615acc565b9081526040519081900360200190205460ff1615612e5c5760405162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e4b6e696768743a206e616d6520616c726561647920657869737473006044820152606401610c9d565b600060158681548110612e7f57634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c020190506000816000018054612ea090615e35565b90501115612ede576000601482600001604051612ebd9190615b17565b908152604051908190036020019020805491151560ff199092169190911790555b8451612ef090829060208801906154eb565b506001601486604051612f039190615acc565b908152604051908190036020018120805492151560ff199093169290921790915586907f8edfa912e70e283a8ef6d6f52cd1faef9690ff989eff2f11a134e8478ba7b28b90612f53908890615c23565b60405180910390a2506008546122e8906001600160a01b0316338385614bb7565b8133612f7f82611cf7565b6001600160a01b031614612fa55760405162461bcd60e51b8152600401610c9d90615cfb565b612fb18383600061403d565b600a5460405163bf0d3f7560e01b81526001600160a01b039091169063bf0d3f7590612fe39033908690600401615bee565b600060405180830381600087803b158015612ffd57600080fd5b505af1158015613011573d6000803e3d6000fd5b50505050827f486feabfbbba4afb4ada394c6deea2ebc86e03923978134dd47ad92b8cff26ef836040516116da9190615c10565b61304f3383613d9a565b6130b55760405162461bcd60e51b815260206004820152603160248201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6044820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b6064820152608401610c9d565b6130c184848484614e58565b50505050565b6000818152600260205260409020546060906001600160a01b03166131465760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610c9d565b6000613150614e8b565b90506000815111613170576040518060200160405280600081525061319b565b8061317a84614e9a565b60405160200161318b929190615ae8565b6040516020818303038152906040525b9392505050565b600260095414156131e35760405162461bcd60e51b815260206004820152601f6024820152600080516020615f1e8339815191526044820152606401610c9d565b60026009556000818152601260205260408120549061320183611cf7565b905033826132515760405162461bcd60e51b815260206004820152601760248201527f4d6f6f6e4b6e696768743a206e6f74206f6e2073616c650000000000000000006044820152606401610c9d565b8234146132a05760405162461bcd60e51b815260206004820152601b60248201527f4d6f6f6e4b6e696768743a20696e636f72726563742076616c756500000000006044820152606401610c9d565b816001600160a01b0316816001600160a01b031614156133115760405162461bcd60e51b815260206004820152602660248201527f4d6f6f6e4b6e696768743a2063616e6e6f742062757920796f7572206f776e2060448201526512db9a59da1d60d21b6064820152608401610c9d565b61331d84828486613ac3565b604080516001600160a01b0380841682528416602082015290810184905284907f8e5b24f8b069110da0f44ac86e8883213e03a2290268235615824c0e86280d47906060015b60405180910390a2505060016009555050565b3360009081526007602052604090205460ff166133d55760405162461bcd60e51b815260206004820152601d60248201527f5065726d697373696f6e47726f75703a206e6f74206f70657261746f720000006044820152606401610c9d565b6127108111156133e457600080fd5b60006015848154811061340757634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c0201905060006015848154811061343a57634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c020190506000816002015483600201541161346557826002015461346b565b81600201545b9050600061271061347c8684615dd3565b6134869190615dbf565b90508084600201600082825461349c9190615da7565b92505081905550808360020160008282546134b79190615df2565b9091555050604051818152869088907f613d6c2f0dea7098f87432d2f00bb35f24b7a243406cab36dd4056777a9e5aa99060200160405180910390a350505050505050565b6006546001600160a01b031633146135445760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b600061354e611180565b905060006011828154811061357357634e487b7160e01b600052603260045260246000fd5b90600052602060002090600702016040518060e00160405290816000820154815260200160018201548152602001600282015481526020016003820154815260200160048201548152602001600582015481526020016006820180546135d890615e35565b80601f016020809104026020016040519081016040528092919081815260200182805461360490615e35565b80156136515780601f1061362657610100808354040283529160200191613651565b820191906000526020600020905b81548152906001019060200180831161363457829003601f168201915b5050505050815250509050806040015181602001511461367057600080fd5b6040805160e081018252600080825260208083018281529383018b8152606084018b8152608085018b815260a086018b815260c087018b8152601180546001810182559752875160079097027f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c68810197885598517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c698a015593517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6a89015591517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6b880155517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6c870155517f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6d860155518051939492936137d6937f31ecc21a745e3968a04e9570e4425bc18fa8019c68028196b546d1669c200c6e019291909101906154eb565b5050507ff5177867b3cf937deaac25da8e7733f654828440429b272c4171f20e50129bf78260016138079190615da7565b60405190815260200160405180910390a150505050505050565b600260095414156138625760405162461bcd60e51b815260206004820152601f6024820152600080516020615f1e8339815191526044820152606401610c9d565b6002600955600081815260136020908152604080832033808552925290912054806138cf5760405162461bcd60e51b815260206004820152601a60248201527f4d6f6f6e4b6e696768743a206e6f206f6666657220666f756e640000000000006044820152606401610c9d565b60008381526013602090815260408083206001600160a01b03861680855292528083208390555183908381818185875af1925050503d8060008114613930576040519150601f19603f3d011682016040523d82523d6000602084013e613935565b606091505b505090508061394357600080fd5b6040516001600160a01b038416815284907f352824f537d55388283e894a5f9948bc36fa9d487c0271a4c1108c7d32da7f0490602001613363565b6006546001600160a01b031633146139c65760405162461bcd60e51b81526020600482018190526024820152600080516020615f3e8339815191526044820152606401610c9d565b6001600160a01b038116613a2b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c9d565b6006546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b600060158281548110613aaa57634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c0201600101549050919050565b600060158581548110613ae657634e487b7160e01b600052603260045260246000fd5b90600052602060002090600c020190506000612710600c5484613b099190615dd3565b613b139190615dbf565b90506000612710600d5485613b289190615dd3565b613b329190615dbf565b90506000828460020154613b469190615da7565b6000898152601260205260408120819055600286018290559091506001600160a01b038716613b758486615da7565b613b7f9088615df2565b604051600081818185875af1925050503d8060008114613bbb576040519150601f19603f3d011682016040523d82523d6000602084013e613bc0565b606091505b5050905080613bce57600080fd5b6000613be26006546001600160a01b031690565b6001600160a01b03168460405160006040518083038185875af1925050503d8060008114613c2c576040519150601f19603f3d011682016040523d82523d6000602084013e613c31565b606091505b5050905080613c3f57600080fd5b613c4a888a8c613e91565b60408051848152602081018790528b917f086277eb5274417916ccef96cc09aa48d5982bd87d0d03370427f211e934f590910160405180910390a250505050505050505050565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190613cc682611cf7565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000613d0a82611cf7565b9050613d17600083613c91565b6001600160a01b0381166000908152600360205260408120805460019290613d40908490615df2565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b6000818152600260205260408120546001600160a01b0316613e135760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610c9d565b6000613e1e83611cf7565b9050806001600160a01b0316846001600160a01b03161480613e595750836001600160a01b0316613e4e84610c28565b6001600160a01b0316145b80613e8957506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316613ea482611cf7565b6001600160a01b031614613f0c5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610c9d565b6001600160a01b038216613f6e5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610c9d565b613f79600082613c91565b6001600160a01b0383166000908152600360205260408120805460019290613fa2908490615df2565b90915550506001600160a01b0382166000908152600360205260408120805460019290613fd0908490615da7565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600061319b8383614fb4565b600083815260126020526040902054156140af5760405162461bcd60e51b815260206004820152602d60248201527f4d6f6f6e4b6e696768743a2063616e6e6f74206368616e6765206974656d732060448201526c7768696c65206f6e2073616c6560981b6064820152608401610c9d565b60008251116140f65760405162461bcd60e51b81526020600482015260136024820152724d6f6f6e4b6e696768743a206e6f206974656d60681b6044820152606401610c9d565b60006015848154811061411957634e487b7160e01b600052603260045260246000fd5b600091825260208083206040805160098082526101408201909252600c9490940290910194509082016101208036833701905050905060005b845181101561496b57600085828151811061417d57634e487b7160e01b600052603260045260246000fd5b602002602001015190506000856141945781614197565b60005b600a5460405163c19a4ef560e01b8152600481018590529192506000916001600160a01b039091169063c19a4ef59060240160206040518083038186803b1580156141e157600080fd5b505afa1580156141f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061421991906157f3565b9050826142685760405162461bcd60e51b815260206004820152601a60248201527f4d6f6f6e4b6e696768743a20696e76616c6964206974656d49640000000000006044820152606401610c9d565b600981600981111561428a57634e487b7160e01b600052602160045260246000fd5b14156142e45760405162461bcd60e51b815260206004820152602360248201527f4d6f6f6e4b6e696768743a2063616e6e6f7420657175697020736b696c6c20626044820152626f6f6b60e81b6064820152608401610c9d565b8481600981111561430557634e487b7160e01b600052602160045260246000fd5b8151811061432357634e487b7160e01b600052603260045260246000fd5b6020026020010151156143785760405162461bcd60e51b815260206004820152601e60248201527f4d6f6f6e4b6e696768743a206475706c6963617465206974656d5479706500006044820152606401610c9d565b600081600981111561439a57634e487b7160e01b600052602160045260246000fd5b141561444457866143b0576003860154156143b8565b828660030154145b6144045760405162461bcd60e51b815260206004820152601f60248201527f4d6f6f6e4b6e69676874203a20696e76616c6964206d61696e576561706f6e006044820152606401610c9d565b6003860182905560018560005b8151811061442f57634e487b7160e01b600052603260045260246000fd5b91151560209283029190910190910152614955565b600181600981111561446657634e487b7160e01b600052602160045260246000fd5b14156144e0578661447c57600486015415614484565b828660040154145b6144d05760405162461bcd60e51b815260206004820152601e60248201527f4d6f6f6e4b6e69676874203a20696e76616c696420737562576561706f6e00006044820152606401610c9d565b6004860182905560018581614411565b600281600981111561450257634e487b7160e01b600052602160045260246000fd5b141561457d578661451857600586015415614520565b828660050154145b61456c5760405162461bcd60e51b815260206004820152601d60248201527f4d6f6f6e4b6e69676874203a20696e76616c69642068656164676561720000006044820152606401610c9d565b600586018290556001856002614411565b600381600981111561459f57634e487b7160e01b600052602160045260246000fd5b141561461a57866145b5576006860154156145bd565b828660060154145b6146095760405162461bcd60e51b815260206004820152601a60248201527f4d6f6f6e4b6e69676874203a20696e76616c69642061726d6f720000000000006044820152606401610c9d565b600686018290556001856003614411565b600481600981111561463c57634e487b7160e01b600052602160045260246000fd5b14156146b757866146525760078601541561465a565b828660070154145b6146a65760405162461bcd60e51b815260206004820152601d60248201527f4d6f6f6e4b6e69676874203a20696e76616c696420666f6f74776561720000006044820152606401610c9d565b600786018290556001856004614411565b60058160098111156146d957634e487b7160e01b600052602160045260246000fd5b141561475457866146ef576008860154156146f7565b828660080154145b6147435760405162461bcd60e51b815260206004820152601a60248201527f4d6f6f6e4b6e69676874203a20696e76616c69642070616e74730000000000006044820152606401610c9d565b600886018290556001856005614411565b600681600981111561477657634e487b7160e01b600052602160045260246000fd5b14156147f1578661478c57600986015415614794565b828660090154145b6147e05760405162461bcd60e51b815260206004820152601b60248201527f4d6f6f6e4b6e69676874203a20696e76616c696420676c6f76657300000000006044820152606401610c9d565b600986018290556001856006614411565b600781600981111561481357634e487b7160e01b600052602160045260246000fd5b141561488e578661482957600a86015415614831565b8286600a0154145b61487d5760405162461bcd60e51b815260206004820152601a60248201527f4d6f6f6e4b6e69676874203a20696e76616c6964206d6f756e740000000000006044820152606401610c9d565b600a86018290556001856007614411565b60088160098111156148b057634e487b7160e01b600052602160045260246000fd5b141561495557866148c657600b860154156148ce565b8286600b0154145b61491a5760405162461bcd60e51b815260206004820152601a60248201527f4d6f6f6e4b6e69676874203a20696e76616c69642074726f6f700000000000006044820152606401610c9d565b600b860182905560018560088151811061494457634e487b7160e01b600052603260045260246000fd5b911515602092830291909101909101525b505050808061496390615e70565b915050614152565b505050505050565b6000610b90825490565b600061319b8383615003565b604080516101a08101825260006101808201818152825260016020808401829052938301859052606083018290526080830182905260a0830182905260c0830182905260e0830182905261010083018290526101208301829052610140830182905261016083018290526015805491820181558252825180519294600c9092027f55f448fdea98c4d29eb340757ef0a66cd03dbb9538908a6a81d96026b71ec4750192614a3992849201906154eb565b506020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e082015181600701556101008201518160080155610120820151816009015561014082015181600a015561016082015181600b015550506001601580549050614ac09190615df2565b9050807f0206a5f891c1e0173fe67376aa91f7cb1396d1304ce0c96e5c9d8e7baac7d7fb83604051614af491815260200190565b60405180910390a2919050565b6119dd828260405180602001604052806000815250615097565b600081600201544442604051602001614b3e929190918252602082015260400190565b6040516020818303038152906040528051906020012060001c614b619190615e8b565b905080614b7657614b73816001615da7565b90505b80825560408051848152602081018390527f2cef2ac652db7d723fb9cffa5df9729234275ec9377763568b8337912851d9f7910160405180910390a1505050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526130c19085906150ca565b600080829050600181511015614c2a5750600092915050565b601481511115614c3d5750600092915050565b80600081518110614c5e57634e487b7160e01b600052603260045260246000fd5b6020910101516001600160f81b031916600160fd1b1415614c825750600092915050565b8060018251614c919190615df2565b81518110614caf57634e487b7160e01b600052603260045260246000fd5b6020910101516001600160f81b031916600160fd1b1415614cd35750600092915050565b600081600081518110614cf657634e487b7160e01b600052603260045260246000fd5b01602001516001600160f81b031916905060005b8251811015614e4d576000838281518110614d3557634e487b7160e01b600052603260045260246000fd5b01602001516001600160f81b0319169050600160fd1b81148015614d665750600160fd1b6001600160f81b03198416145b15614d775750600095945050505050565b600360fc1b6001600160f81b0319821610801590614da35750603960f81b6001600160f81b0319821611155b158015614dd95750604160f81b6001600160f81b0319821610801590614dd75750602d60f91b6001600160f81b0319821611155b155b8015614e0e5750606160f81b6001600160f81b0319821610801590614e0c5750603d60f91b6001600160f81b0319821611155b155b8015614e285750600160fd1b6001600160f81b0319821614155b15614e395750600095945050505050565b915080614e4581615e70565b915050614d0a565b506001949350505050565b614e63848484613e91565b614e6f8484848461519c565b6130c15760405162461bcd60e51b8152600401610c9d90615ca9565b606060108054610ba590615e35565b606081614ebe5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115614ee85780614ed281615e70565b9150614ee19050600a83615dbf565b9150614ec2565b60008167ffffffffffffffff811115614f1157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614f3b576020820181803683370190505b5090505b8415613e8957614f50600183615df2565b9150614f5d600a86615e8b565b614f68906030615da7565b60f81b818381518110614f8b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350614fad600a86615dbf565b9450614f3f565b6000818152600183016020526040812054614ffb57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610b90565b506000610b90565b815460009082106150615760405162461bcd60e51b815260206004820152602260248201527f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e604482015261647360f01b6064820152608401610c9d565b82600001828154811061508457634e487b7160e01b600052603260045260246000fd5b9060005260206000200154905092915050565b6150a1838361529e565b6150ae600084848461519c565b61105c5760405162461bcd60e51b8152600401610c9d90615ca9565b600061511f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166153e09092919063ffffffff16565b80519091501561105c578080602001905181019061513d919061579f565b61105c5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610c9d565b60006001600160a01b0384163b15614e4d57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906151e0903390899088908890600401615bb2565b602060405180830381600087803b1580156151fa57600080fd5b505af192505050801561522a575060408051601f3d908101601f19168201909252615227918101906157d7565b60015b615284573d808015615258576040519150601f19603f3d011682016040523d82523d6000602084013e61525d565b606091505b50805161527c5760405162461bcd60e51b8152600401610c9d90615ca9565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050613e89565b6001600160a01b0382166152f45760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610c9d565b6000818152600260205260409020546001600160a01b0316156153595760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610c9d565b6001600160a01b0382166000908152600360205260408120805460019290615382908490615da7565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060613e89848460008585843b6154395760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610c9d565b600080866001600160a01b031685876040516154559190615acc565b60006040518083038185875af1925050503d8060008114615492576040519150601f19603f3d011682016040523d82523d6000602084013e615497565b606091505b50915091506154a78282866154b2565b979650505050505050565b606083156154c157508161319b565b8251156154d15782518084602001fd5b8160405162461bcd60e51b8152600401610c9d9190615c23565b8280546154f790615e35565b90600052602060002090601f016020900481019282615519576000855561555f565b82601f1061553257805160ff191683800117855561555f565b8280016001018555821561555f579182015b8281111561555f578251825591602001919060010190615544565b5061556b92915061558e565b5090565b6040518061012001604052806009906020820280368337509192915050565b5b8082111561556b576000815560010161558f565b600067ffffffffffffffff8311156155bd576155bd615ecb565b6155d0601f8401601f1916602001615d76565b90508281528383830111156155e457600080fd5b828260208301376000602084830101529392505050565b600082601f83011261560b578081fd5b61319b838335602085016155a3565b60006020828403121561562b578081fd5b813561319b81615ee1565b600060208284031215615647578081fd5b815161319b81615ee1565b60008060408385031215615664578081fd5b823561566f81615ee1565b9150602083013561567f81615ee1565b809150509250929050565b60008060006060848603121561569e578081fd5b83356156a981615ee1565b925060208401356156b981615ee1565b929592945050506040919091013590565b600080600080608085870312156156df578081fd5b84356156ea81615ee1565b935060208501356156fa81615ee1565b925060408501359150606085013567ffffffffffffffff81111561571c578182fd5b8501601f8101871361572c578182fd5b61573b878235602084016155a3565b91505092959194509250565b60008060408385031215615759578182fd5b823561576481615ee1565b9150602083013561567f81615ef9565b60008060408385031215615786578182fd5b823561579181615ee1565b946020939093013593505050565b6000602082840312156157b0578081fd5b815161319b81615ef9565b6000602082840312156157cc578081fd5b813561319b81615f07565b6000602082840312156157e8578081fd5b815161319b81615f07565b600060208284031215615804578081fd5b8151600a811061319b578182fd5b600060208284031215615823578081fd5b813567ffffffffffffffff811115615839578182fd5b613e89848285016155fb565b600060208284031215615856578081fd5b5035919050565b60006020828403121561586e578081fd5b5051919050565b60008060408385031215615887578182fd5b82359150602083013561567f81615ee1565b6000806000606084860312156158ad578081fd5b8335925060208401356156b981615ee1565b600080604083850312156158d1578182fd5b8235915060208084013567ffffffffffffffff808211156158f0578384fd5b818601915086601f830112615903578384fd5b81358181111561591557615915615ecb565b8060051b9150615926848301615d76565b8181528481019084860184860187018b1015615940578788fd5b8795505b83861015615962578035835260019590950194918601918601615944565b508096505050505050509250929050565b60008060408385031215615985578182fd5b82359150602083013567ffffffffffffffff8111156159a2578182fd5b6159ae858286016155fb565b9150509250929050565b600080604083850312156159ca578182fd5b50508035926020909101359150565b6000806000606084860312156159ed578081fd5b505081359360208301359350604090920135919050565b600080600080600060a08688031215615a1b578283fd5b85359450602086013593506040860135925060608601359150608086013567ffffffffffffffff811115615a4d578182fd5b615a59888289016155fb565b9150509295509295909350565b6000815180845260208085019450808401835b83811015615a9557815187529582019590820190600101615a79565b509495945050505050565b60008151808452615ab8816020860160208601615e09565b601f01601f19169290920160200192915050565b60008251615ade818460208701615e09565b9190910192915050565b60008351615afa818460208801615e09565b835190830190615b0e818360208801615e09565b01949350505050565b600080835482600182811c915080831680615b3357607f831692505b6020808410821415615b5357634e487b7160e01b87526022600452602487fd5b818015615b675760018114615b7857615ba4565b60ff19861689528489019650615ba4565b60008a815260209020885b86811015615b9c5781548b820152908501908301615b83565b505084890196505b509498975050505050505050565b60006001600160a01b03808716835280861660208401525083604083015260806060830152615be46080830184615aa0565b9695505050505050565b6001600160a01b0383168152604060208201526000613e896040830184615a66565b60208152600061319b6020830184615a66565b60208152600061319b6020830184615aa0565b60006101c0808352615c4a8184018a615aa0565b9050602088818501528760408501528660608501528382036080850152615c718287615a66565b925060a0840191508460005b6009811015615c9a57815184529282019290820190600101615c7d565b50505050979650505050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252601c908201527f4d6f6f6e4b6e696768743a206e6f74206b6e69676874206f776e657200000000604082015260600190565b8781528660208201528560408201528460608201528360808201528260a082015260e060c08201526000615d6960e0830184615aa0565b9998505050505050505050565b604051601f8201601f1916810167ffffffffffffffff81118282101715615d9f57615d9f615ecb565b604052919050565b60008219821115615dba57615dba615e9f565b500190565b600082615dce57615dce615eb5565b500490565b6000816000190483118215151615615ded57615ded615e9f565b500290565b600082821015615e0457615e04615e9f565b500390565b60005b83811015615e24578181015183820152602001615e0c565b838111156130c15750506000910152565b600181811c90821680615e4957607f821691505b60208210811415615e6a57634e487b7160e01b600052602260045260246000fd5b50919050565b6000600019821415615e8457615e84615e9f565b5060010190565b600082615e9a57615e9a615eb5565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114615ef657600080fd5b50565b8015158114615ef657600080fd5b6001600160e01b031981168114615ef657600080fdfe5265656e7472616e637947756172643a207265656e7472616e742063616c6c004f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572a26469706673582212203934e018255279238922cc76814b07b9cc07b2bdfbb508e04fa55916282a363764736f6c63430008040033000000000000000000000000f9dbe8aec9f0cd42c27ff1d7f86fc801773695a900000000000000000000000090822bd3e3d683c394e7928a1d531490e68b9ff000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004e2000000000000000000000000000000000000000000000000006f05b59d3b200000000000000000000000000000000000000000000000000000000000060b248e00000000000000000000000000000000000000000000000000000000060c36c600000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002068747470733a2f2f666172616c616e642e696f2f6170692f6865726f2f69642f000000000000000000000000000000000000000000000000000000000000004063343733306566633864373935303031623339623066323332353062333738613966643561666533646433326231346335623339383134323033303561323734

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

000000000000000000000000f9dbe8aec9f0cd42c27ff1d7f86fc801773695a900000000000000000000000090822bd3e3d683c394e7928a1d531490e68b9ff000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004e2000000000000000000000000000000000000000000000000006f05b59d3b200000000000000000000000000000000000000000000000000000000000060b248e00000000000000000000000000000000000000000000000000000000060c36c600000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000002068747470733a2f2f666172616c616e642e696f2f6170692f6865726f2f69642f000000000000000000000000000000000000000000000000000000000000004063343733306566633864373935303031623339623066323332353062333738613966643561666533646433326231346335623339383134323033303561323734

-----Encoded View---------------
13 Constructor Arguments found :
Arg [0] : 000000000000000000000000f9dbe8aec9f0cd42c27ff1d7f86fc801773695a9
Arg [1] : 00000000000000000000000090822bd3e3d683c394e7928a1d531490e68b9ff0
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [3] : 0000000000000000000000000000000000000000000000000000000000004e20
Arg [4] : 00000000000000000000000000000000000000000000000006f05b59d3b20000
Arg [5] : 0000000000000000000000000000000000000000000000000000000060b248e0
Arg [6] : 0000000000000000000000000000000000000000000000000000000060c36c60
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000140
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000020
Arg [9] : 68747470733a2f2f666172616c616e642e696f2f6170692f6865726f2f69642f
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000040
Arg [11] : 6334373330656663386437393530303162333962306632333235306233373861
Arg [12] : 3966643561666533646433326231346335623339383134323033303561323734


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