ETH Price: $3,168.65 (+4.34%)

Token

ethkun (ETHKUN)
 

Overview

Max Total Supply

5,342 ETHKUN

Holders

1,622

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Filtered by Token Holder
codediablos.eth
Balance
1 ETHKUN
0xaa24f03ce0054041dad876a9593272fa289d1002
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
EthKun

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 33 : EthKun.sol
// SPDX-License-Identifier: MIT
/**
                                                                                                    
                                            ethkun <3 u                                                  
                                                                                                    
                                                                                                    
                                               ,,,***.                                              
                                               ,,,***.                                              
                                               ,,,***.                                              
                                            ,,,,,,*******                                           
                                            ,,,,,,*******                                           
                                         ,,,,,,,,,**********                                        
                                         ,,,,,,,,,**********                                        
                                         ,,,,,,,,,**********                                        
                                      ,,,,,,,,,,,,*************                                     
                                      ,,,,,,,,,,,,*************                                     
                                   ,,,,,,,,,,,,,,,****************                                  
                                   ,,,,,,,,,,,,,,,****************                                  
                                   ,,,,,,,,,,,,,,,****************                                  
                                ,,,,,,,,,,,,,,,,,,*******************                               
                                ,,,,,,,,,,,,,,,,,,*******************                               
                            .,,,,,,,,,,,,&&&,,,,,,******&&&*************                            
                            .,,,,,,,,,||||||,,,,,,******|||||||*********                            
                            .,,,,,,,,,||||||,,,,,,******|||||||*********                            
                         ,,,,,,,,,,,,,||||||,,,,,,******|||||||************                         
                         ,,,,,,,,,,,,,,,,,,,,,,,,,***#&&%******************                         
                      ,,,,,,,,,,,,,,,,,,,,,,&&&&&&&&&&&&%*********************.                     
                            .,,,,,,,,,,,,,,,,,,,,,***#&&%***************                            
                            .,,,,,,,,,,,,,,,,,,,,,***#&&%***************                            
                      ,,,,,,.      ,,,,,,,,,,,,,,,****************      ******.                     
                         ,,,,,,,,,,      ,,,,,,,,,**********      *********                         
                            .,,,,,,,,,,,,      ,,,***.      ************                            
                                ,,,,,,,,,,,,,,,      ,***************                               
                                ,,,,,,,,,,,,,,,      ,***************                               
                                   ,,,,,,,,,,,,,,,****************                                  
                                      ,,,,,,,,,,,,*************                                     
                                         ,,,,,,,,,**********                                        
                                            ,,,,,,*******                                           
                                            ,,,,,,*******                                           
                                               ,,,***.                                              
                                                                                                    
                                                                                                    


**/

// ethkun
// a celebration of The Merge
// by @eddietree and @SecondBestDad

pragma solidity ^0.8.4;

import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import 'base64-sol/base64.sol';

import "./IEthKunRenderer.sol";
import "./EthKunRenderer.sol";

/// @title ethkun
/// @author @eddietree
/// @notice ethkun is an 100% on-chain experimental NFT project
contract EthKun is ERC721A, Ownable {
    
    // TTD: 58750000000000000000000 
    uint256 public constant MAX_TOKEN_SUPPLY_GENESIS = 5875;

    // contracts
    IEthKunRenderer public contractRenderer;

    enum MintStatus {
        CLOSED, // 0
        PUBLIC // 1
    }

    MintStatus public mintStatus = MintStatus.CLOSED;
    bool public revealEnabled = false;
    bool public mergeEnabled = false;
    bool public demoteRerollEnabled = false;
    bool public burnSacrificeEnabled = false;

    mapping(uint256 => uint256) public seeds; // seeds for image + stats
    mapping(uint256 => uint) public level;
    uint256 public maxLevel = 64;
    uint256 public mergeBlockNumber = 0; // estimated block# to be injected

    // tier 0 (free mint)
    uint256 public tier0_supply = 2000;
    uint256 public tier0_price = 0.0 ether;
    uint256 public tier0_maxTokensOwnedInWallet = 2;
    uint256 public tier0_maxMintsPerTransaction = 1;

    // tier 1 (paid)
    uint256 public tier1_price = 0.01 ether;
    uint256 public tier1_maxTokensOwnedInWallet = 64;
    uint256 public tier1_maxMintsPerTransaction = 64;

    uint256 public constant SECS_PER_DAY = 86400;

    // events
    event EthKunLevelUp(uint256 indexed tokenId, uint256 oldLevel, uint256 newLevel); // emitted when an EthKun levels up
    event EthKunDied(uint256 indexed tokenIdDied, uint256 level, uint256 indexed tokenMergedInto); // emitted when an EthKun dies
    event EthKunSacrificed(uint256 indexed tokenId); // emitted when an EthKun gets sacrificed upon the alter of Vitty B
    event EthRerolled(uint256 indexed tokenId, uint256 newLevel); // emitted when an EthKun gets rerolled

    constructor() ERC721A("ethkun", "ETHKUN") {
        //contractRenderer = IEthKunRenderer(this);
    }

    modifier verifyTokenId(uint256 tokenId) {
        require(tokenId >= _startTokenId() && tokenId <= _totalMinted(), "Invalid");
        _;
    }

    modifier onlyApprovedOrOwner(uint256 tokenId) {
        require(
            _ownershipOf(tokenId).addr == _msgSender() ||
                getApproved(tokenId) == _msgSender(),
            "Not approved nor owner"
        );
        
        _;
    }

    modifier verifySupplyGenesis(uint256 numToMint) {
        require(numToMint > 0, "Mint at least 1");
        require(_totalMinted() + numToMint <= MAX_TOKEN_SUPPLY_GENESIS, "Invalid");

        _;
    }

    // randomize seed
    function _saveSeed(uint256 tokenId) private {
        seeds[tokenId] = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), tokenId, msg.sender)));
    }

    /// @notice Burn sacrifice an ethkun at the altar of Lord Vitalik
    /// @param tokenId The tokenID for the EthKun
    function burnSacrifice(uint256 tokenId) external onlyApprovedOrOwner(tokenId) {
        //require(msg.sender == ownerOf(tokenId), "Not yours");
        require(burnSacrificeEnabled == true);

        _burn(tokenId);
        emit EthKunSacrificed(tokenId);
    }

    function _startTokenId() override internal pure virtual returns (uint256) {
        return 1;
    }

    function _mintEthKuns(address to, uint256 numToMint) private {
        uint256 startTokenId = _startTokenId() + _totalMinted();
         for(uint256 tokenId = startTokenId; tokenId < startTokenId+numToMint; tokenId++) {
            _saveSeed(tokenId);
            level[tokenId] = 1;
         }

         _safeMint(to, numToMint);
    }

    function reserveEthKuns(address to, uint256 numToMint) external onlyOwner {
        _mintEthKuns(to, numToMint);
    }

    function reserveEthKunsMany(address[] calldata recipients, uint256 numToMint) external onlyOwner {
        uint256 num = recipients.length;
        require(num > 0);

        for (uint256 i = 0; i < num; ++i) {
            _mintEthKuns(recipients[i], numToMint);    
        }
    }

    /// @notice Mint genesis ethkuns into your wallet!
    /// @param numToMint The number of genesis ethkuns to mint 
    function mintEthKunsGenesis(uint256 numToMint) external payable verifySupplyGenesis(numToMint) {
        require(mintStatus == MintStatus.PUBLIC, "Public mint closed");
        require(msg.value >= _getPrice(numToMint), "Incorrect ether sent" );

        // check max mint
        (uint256 maxTokensOwnedInWallet, uint256 maxMintsPerTransaction) = _getMaxMintsData();
        require(_numberMinted(msg.sender) + numToMint <= maxTokensOwnedInWallet, "Exceeds max mints");
        require(numToMint <= maxMintsPerTransaction, "Exceeds transaction max");

        _mintEthKuns(msg.sender, numToMint);
    }

    function _merge(uint256[] calldata tokenIds) private {
        uint256 num = tokenIds.length;
        require(num > 0);

        // all the levels accumulate to the first token
        uint256 tokenIdChad = tokenIds[0];
        uint256 accumulatedTotalLevel = 0;

        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            uint256 tokenLevel = level[tokenId];

            require( _ownershipOf(tokenId).addr == _msgSender() || getApproved(tokenId) == _msgSender(), "Denied");
            require(tokenLevel != 0, "Dead");

            accumulatedTotalLevel += tokenLevel;

            // burn if not main one
            if (i > 0) {
                _burn(tokenId);
                emit EthKunDied(tokenId, tokenLevel, tokenIdChad);

                // reset
                level[tokenId] = 0;
            }
        }

        require(accumulatedTotalLevel <= maxLevel, "Exceeded max level");

        uint256 prevLevel = level[tokenIdChad];
        level[tokenIdChad] = accumulatedTotalLevel;

        //_saveSeed(tokenIdChad);
        emit EthKunLevelUp(tokenIdChad, prevLevel, accumulatedTotalLevel);
    }

    /// @notice Merge several ethkuns into one buff gigachad ethkun, all the levels accumulate into the gigachad ethkun, but the remaining ethkuns are burned, gg
    /// @param tokenIds Array of owned tokenIds. Note that the first tokenId will be the one that remains and accumulates levels of other ethkuns, the other tokens will be BURNT!!
    function merge(uint256[] calldata tokenIds) external {
        require(_isRevealed() && mergeEnabled, "Not mergeable");
        _merge(tokenIds);
    }

    /// @notice Reroll the visuals/stats of ethkun, but unfortunately demotes them by -1 level :(
    /// @param tokenIds Array of owned tokenIds of ethkuns to demote
    function rerollMany(uint256[] calldata tokenIds) external {
        require(_isRevealed() && demoteRerollEnabled);

        uint256 num = tokenIds.length;
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            uint256 tokenLevel = level[tokenId];

            require(_ownershipOf(tokenId).addr == _msgSender(), "Must own");
            require(tokenLevel > 1, "At least Lvl 1"); // need to be at least level 1 to reroll
            
            // reroll visuals/stats
            _saveSeed(tokenId); 

            // demote -1 evel
            uint256 tokenLevelDemoted = tokenLevel-1;
            level[tokenId] = tokenLevelDemoted; 

            emit EthRerolled(tokenId, tokenLevelDemoted);
        }
    }

    // taken from 'ERC721AQueryable.sol'
    function tokensOfOwner(address owner) external view returns (uint256[] memory) {
        unchecked {
            uint256 tokenIdsIdx;
            address currOwnershipAddr;
            uint256 tokenIdsLength = balanceOf(owner);
            uint256[] memory tokenIds = new uint256[](tokenIdsLength);
            TokenOwnership memory ownership;
            for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            return tokenIds;
        }
    }

    ///////////////////////////
    // -- GETTERS/SETTERS --
    ///////////////////////////
    function getNumMinted() external view returns (uint256) {
        return _totalMinted();
    }

    function _getNumBabiesMinted() private view returns (uint256) {
        uint256 numTotalMinted = _totalMinted();

        if (numTotalMinted <= MAX_TOKEN_SUPPLY_GENESIS)
            return 0;

        return numTotalMinted - MAX_TOKEN_SUPPLY_GENESIS;
    }

    function getNumBabiesMinted() external view returns (uint256) {
        return _getNumBabiesMinted();
    }

    function setPricing(uint256[] calldata pricingData) external onlyOwner {
        // tier 0
        tier0_supply = pricingData[0];
        tier0_price = pricingData[1];
        tier0_maxTokensOwnedInWallet = pricingData[2];
        tier0_maxMintsPerTransaction = pricingData[3];

        // tier 1
        tier1_price = pricingData[4];
        tier1_maxTokensOwnedInWallet = pricingData[5];
        tier1_maxMintsPerTransaction = pricingData[6];

        require(tier0_supply <= MAX_TOKEN_SUPPLY_GENESIS);
    }

    function _getPrice(uint256 numToMint) private view returns (uint256) {
        uint256 numMintedAlready = _totalMinted();
        return numToMint * (numMintedAlready < tier0_supply ? tier0_price : tier1_price);
    }

    function getPrice(uint256 numToMint) external view returns (uint256) {
        return _getPrice(numToMint);
    }

    function _getMaxMintsData() private view returns (uint256 maxTokensOwnedInWallet, uint256 maxMintsPerTransaction) {
        uint256 numMintedAlready = _totalMinted();

        return (numMintedAlready < tier0_supply) ? 
            (tier0_maxTokensOwnedInWallet, tier0_maxMintsPerTransaction) 
            : (tier1_maxTokensOwnedInWallet, tier1_maxMintsPerTransaction);
    }

    function getMaxMintsData() external view returns (uint256 maxTokensOwnedInWallet, uint256 maxMintsPerTransaction) {
        return _getMaxMintsData() ;
    }

    function setMaxLevel(uint256 _maxLevel) external onlyOwner {
        maxLevel = _maxLevel;
    }

    function setMintStatus(uint256 _status) external onlyOwner {
        mintStatus = MintStatus(_status);
    }

    function setContractRenderer(address newAddress) external onlyOwner {
        contractRenderer = IEthKunRenderer(newAddress);
    }

    function setRevealed(bool _revealEnabled) external onlyOwner {
        revealEnabled = _revealEnabled;
    }

    function setMergeEnabled(bool _enabled) external onlyOwner {
        mergeEnabled = _enabled;
    }

    function setMergeBlockNumber(uint256 newMergeBlockNumber) external onlyOwner {
        mergeBlockNumber = newMergeBlockNumber;
    }

    function setBurnSacrificeEnabled(bool _enabled) external onlyOwner {
        burnSacrificeEnabled = _enabled;
    }

    function setDemoteRerollEnabled(bool _enabled) external onlyOwner {
        demoteRerollEnabled = _enabled;
    }

    function numberMinted(address addr) external view returns(uint256){
        return _numberMinted(addr);
    }

    function isGenesis(uint256 tokenId) external pure returns(bool){
        return tokenId <= MAX_TOKEN_SUPPLY_GENESIS;
    }

    ///////////////////////////
    // -- MERKLE NERD STUFF --
    ///////////////////////////
    bytes32 public merkleRoot = 0x0;
    bool public merkleMintEnabled = false;
    uint256 public constant merkleMintMax = 1;

    function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner {
        merkleRoot = _merkleRoot;
    }

    function setMerkleMintEnabled(bool _enabled) external onlyOwner {
        merkleMintEnabled = _enabled;
    }

    function _verifyMerkle(bytes32[] calldata _proof, bytes32 _leaf) private view returns (bool) {
        return MerkleProof.verify(_proof, merkleRoot, _leaf);
    }

    function verifyMerkle(bytes32[] calldata _proof, bytes32 _leaf) external view returns (bool) {
        return _verifyMerkle(_proof, _leaf);
    }

    function verifyMerkleAddress(bytes32[] calldata _proof, address from) external view returns (bool) {
        bytes32 leaf = keccak256(abi.encodePacked(from));
        return _verifyMerkle(_proof, leaf);
    }

    function mintMerkle(bytes32[] calldata _merkleProof, uint256 numToMint) external verifySupplyGenesis(numToMint) {
        require(merkleMintEnabled == true, "Merkle closed");
        require(_numberMinted(msg.sender) + numToMint <= merkleMintMax, "Can claim only 1");

        // verify merkle        
        bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
        require(_verifyMerkle(_merkleProof, leaf), "Invalid proof");

        _mintEthKuns(msg.sender, numToMint);
    }

    ///////////////////////////
    // -- TOKEN URI --
    ///////////////////////////
    function _tokenURI(uint256 tokenId) private view returns (string memory) {
        //string[13] memory lookup = [  '0', '1', '2', '3', '4', '5', '6', '7', '8','9', '10','11', '12'];

        uint256 seed = seeds[tokenId];
        unchecked{ // unchecked so it can run over
            seed += mergeBlockNumber;
        }

        uint256 currentLevel = level[tokenId];

        string memory image = contractRenderer.getSVG(seed, currentLevel);

        string memory json = Base64.encode(
            bytes(string(
                abi.encodePacked(
                    '{"name": ', '"ethkun #', Strings.toString(tokenId),'",',
                    '"description": "ethkun is an 100% on-chain dynamic NFT project with unique functionality and fun merge mechanics, made to celebrate The Merge! Gambatte ethkun!",',
                    '"attributes":[',
                        contractRenderer.getTraitsMetadata(seed),
                        _getStatsMetadata(seed, currentLevel),
                        '{"trait_type":"Genesis", "value":', (tokenId <= MAX_TOKEN_SUPPLY_GENESIS) ? '"Yes"' : '"No"', '},',
                        '{"trait_type":"Steaking", "value":', (steakingStartTimestamp[tokenId] != NULL_STEAKING) ? '"Yes"' : '"No"', '},',
                        '{"trait_type":"Level", "value":',Strings.toString(currentLevel),'}'
                    '],',
                    '"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}' 
                )
            ))
        );

        return string(abi.encodePacked('data:application/json;base64,', json));
    }

    function _tokenUnrevealedURI(uint256 tokenId) private view returns (string memory) {
        uint256 seed = seeds[tokenId];
        string memory image = contractRenderer.getUnrevealedSVG(seed);

        string memory json = Base64.encode(
            bytes(string(
                abi.encodePacked(
                    '{"name": ', '"ethkun #', Strings.toString(tokenId),'",',
                    '"description": "ethkun is an 100% on-chain dynamic NFT project with unique functionality and fun merge mechanics, made to celebrate The Merge! Gambatte ethkun!",',
                    '"attributes":[{"trait_type":"Waiting for The Merge", "value":"True"}],',
                    '"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}' 
                )
            ))
        );

        return string(abi.encodePacked('data:application/json;base64,', json));
    }

    function _isRevealed() private view returns (bool) {
        return revealEnabled && block.number > mergeBlockNumber;   
    }

    function tokenURI(uint256 tokenId) override(ERC721A) public view verifyTokenId(tokenId) returns (string memory) {
        if (_isRevealed()) 
            return _tokenURI(tokenId);
        else
            return _tokenUnrevealedURI(tokenId);
    }

    function _randStat(uint256 seed, uint256 div, uint256 min, uint256 max) private pure returns (uint256) {
        return min + (seed/div) % (max-min);
    }

    function _getStatsMetadata(uint256 seed, uint256 currLevel) private pure returns (string memory) {
        //string[11] memory lookup = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ];

        string memory metadata = string(abi.encodePacked(
          '{"trait_type":"Kimochii", "display_type": "number", "value":', Strings.toString(_randStat(seed, 2, 1, 5+currLevel)), '},',
          '{"trait_type":"UWU", "display_type": "number", "value":', Strings.toString(_randStat(seed, 3, 2, 10+currLevel)), '},',
          '{"trait_type":"Ultrasoundness", "display_type": "number", "value":', Strings.toString(_randStat(seed, 4, 2, 10+currLevel)), '},',
          '{"trait_type":"Fungibility", "display_type": "number", "value":', Strings.toString(_randStat(seed, 5, 2, 10+currLevel)), '},',
          '{"trait_type":"Sugoiness", "display_type": "number", "value":', Strings.toString(_randStat(seed, 6, 2, 10+currLevel)), '},',
          '{"trait_type":"Kakkoii", "display_type": "number", "value":', Strings.toString(_randStat(seed, 7, 2, 10+currLevel)), '},',
          '{"trait_type":"Kawaii", "display_type": "number", "value":', Strings.toString(_randStat(seed, 8, 2, 10+currLevel)), '},',
          '{"trait_type":"Moisturized", "display_type": "number", "value":', Strings.toString(_randStat(seed, 9, 2, 10+currLevel)), '},'
        ));

        return metadata;
    }

    function withdraw() external onlyOwner {
        uint balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }

    ///////////////////////////
    // -- STEAKING --
    ///////////////////////////

    bool public steakingEnabled = false;
    bool public mintingBabiesEnabled = false;
    uint256 public minSteakingLevel = 8; // ethkun's min level to allow for steaking
    uint256 private constant NULL_STEAKING = 0;

    // steaking curve parameters
    uint256 public steakingMinDays = 2;
    uint256 public steakingCurveDivisor = 8;
    uint256 public steakingLevelBoostDivisor = 16;

    // steaking
    mapping(uint256 => uint256) private steakingStartTimestamp; // tokenId -> steaking start time (0 = not steaking).
    mapping(uint256 => uint256) private steakingTotalTime; // tokenId -> cumulative steaking time, does not include current time if steaking
    
    // events
    event EventStartSteaking(uint256 indexed tokenId);
    event EventEndSteaking(uint256 indexed tokenId);
    event EventForceEndSteaking(uint256 indexed tokenId);
    event EventBirthBaby(uint256 indexed tokenIdParent, uint256 indexed tokenIdBaby);

    // currentSteakingTime: current steaking time in secs (0 = not steaking)
    // totalSteakingTime: total time of steaking (in secs)
    function getSteakingInfoForToken(uint256 tokenId) external view returns (uint256 currentSteakingTime, uint256 totalSteakingTime, bool steaking)
    {
        currentSteakingTime = 0;
        uint256 startTimestamp = steakingStartTimestamp[tokenId];

        // is steaking?
        if (startTimestamp != NULL_STEAKING) { 
            currentSteakingTime = block.timestamp - startTimestamp;
        }

        totalSteakingTime = currentSteakingTime + steakingTotalTime[tokenId];
        steaking = startTimestamp != NULL_STEAKING;
    }

    function setSteakingEnabled(bool allowed) external onlyOwner {
        steakingEnabled = allowed;
    }

    function setMintingBabiesEnabled(bool allowed) external onlyOwner {
        mintingBabiesEnabled = allowed;
    }

    function setSteakingMinLevel(uint256 _minLvl) external onlyOwner {
        minSteakingLevel = _minLvl;
    }

    function _toggleSteaking(uint256 tokenId) private onlyApprovedOrOwner(tokenId)
    {
        uint256 startTimestamp = steakingStartTimestamp[tokenId];

        if (startTimestamp == NULL_STEAKING) { 
            // start steaking
            require(steakingEnabled, "Disabled");
            require(level[tokenId] >= minSteakingLevel, "Not level");
            steakingStartTimestamp[tokenId] = block.timestamp;

            emit EventStartSteaking(tokenId);
        } else { 
            // start unsteaking
            steakingTotalTime[tokenId] += block.timestamp - startTimestamp;
            steakingStartTimestamp[tokenId] = NULL_STEAKING;

            emit EventEndSteaking(tokenId);
        }
    }

    /// @notice Token steaking on multiple ethkun tokens!
    /// @param tokenIds Array of ethkun tokenIds to toggle steaking 
    function toggleSteaking(uint256[] calldata tokenIds) external {
        uint256 num = tokenIds.length;

        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            _toggleSteaking(tokenId);
        }
    }

    function _resetAndClearSteaking(uint256 tokenId) private {
        // end staking
        if (steakingStartTimestamp[tokenId] != NULL_STEAKING) {
            steakingStartTimestamp[tokenId] = NULL_STEAKING;
            emit EventEndSteaking(tokenId);
        }

        // clear total staking time
        if (steakingTotalTime[tokenId] != NULL_STEAKING)    
            steakingTotalTime[tokenId] = NULL_STEAKING;
    }

    function _adminForceStopSteaking(uint256 tokenId) private {
        require(steakingStartTimestamp[tokenId] != NULL_STEAKING, "Character not steaking");
        
        // accum current time
        uint256 deltaTime = block.timestamp - steakingStartTimestamp[tokenId];
        steakingTotalTime[tokenId] += deltaTime;

        // no longer steaking
        steakingStartTimestamp[tokenId] = NULL_STEAKING;

        emit EventEndSteaking(tokenId);
        emit EventForceEndSteaking(tokenId);
    }

    function adminForceStopSteaking(uint256[] calldata tokenIds) external onlyOwner {
        uint256 num = tokenIds.length;

        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            _adminForceStopSteaking(tokenId);
        }
    }

    function _canSpawnEthKunBaby(uint256 tokenId) private view returns (bool) {
        uint256 currentSteakingTime = 0;
        uint256 startTimestamp = steakingStartTimestamp[tokenId];

        // is steaking?
        if (startTimestamp != NULL_STEAKING) { 
            currentSteakingTime = block.timestamp - startTimestamp;
        }

        uint256 totalSteakingTime = currentSteakingTime + steakingTotalTime[tokenId];
        
        return 
            totalSteakingTime >= _getSecsSteakingRequiredToMintBaby(tokenId)  // check staking time
            && level[tokenId] >= minSteakingLevel // check level
            && steakingStartTimestamp[tokenId] != NULL_STEAKING; // is staking
    }

    function canSpawnEthKunBaby(uint256 tokenId) external view returns (bool) {
        return _canSpawnEthKunBaby(tokenId);
    }

    /// @notice Set parameters for steaking
    /// @param _steakingMinDays Minimum days for steaking
    /// @param _steakingCurveDivisor Per baby coefficient divisor
    function setSteakingParams(uint256 _steakingMinDays, uint256 _steakingCurveDivisor, uint256 _steakingLevelBoostDivisor) external onlyOwner {
        steakingMinDays = _steakingMinDays;
        steakingCurveDivisor = _steakingCurveDivisor;
        steakingLevelBoostDivisor = _steakingLevelBoostDivisor;
    }

    function _getSecsSteakingRequiredToMintBaby(uint256 tokenId) private view returns (uint256) {

        // formula goes as such
        // secs requires to mint =
        //      min days
        //      + secsCurveFromBabies
        //      - levelBoost

        // curve for babies minted
        uint256 numBabiesMinted = _getNumBabiesMinted();
        uint256 secsFromBabiesMinted = (SECS_PER_DAY*numBabiesMinted)/steakingCurveDivisor;

        // reduction for higher level
        uint256 secsLevelSubtractor = 0;
        uint256 currLevel = level[tokenId];
        if (currLevel > minSteakingLevel) {
            secsLevelSubtractor = (SECS_PER_DAY*(currLevel - minSteakingLevel)) / steakingLevelBoostDivisor;
        }

        // cannot go below steakingMinDays
        if (secsLevelSubtractor > secsFromBabiesMinted) {
            secsLevelSubtractor = secsFromBabiesMinted;
        }

        uint256 secMinSteaked = steakingMinDays * SECS_PER_DAY + secsFromBabiesMinted - secsLevelSubtractor;
        
        // convert days to seconds
        return secMinSteaked;
    }

    /// @notice Mint a baby ethkun from steaked parent ethkun!
    /// @param parentTokenIds Steaked ethkun tokenIds to spawn from
    function mintEthKunBaby(uint256[] calldata parentTokenIds) external {
        _mintEthKunBabies(parentTokenIds);
    }

    function _mintEthKunBabies(uint256[] calldata parentTokenIds) private {
        require(mintingBabiesEnabled == true, "Babies disabled");
        //require(steakingEnabled == true, "Steaking disabled");

        uint256 num = parentTokenIds.length;
        for (uint256 i = 0; i < num; ++i) {

            uint256 parentTokenId = parentTokenIds[i];

            require(_ownershipOf(parentTokenId).addr == _msgSender() || getApproved(parentTokenId) == _msgSender(), "Denied");
            require(_canSpawnEthKunBaby(parentTokenId), "Not ready");

            // mint a new baby to owner's address!
            _mintEthKuns(_ownershipOf(parentTokenId).addr, 1);

            // reset staking to now
            steakingTotalTime[parentTokenId] = 0;
            steakingStartTimestamp[parentTokenId] = block.timestamp;

            uint256 childTokenId = _totalMinted();
            emit EventBirthBaby(parentTokenId, childTokenId);
        }
    }

     function _beforeTokenTransfers(address from, address to, uint256 startTokenId, uint256 quantity) internal override {
        // bypass for minting and burning
        if (from == address(0) || to == address(0))
            return;

        // transfers will cancel+clear steaking
        if (from != address(0)) {
            for (uint256 tokenId = startTokenId; tokenId < startTokenId + quantity; ++tokenId) {
                _resetAndClearSteaking(tokenId);
            }
        }
    }

    function getSecsSteakingRequiredToMintBaby(uint256 tokenId) external view returns (uint256) {
        return _getSecsSteakingRequiredToMintBaby(tokenId);
    }
}

File 2 of 33 : AntibotRenderer.sol
// SPDX-License-Identifier: MIT
// referenced from original Aribibots render code.

pragma solidity ^0.8.0;

import 'base64-sol/base64.sol';

contract BotRenderer {

  mapping(uint256 => uint256) public seeds; // will be copied from OG Arbibots contract
  mapping(uint256 => bool) public flipped;

  string[][] public palettes = [
    ['#b5eaea', '#edf6e5', '#f38ba0'],
    ['#b5c7ea', '#e5f6e8', '#f3bb8b'],
    ['#eab6b5', '#eee5f6', '#8bf3df'],
    ['#c3eab5', '#f6e9e5', '#c18bf3'],
    ['#eab5d9', '#e5e8f6', '#8bf396']
  ];

  bytes[] public bodies = [
    bytes(hex'ff00ba0001010404010111000101060301010f000101080301010d000101090301010d000101090301010d00010109030101'),
    bytes(hex'ff00ba0001010404010111000101060301010f000101080301010d000101090301010d000101090301010d00010109030101'),
    bytes(hex'ff00b90001010504010111000101050301011100010105030101110001010503010111000101050301011100010105030101'),
    bytes(hex'ff00ba000101030401011200010105030101100001010104010103030101010401010e00010103040301030401010c0001010b0401010a0001010d040101'),
    bytes(hex'ff00b9000101050301010f0002010104010103030101010402010c00010104040301040401010a0001010d040101090001010d040101090001010d040101'),
    bytes(hex'ff00ba00010103030101120001010104010101030101010401011000010103040101030401010f000101070401010f000101070401010f00010107040101'),
    bytes(hex'ff00ba0001010104010101030101010401011000010103040101020401010f00010104040101030401010e00010104040101040401010d00010104040101040401010d0001010404010104040101')
  ];

  bytes[] public heads = [
    bytes(hex'96000c010b0001010c030101090001010e030101080001010e030101080001010e030101080001010e030101080001010e030101080001010e030101080001010e030101080001010e030101080001010e03010109000e01'),
    bytes(hex'97000a010d0001010a0301010b0001010c030101090001010e030101080001010e030101080001010e030101080001010e030101080001010e030101080001010e030101090001010c0301010b0001010a0301010d000a01'),
    bytes(hex'9400100107000101100401010600010101040e03010401010600010101040e03010401010600010101040e03010401010600010101040e03010401010600010101040e03010401010600010101040e03010401010600010101040e03010401010600010101040e0301040101060001011004010107001001'),
    bytes(hex'96000c010b0001010c030101090001010e030101070001011003010105000101120301010400010112030101040001011203010104000101120301010500010110030101070001010d030201090001010b0301010c000b01'),
    bytes(hex'9400100107000101100301010600010110030101060001011003010106000101100301010600010110030101070001010e030101080001010e030101090001010c0301010a0001010c0301010b0001010a0301010d000a01')
  ];

  bytes[] public eyes = [
    bytes(hex'ff0010000201070002010d0001010104070001010104ff00'),
    bytes(hex'ff001000030105000301ff00'),
    bytes(hex'f8000101070001010e000101010001010500010101000101ff00'),
    bytes(hex'df000301050003010d000301050003010e00010107000101ff00'),
    bytes(hex'ff0011000101070001010f00010107000101ff00'),
    bytes(hex'ff00100001010100010105000101010001010e00010107000101ff00')
  ];

  bytes[] public mouths = [
    bytes(hex'ff004300010101000101010001011400010101000101'),
    bytes(hex'ff00450001011600010101000101'),
    bytes(hex'ff005c000401'),
    bytes(hex'ff00440001010200010115000201'),
    bytes(hex'ff0044000401140001010204010115000201')
  ];

  bytes[] public headgears = [
    bytes(hex'37000101080001010d0001010100010106000101010001010e000101060001011000010106000101ff00'),
    bytes(hex'240001011600010101000101150001011700010117000101ff00'),
    bytes(hex'0c000201150001010200010114000101010001010104010113000101020001011400010117000101ff00'),
    bytes(hex'68000101060001010f000101010301010400010101030101ff00'),
    bytes(hex'50000101060001010f0001010103010104000101010301010e000101020301010200010102030101ff00')
  ];

  struct BotData {
    uint palette;
    uint body;
    uint head;
    uint eyes;
    uint mouth;
    uint headgear;
  }

  function _getSVG(uint256 tokenId) internal view returns (string memory) {
    BotData memory data = _generateBotData(tokenId);
    string[] memory palette = palettes[data.palette];

    bool flip = flipped[tokenId];

    string memory image = string(abi.encodePacked(
      '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" shape-rendering="crispEdges" width="256" height="256">'
      '<rect width="100%" height="100%" fill="', palette[0], '" />',
      _renderRectsSingleColor(bodies[data.body], '#000000', flip),
      _renderRectsSingleColor(heads[data.head], '#000000', flip),
      _renderRects(eyes[data.eyes], palette, '#ffffff', flip),
      _renderRects(mouths[data.mouth], palette, '#ffffff', flip),
      _renderRects(headgears[data.headgear], palette, '#000000', flip),
      '</svg>'
    ));

    return image;
  }

  function _render(uint256 tokenId) internal view returns (string memory) {
   
    string memory image = _getSVG(tokenId);

    return string(abi.encodePacked(
      'data:application/json;base64,',
      Base64.encode(
        bytes(
          abi.encodePacked('{"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}')
        )
      )
    ));
  }

  function _renderRectsSingleColor(bytes memory data, string memory color, bool flip) private pure returns (string memory) {
    string[24] memory lookup = [
      '0', '1', '2', '3', '4', '5', '6', '7',
      '8', '9', '10', '11', '12', '13', '14', '15',
      '16', '17', '18', '19', '20', '21', '22', '23'
    ];

    string memory rects;
    uint256 drawIndex = 0;
    for (uint256 i = 0; i < data.length; i = i+2) {
      uint8 runLength = uint8(data[i]); // we assume runLength of any non-transparent segment cannot exceed image width (24px)
      uint8 colorIndex = uint8(data[i+1]);
      if (colorIndex != 0) { // transparent
        uint8 x = uint8(drawIndex % 24);
        x = 24-x-runLength; // mirror horizontally
        uint8 y = uint8(drawIndex / 24);

        if (flip) // mirror vertically
            y = 23-y;

        rects = string(abi.encodePacked(rects, '<rect width="', lookup[runLength], '" height="1" x="', lookup[x], '" y="', lookup[y], '" fill="', color, '" />'));
      }
      drawIndex += runLength;
    }

    return rects;
  }

  function _renderRects(bytes memory data, string[] memory palette, string memory defaultColor, bool flip) private pure returns (string memory) {
    string[24] memory lookup = [
      '0', '1', '2', '3', '4', '5', '6', '7',
      '8', '9', '10', '11', '12', '13', '14', '15',
      '16', '17', '18', '19', '20', '21', '22', '23'
    ];

    string memory rects;
    uint256 drawIndex = 0;
    for (uint256 i = 0; i < data.length; i = i+2) {
      uint8 runLength = uint8(data[i]); // we assume runLength of any non-transparent segment cannot exceed image width (24px)
      uint8 colorIndex = uint8(data[i+1]);
      if (colorIndex != 0) { // transparent
        uint8 x = uint8(drawIndex % 24);
        x = 24-x-runLength; // mirror horizontally
        uint8 y = uint8(drawIndex / 24);
        
        if (flip) // mirror vertically
            y = 23-y;

        string memory color = defaultColor;
        if (colorIndex > 1) {
          color = palette[colorIndex-2];
        }
        rects = string(abi.encodePacked(rects, '<rect width="', lookup[runLength], '" height="1" x="', lookup[x], '" y="', lookup[y], '" fill="', color, '" />'));
      }
      drawIndex += runLength;
    }

    return rects;
  }

  function _generateBotData(uint256 tokenId) private view returns (BotData memory) {
    uint256 seed = seeds[tokenId];

    return BotData({
      palette: seed % palettes.length,
      body: (seed/2) % bodies.length,
      head: (seed/3) % heads.length,
      eyes: (seed/4) % eyes.length,
      mouth: (seed/5) % mouths.length,
      headgear: (seed/6) % headgears.length
    });
  }
}

File 3 of 33 : base64.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0;

/// @title Base64
/// @author Brecht Devos - <[email protected]>
/// @notice Provides functions for encoding/decoding base64
library Base64 {
    string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
    bytes  internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000"
                                            hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000"
                                            hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000"
                                            hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000";

    function encode(bytes memory data) internal pure returns (string memory) {
        if (data.length == 0) return '';

        // load the table into memory
        string memory table = TABLE_ENCODE;

        // multiply by 4/3 rounded up
        uint256 encodedLen = 4 * ((data.length + 2) / 3);

        // add some extra buffer at the end required for the writing
        string memory result = new string(encodedLen + 32);

        assembly {
            // set the actual output length
            mstore(result, encodedLen)

            // prepare the lookup table
            let tablePtr := add(table, 1)

            // input ptr
            let dataPtr := data
            let endPtr := add(dataPtr, mload(data))

            // result ptr, jump over length
            let resultPtr := add(result, 32)

            // run over the input, 3 bytes at a time
            for {} lt(dataPtr, endPtr) {}
            {
                // read 3 bytes
                dataPtr := add(dataPtr, 3)
                let input := mload(dataPtr)

                // write 4 characters
                mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
                resultPtr := add(resultPtr, 1)
                mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
                resultPtr := add(resultPtr, 1)
                mstore8(resultPtr, mload(add(tablePtr, and(shr( 6, input), 0x3F))))
                resultPtr := add(resultPtr, 1)
                mstore8(resultPtr, mload(add(tablePtr, and(        input,  0x3F))))
                resultPtr := add(resultPtr, 1)
            }

            // padding with '='
            switch mod(mload(data), 3)
            case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) }
            case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) }
        }

        return result;
    }

    function decode(string memory _data) internal pure returns (bytes memory) {
        bytes memory data = bytes(_data);

        if (data.length == 0) return new bytes(0);
        require(data.length % 4 == 0, "invalid base64 decoder input");

        // load the table into memory
        bytes memory table = TABLE_DECODE;

        // every 4 characters represent 3 bytes
        uint256 decodedLen = (data.length / 4) * 3;

        // add some extra buffer at the end required for the writing
        bytes memory result = new bytes(decodedLen + 32);

        assembly {
            // padding with '='
            let lastBytes := mload(add(data, mload(data)))
            if eq(and(lastBytes, 0xFF), 0x3d) {
                decodedLen := sub(decodedLen, 1)
                if eq(and(lastBytes, 0xFFFF), 0x3d3d) {
                    decodedLen := sub(decodedLen, 1)
                }
            }

            // set the actual output length
            mstore(result, decodedLen)

            // prepare the lookup table
            let tablePtr := add(table, 1)

            // input ptr
            let dataPtr := data
            let endPtr := add(dataPtr, mload(data))

            // result ptr, jump over length
            let resultPtr := add(result, 32)

            // run over the input, 4 characters at a time
            for {} lt(dataPtr, endPtr) {}
            {
               // read 4 characters
               dataPtr := add(dataPtr, 4)
               let input := mload(dataPtr)

               // write 3 bytes
               let output := add(
                   add(
                       shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)),
                       shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))),
                   add(
                       shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)),
                               and(mload(add(tablePtr, and(        input , 0xFF))), 0xFF)
                    )
                )
                mstore(resultPtr, shl(232, output))
                resultPtr := add(resultPtr, 3)
            }
        }

        return result;
    }
}

File 4 of 33 : Antibots.sol
// SPDX-License-Identifier: MIT
//
// [ @ _ @ ]
//
// Antibots by @eddietree

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import "./AntibotRenderer.sol";

contract Antibots is BotRenderer, ERC721, ERC721Enumerable, ERC721Burnable, Ownable {
    constructor() ERC721("Antibots", "ANTIBOTS") {}

    bool public redeemEnabled = true;

    // original arbibots contract
    IERC721Enumerable public contractArbibots;
    bytes4 constant sigFunc_ownerOf = bytes4(keccak256("ownerOf(uint256)"));
    bytes4 constant sigFunc_balanceOf = bytes4(keccak256("balanceOf(address)"));
    bytes4 constant sigFunc_tokenOfOwnerByIndex = bytes4(keccak256("tokenOfOwnerByIndex(address,uint256)"));
    bytes4 constant sigVariable_seeds = bytes4(keccak256("seeds(uint256)")); // mapping(uint256 => uint256) public seeds;

    event AntibotRedeemed(uint256 indexed tokenId); // emitted when Antibot is redeemed
    event AntibotNinjaFlipped(uint256 indexed tokenId); // emitted when Antibot is flipped!

    function _ninjaFlip(uint256 tokenId) internal {
        require(_exists(tokenId), "Nonexistent token");

        flipped[tokenId] = !flipped[tokenId];
        emit AntibotNinjaFlipped(tokenId);
    }

    function ninjaFlip(uint256 tokenId) external {
        require(msg.sender == ownerOf(tokenId), "Not yours homie.");
        _ninjaFlip(tokenId);
    }

    function ninjaFlipMany(uint256[] calldata tokenIds) external {
        uint256 num = tokenIds.length;
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            require(msg.sender == ownerOf(tokenId), "Not yours homie.");
            _ninjaFlip(tokenId);
        }
    }

    function ninjaFlipAll() external {
        uint256 num = balanceOf(msg.sender);
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenOfOwnerByIndex(msg.sender, i);
            _ninjaFlip(tokenId);
        }
    }

    function ninjaFlipAdmin(uint256 tokenId) external onlyOwner {
        _ninjaFlip(tokenId);
    }

    function _redeem(uint256 tokenId, address to) internal {
        require(!_exists(tokenId), "Already redeemed!");

        _mint(to, tokenId);
        seeds[tokenId] = fetchSeedForToken(tokenId);

        emit AntibotRedeemed(tokenId);
    }

    function redeemIndividual(uint256 tokenId) external {
        require(msg.sender == fetchOwnerOfArbibot(tokenId), "Not yours homie.");
        require(redeemEnabled, "Not enabled!");
        _redeem(tokenId, msg.sender);
    }

    // redeem all 
    function redeem() external {
        require(redeemEnabled, "Not enabled!");

        uint256 num = fetchNumArbibotsOwnedBy(msg.sender);
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = fetchArbibotTokenOfOwnerByIndex(msg.sender, i);

            // only redeem if it hasnt been redeemed yet
            if (!_exists(tokenId))
                _redeem(tokenId, msg.sender);
        }
    }

    function redeemMany(uint256[] calldata tokenIds) external {
        require(redeemEnabled, "Not enabled!");

        uint256 num = tokenIds.length;
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            require(msg.sender == fetchOwnerOfArbibot(tokenId), "Not yours homie.");
            _redeem(tokenId, msg.sender);
        }
    }

    // returns array of redeemable tokenIds and count of redeemable tokens
    // note: count can be less than memory.length
    function getAllRedeemableTokens() external view returns (uint256[] memory, uint count) {

        uint256 num = fetchNumArbibotsOwnedBy(msg.sender);
        uint256[] memory redeemableTokens = new uint256[](num);

        count = 0;

        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = fetchArbibotTokenOfOwnerByIndex(msg.sender, i);

            // only redeem if it hasnt been redeemed yet
            if (!_exists(tokenId)) {
                redeemableTokens[count] = tokenId;
                count++;
            }
        }

        return (redeemableTokens, count);
    }

    /*function adminRedeem(uint256 tokenId) external onlyOwner { // for testing
        _redeem(tokenId, msg.sender);
    }

    function adminRedeemMany(uint256[] calldata tokenIds) external { // for testing
        uint256 num = tokenIds.length;
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            _redeem(tokenId, msg.sender);
        }
    }*/

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

    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal override(ERC721, ERC721Enumerable) {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) {
        return super.supportsInterface(interfaceId);
    }

    function setRedeemEnabled(bool newEnabled) external onlyOwner {
        redeemEnabled = newEnabled;
    }

    function setContractArbibots(address newAddress) external onlyOwner {
        contractArbibots = IERC721Enumerable(newAddress);
    }

    function fetchSeedForToken(uint256 tokenId) internal returns (uint256) { 
        if (address(contractArbibots) == address(0)) {
            return tokenId;
        }

        bytes memory data = abi.encodeWithSelector(sigVariable_seeds, tokenId);
        (bool success, bytes memory returnedData) = address(contractArbibots).call(data);
        require(success);

        uint256 seed = abi.decode(returnedData, (uint256));
        return seed;
    }

    function fetchOwnerOfArbibot(uint256 arbibotTokenId) public view returns (address) {
        if (address(contractArbibots) == address(0)) {
            return address(0);
        }

        return contractArbibots.ownerOf(arbibotTokenId);
    }

    function fetchNumArbibotsOwnedBy(address from) public view returns (uint256) {
        if (address(contractArbibots) == address(0)) {
            return 0;
        }

        return contractArbibots.balanceOf(from);
    }

    function fetchArbibotTokenOfOwnerByIndex(address from, uint256 index) public view returns (uint256) {
        if (address(contractArbibots) == address(0)) {
            return 0;
        }

        return contractArbibots.tokenOfOwnerByIndex(from, index);
    }

    function withdraw() public onlyOwner {
        uint balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }
}

File 5 of 33 : ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: address zero is not a valid owner");
        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: invalid token ID");
        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) {
        _requireMinted(tokenId);

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

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

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

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

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        _requireMinted(tokenId);

        return _tokenApprovals[tokenId];
    }

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

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token 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: caller is not token 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) {
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == 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);

        _afterTokenTransfer(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);

        _afterTokenTransfer(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 from incorrect owner");
        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);

        _afterTokenTransfer(from, to, tokenId);
    }

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

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

    /**
     * @dev Reverts if the `tokenId` has not been minted yet.
     */
    function _requireMinted(uint256 tokenId) internal view virtual {
        require(_exists(tokenId), "ERC721: invalid token ID");
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
                return retval == IERC721Receiver.onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    /// @solidity memory-safe-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` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}

File 6 of 33 : ERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721.sol";
import "./IERC721Enumerable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

    /**
     * @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 override {
        super._beforeTokenTransfer(from, to, tokenId);

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}

File 7 of 33 : ERC721Burnable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)

pragma solidity ^0.8.0;

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

/**
 * @title ERC721 Burnable Token
 * @dev ERC721 Token that can be burned (destroyed).
 */
abstract contract ERC721Burnable is Context, ERC721 {
    /**
     * @dev Burns `tokenId`. See {ERC721-_burn}.
     *
     * Requirements:
     *
     * - The caller must own `tokenId` or be an approved operator.
     */
    function burn(uint256 tokenId) public virtual {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
        _burn(tokenId);
    }
}

File 8 of 33 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

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

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

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

File 9 of 33 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * 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;

    /**
     * @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 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 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 the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

File 10 of 33 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

File 12 of 33 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

File 14 of 33 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

File 17 of 33 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

    /**
     * @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 18 of 33 : UkeToken.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.4;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
//import "@openzeppelin/contracts/utils/Strings.sol";
//import 'base64-sol/base64.sol';


contract UkeToken is ERC20, Ownable {

    uint256 public constant START_TOKEN_SUPPLY = 420;

    constructor() ERC20 ("UkeToken", "UKE") {
      _mint(msg.sender, START_TOKEN_SUPPLY);
    }

    function decimals() public view virtual override returns (uint8) {
      return 16;
    }

    function mintAdmin(address to, uint256 tokenCount) external onlyOwner {
        _mint(to, tokenCount);
    }
}

File 19 of 33 : ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../../utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20, IERC20Metadata {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

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

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
        }
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

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

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

File 20 of 33 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

File 21 of 33 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

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

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 22 of 33 : ERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.2
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721A.sol';

/**
 * @dev Interface of ERC721 token receiver.
 */
interface ERC721A__IERC721Receiver {
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

/**
 * @title ERC721A
 *
 * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
 * Non-Fungible Token Standard, including the Metadata extension.
 * Optimized for lower gas during batch mints.
 *
 * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
 * starting from `_startTokenId()`.
 *
 * Assumptions:
 *
 * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
 * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
 */
contract ERC721A is IERC721A {
    // Reference type for token approval.
    struct TokenApprovalRef {
        address value;
    }

    // =============================================================
    //                           CONSTANTS
    // =============================================================

    // Mask of an entry in packed address data.
    uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;

    // The bit position of `numberMinted` in packed address data.
    uint256 private constant _BITPOS_NUMBER_MINTED = 64;

    // The bit position of `numberBurned` in packed address data.
    uint256 private constant _BITPOS_NUMBER_BURNED = 128;

    // The bit position of `aux` in packed address data.
    uint256 private constant _BITPOS_AUX = 192;

    // Mask of all 256 bits in packed address data except the 64 bits for `aux`.
    uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;

    // The bit position of `startTimestamp` in packed ownership.
    uint256 private constant _BITPOS_START_TIMESTAMP = 160;

    // The bit mask of the `burned` bit in packed ownership.
    uint256 private constant _BITMASK_BURNED = 1 << 224;

    // The bit position of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;

    // The bit mask of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;

    // The bit position of `extraData` in packed ownership.
    uint256 private constant _BITPOS_EXTRA_DATA = 232;

    // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
    uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;

    // The mask of the lower 160 bits for addresses.
    uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;

    // The maximum `quantity` that can be minted with {_mintERC2309}.
    // This limit is to prevent overflows on the address data entries.
    // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
    // is required to cause an overflow, which is unrealistic.
    uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;

    // The `Transfer` event signature is given by:
    // `keccak256(bytes("Transfer(address,address,uint256)"))`.
    bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    // =============================================================
    //                            STORAGE
    // =============================================================

    // The next token ID to be minted.
    uint256 private _currentIndex;

    // The number of tokens burned.
    uint256 private _burnCounter;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to ownership details
    // An empty struct value does not necessarily mean the token is unowned.
    // See {_packedOwnershipOf} implementation for details.
    //
    // Bits Layout:
    // - [0..159]   `addr`
    // - [160..223] `startTimestamp`
    // - [224]      `burned`
    // - [225]      `nextInitialized`
    // - [232..255] `extraData`
    mapping(uint256 => uint256) private _packedOwnerships;

    // Mapping owner address to address data.
    //
    // Bits Layout:
    // - [0..63]    `balance`
    // - [64..127]  `numberMinted`
    // - [128..191] `numberBurned`
    // - [192..255] `aux`
    mapping(address => uint256) private _packedAddressData;

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

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

    // =============================================================
    //                          CONSTRUCTOR
    // =============================================================

    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _currentIndex = _startTokenId();
    }

    // =============================================================
    //                   TOKEN COUNTING OPERATIONS
    // =============================================================

    /**
     * @dev Returns the starting token ID.
     * To change the starting token ID, please override this function.
     */
    function _startTokenId() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev Returns the next token ID to be minted.
     */
    function _nextTokenId() internal view virtual returns (uint256) {
        return _currentIndex;
    }

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than `_currentIndex - _startTokenId()` times.
        unchecked {
            return _currentIndex - _burnCounter - _startTokenId();
        }
    }

    /**
     * @dev Returns the total amount of tokens minted in the contract.
     */
    function _totalMinted() internal view virtual returns (uint256) {
        // Counter underflow is impossible as `_currentIndex` does not decrement,
        // and it is initialized to `_startTokenId()`.
        unchecked {
            return _currentIndex - _startTokenId();
        }
    }

    /**
     * @dev Returns the total number of tokens burned.
     */
    function _totalBurned() internal view virtual returns (uint256) {
        return _burnCounter;
    }

    // =============================================================
    //                    ADDRESS DATA OPERATIONS
    // =============================================================

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();
        return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens minted by `owner`.
     */
    function _numberMinted(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens burned by or on behalf of `owner`.
     */
    function _numberBurned(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     */
    function _getAux(address owner) internal view returns (uint64) {
        return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
    }

    /**
     * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     * If there are multiple variables, please pack them into a uint64.
     */
    function _setAux(address owner, uint64 aux) internal virtual {
        uint256 packed = _packedAddressData[owner];
        uint256 auxCasted;
        // Cast `aux` with assembly to avoid redundant masking.
        assembly {
            auxCasted := aux
        }
        packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
        _packedAddressData[owner] = packed;
    }

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        // The interface IDs are constants representing the first 4 bytes
        // of the XOR of all function selectors in the interface.
        // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
        // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
        return
            interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
            interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
            interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
    }

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

    /**
     * @dev Returns the token collection name.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

        string memory baseURI = _baseURI();
        return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
    }

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

    // =============================================================
    //                     OWNERSHIPS OPERATIONS
    // =============================================================

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return address(uint160(_packedOwnershipOf(tokenId)));
    }

    /**
     * @dev Gas spent here starts off proportional to the maximum mint batch size.
     * It gradually moves to O(1) as tokens get transferred around over time.
     */
    function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnershipOf(tokenId));
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct at `index`.
     */
    function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnerships[index]);
    }

    /**
     * @dev Initializes the ownership slot minted at `index` for efficiency purposes.
     */
    function _initializeOwnershipAt(uint256 index) internal virtual {
        if (_packedOwnerships[index] == 0) {
            _packedOwnerships[index] = _packedOwnershipOf(index);
        }
    }

    /**
     * Returns the packed ownership data of `tokenId`.
     */
    function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
        uint256 curr = tokenId;

        unchecked {
            if (_startTokenId() <= curr)
                if (curr < _currentIndex) {
                    uint256 packed = _packedOwnerships[curr];
                    // If not burned.
                    if (packed & _BITMASK_BURNED == 0) {
                        // Invariant:
                        // There will always be an initialized ownership slot
                        // (i.e. `ownership.addr != address(0) && ownership.burned == false`)
                        // before an unintialized ownership slot
                        // (i.e. `ownership.addr == address(0) && ownership.burned == false`)
                        // Hence, `curr` will not underflow.
                        //
                        // We can directly compare the packed value.
                        // If the address is zero, packed will be zero.
                        while (packed == 0) {
                            packed = _packedOwnerships[--curr];
                        }
                        return packed;
                    }
                }
        }
        revert OwnerQueryForNonexistentToken();
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct from `packed`.
     */
    function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
        ownership.addr = address(uint160(packed));
        ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
        ownership.burned = packed & _BITMASK_BURNED != 0;
        ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
    }

    /**
     * @dev Packs ownership data into a single uint256.
     */
    function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
            result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
        }
    }

    /**
     * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
     */
    function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
        // For branchless setting of the `nextInitialized` flag.
        assembly {
            // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
            result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
        }
    }

    // =============================================================
    //                      APPROVAL OPERATIONS
    // =============================================================

    /**
     * @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) public virtual override {
        address owner = ownerOf(tokenId);

        if (_msgSenderERC721A() != owner)
            if (!isApprovedForAll(owner, _msgSenderERC721A())) {
                revert ApprovalCallerNotOwnerNorApproved();
            }

        _tokenApprovals[tokenId].value = to;
        emit Approval(owner, to, tokenId);
    }

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();

        return _tokenApprovals[tokenId].value;
    }

    /**
     * @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) public virtual override {
        if (operator == _msgSenderERC721A()) revert ApproveToCaller();

        _operatorApprovals[_msgSenderERC721A()][operator] = approved;
        emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
    }

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

    /**
     * @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. See {_mint}.
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return
            _startTokenId() <= tokenId &&
            tokenId < _currentIndex && // If within bounds,
            _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
    }

    /**
     * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
     */
    function _isSenderApprovedOrOwner(
        address approvedAddress,
        address owner,
        address msgSender
    ) private pure returns (bool result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
            msgSender := and(msgSender, _BITMASK_ADDRESS)
            // `msgSender == owner || msgSender == approvedAddress`.
            result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
        }
    }

    /**
     * @dev Returns the storage slot and value for the approved address of `tokenId`.
     */
    function _getApprovedSlotAndAddress(uint256 tokenId)
        private
        view
        returns (uint256 approvedAddressSlot, address approvedAddress)
    {
        TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
        // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId]`.
        assembly {
            approvedAddressSlot := tokenApproval.slot
            approvedAddress := sload(approvedAddressSlot)
        }
    }

    // =============================================================
    //                      TRANSFER OPERATIONS
    // =============================================================

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * 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
    ) public virtual override {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        // The nested ifs save around 20+ gas over a compound boolean condition.
        if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
            if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();

        if (to == address(0)) revert TransferToZeroAddress();

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // We can directly increment and decrement the balances.
            --_packedAddressData[from]; // Updates: `balance -= 1`.
            ++_packedAddressData[to]; // Updates: `balance += 1`.

            // Updates:
            // - `address` to the next owner.
            // - `startTimestamp` to the timestamp of transfering.
            // - `burned` to `false`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                to,
                _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, to, tokenId);
        _afterTokenTransfers(from, to, tokenId, 1);
    }

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, '');
    }

    /**
     * @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 memory _data
    ) public virtual override {
        transferFrom(from, to, tokenId);
        if (to.code.length != 0)
            if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
                revert TransferToNonERC721ReceiverImplementer();
            }
    }

    /**
     * @dev Hook that is called before a set of serially-ordered token IDs
     * are about to be transferred. This includes minting.
     * And also called before burning one token.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * 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, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Hook that is called after a set of serially-ordered token IDs
     * have been transferred. This includes minting.
     * And also called after one token has been burned.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
     * transferred to `to`.
     * - When `from` is zero, `tokenId` has been minted for `to`.
     * - When `to` is zero, `tokenId` has been burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
     *
     * `from` - Previous owner of the given token ID.
     * `to` - Target address that will receive the token.
     * `tokenId` - Token ID to be transferred.
     * `_data` - Optional data to send along with the call.
     *
     * Returns whether the call correctly returned the expected magic value.
     */
    function _checkContractOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
            bytes4 retval
        ) {
            return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
        } catch (bytes memory reason) {
            if (reason.length == 0) {
                revert TransferToNonERC721ReceiverImplementer();
            } else {
                assembly {
                    revert(add(32, reason), mload(reason))
                }
            }
        }
    }

    // =============================================================
    //                        MINT OPERATIONS
    // =============================================================

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _mint(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (quantity == 0) revert MintZeroQuantity();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are incredibly unrealistic.
        // `balance` and `numberMinted` have a maximum limit of 2**64.
        // `tokenId` has a maximum limit of 2**256.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            uint256 toMasked;
            uint256 end = startTokenId + quantity;

            // Use assembly to loop and emit the `Transfer` event for gas savings.
            assembly {
                // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
                toMasked := and(to, _BITMASK_ADDRESS)
                // Emit the `Transfer` event.
                log4(
                    0, // Start of data (0, since no data).
                    0, // End of data (0, since no data).
                    _TRANSFER_EVENT_SIGNATURE, // Signature.
                    0, // `address(0)`.
                    toMasked, // `to`.
                    startTokenId // `tokenId`.
                )

                for {
                    let tokenId := add(startTokenId, 1)
                } iszero(eq(tokenId, end)) {
                    tokenId := add(tokenId, 1)
                } {
                    // Emit the `Transfer` event. Similar to above.
                    log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
                }
            }
            if (toMasked == 0) revert MintToZeroAddress();

            _currentIndex = end;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * This function is intended for efficient minting only during contract creation.
     *
     * It emits only one {ConsecutiveTransfer} as defined in
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
     * instead of a sequence of {Transfer} event(s).
     *
     * Calling this function outside of contract creation WILL make your contract
     * non-compliant with the ERC721 standard.
     * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
     * {ConsecutiveTransfer} event is only permissible during contract creation.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {ConsecutiveTransfer} event.
     */
    function _mintERC2309(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();
        if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are unrealistic due to the above check for `quantity` to be below the limit.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);

            _currentIndex = startTokenId + quantity;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Safely mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
     * - `quantity` must be greater than 0.
     *
     * See {_mint}.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal virtual {
        _mint(to, quantity);

        unchecked {
            if (to.code.length != 0) {
                uint256 end = _currentIndex;
                uint256 index = end - quantity;
                do {
                    if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
                        revert TransferToNonERC721ReceiverImplementer();
                    }
                } while (index < end);
                // Reentrancy protection.
                if (_currentIndex != end) revert();
            }
        }
    }

    /**
     * @dev Equivalent to `_safeMint(to, quantity, '')`.
     */
    function _safeMint(address to, uint256 quantity) internal virtual {
        _safeMint(to, quantity, '');
    }

    // =============================================================
    //                        BURN OPERATIONS
    // =============================================================

    /**
     * @dev Equivalent to `_burn(tokenId, false)`.
     */
    function _burn(uint256 tokenId) internal virtual {
        _burn(tokenId, false);
    }

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

        address from = address(uint160(prevOwnershipPacked));

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        if (approvalCheck) {
            // The nested ifs save around 20+ gas over a compound boolean condition.
            if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
                if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
        }

        _beforeTokenTransfers(from, address(0), tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // Updates:
            // - `balance -= 1`.
            // - `numberBurned += 1`.
            //
            // We can directly decrement the balance, and increment the number burned.
            // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
            _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;

            // Updates:
            // - `address` to the last owner.
            // - `startTimestamp` to the timestamp of burning.
            // - `burned` to `true`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                from,
                (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, address(0), tokenId);
        _afterTokenTransfers(from, address(0), tokenId, 1);

        // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
        unchecked {
            _burnCounter++;
        }
    }

    // =============================================================
    //                     EXTRA DATA OPERATIONS
    // =============================================================

    /**
     * @dev Directly sets the extra data for the ownership data `index`.
     */
    function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
        uint256 packed = _packedOwnerships[index];
        if (packed == 0) revert OwnershipNotInitializedForExtraData();
        uint256 extraDataCasted;
        // Cast `extraData` with assembly to avoid redundant masking.
        assembly {
            extraDataCasted := extraData
        }
        packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
        _packedOwnerships[index] = packed;
    }

    /**
     * @dev Called during each token transfer to set the 24bit `extraData` field.
     * Intended to be overridden by the cosumer contract.
     *
     * `previousExtraData` - the value of `extraData` before transfer.
     *
     * 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, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _extraData(
        address from,
        address to,
        uint24 previousExtraData
    ) internal view virtual returns (uint24) {}

    /**
     * @dev Returns the next extra data for the packed ownership data.
     * The returned result is shifted into position.
     */
    function _nextExtraData(
        address from,
        address to,
        uint256 prevOwnershipPacked
    ) private view returns (uint256) {
        uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
        return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
    }

    // =============================================================
    //                       OTHER OPERATIONS
    // =============================================================

    /**
     * @dev Returns the message sender (defaults to `msg.sender`).
     *
     * If you are writing GSN compatible contracts, you need to override this function.
     */
    function _msgSenderERC721A() internal view virtual returns (address) {
        return msg.sender;
    }

    /**
     * @dev Converts a uint256 to its ASCII string decimal representation.
     */
    function _toString(uint256 value) internal pure virtual returns (string memory str) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit),
            // but we allocate 0x80 bytes to keep the free memory pointer 32-byte word aliged.
            // We will need 1 32-byte word to store the length,
            // and 3 32-byte words to store a maximum of 78 digits. Total: 0x20 + 3 * 0x20 = 0x80.
            str := add(mload(0x40), 0x80)
            // Update the free memory pointer to allocate.
            mstore(0x40, str)

            // Cache the end of the memory to calculate the length later.
            let end := str

            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            // prettier-ignore
            for { let temp := value } 1 {} {
                str := sub(str, 1)
                // Write the character to the pointer.
                // The ASCII index of the '0' character is 48.
                mstore8(str, add(48, mod(temp, 10)))
                // Keep dividing `temp` until zero.
                temp := div(temp, 10)
                // prettier-ignore
                if iszero(temp) { break }
            }

            let length := sub(end, str)
            // Move the pointer 32 bytes leftwards to make room for the length.
            str := sub(str, 0x20)
            // Store the length.
            mstore(str, length)
        }
    }
}

File 23 of 33 : MerkleProof.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the merkle tree could be reinterpreted as a leaf value.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Calldata version of {verify}
     *
     * _Available since v4.7._
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leafs & pre-images are assumed to be sorted.
     *
     * _Available since v4.4._
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Calldata version of {processProof}
     *
     * _Available since v4.7._
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = _hashPair(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be proved to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * _Available since v4.7._
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Calldata version of {multiProofVerify}
     *
     * _Available since v4.7._
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and the sibling nodes in `proof`,
     * consuming from one or the other at each step according to the instructions given by
     * `proofFlags`.
     *
     * _Available since v4.7._
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Calldata version of {processMultiProof}
     *
     * _Available since v4.7._
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 totalHashes = proofFlags.length;

        // Check proof validity.
        require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](totalHashes);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < totalHashes; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
            hashes[i] = _hashPair(a, b);
        }

        if (totalHashes > 0) {
            return hashes[totalHashes - 1];
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
    }

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        /// @solidity memory-safe-assembly
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

File 24 of 33 : IEthKunRenderer.sol
// SPDX-License-Identifier: MIT
// coded by @eddietree

pragma solidity ^0.8.0;

interface IEthKunRenderer{
  function getSVG(uint256 seed, uint256 level) external view returns (string memory);
  function getUnrevealedSVG(uint256 seed) external view returns (string memory);
  function getTraitsMetadata(uint256 seed) external view returns (string memory);
}

File 25 of 33 : EthKunRenderer.sol
// SPDX-License-Identifier: MIT
// coded by @eddietree

pragma solidity ^0.8.0;

import 'base64-sol/base64.sol';
import "./IEthKunRenderer.sol";
import "./EthKunData.sol";

contract EthKunRenderer is IEthKunRenderer, EthKunData {

  string[] public bgPaletteColors = [
     'ffffff', 'fdf8db', 'fdeddb', 'fee5e0', 'feddec', 'feddf5', 'f7defe', 'ecddfe', 'dfdbfe', 'e1edfe', 'e4fafe', 'dffef3', 'dffee1', '122026'
  ];

  string[] public bodyColors = [
    '80b0bb','56b7e9','e1624a','85ae36',
    'e7b509','f6b099','85ae36','de953a',
    '56b7e9','dd5bca','80b0bb','56b7e9',
    'e1624a','85ae36','debb45', 'f6b099'
  ];
  
  struct CharacterData {
    uint background;

    uint body;
    uint eyes;
    uint mouth;
  }

  function getSVG(uint256 seed, uint256 level) external view returns (string memory) {
    return _getSVG(seed, level);
  }

  function _getSVG(uint256 seed, uint256 level) internal view returns (string memory) {
    CharacterData memory data = _generateCharacterData(seed);

    // clamp to max
    uint256 levelIndex = level;
    if (levelIndex > levels.length) 
    {
      levelIndex = levels.length;
    }
    levelIndex = levelIndex-1;// map from [1,32]->[0,31]

    string memory image = string(abi.encodePacked(
      '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" shape-rendering="crispEdges" width="512" height="512">'
      '<rect width="100%" height="100%" fill="#', bgPaletteColors[data.background], '"/>',
      //_renderRects(levels[levelIndex], fullPalettes),
      _renderRectsSingleColor(levels[levelIndex], fullPalettes, bodyColors[data.body]),
      //_renderRectsSingleColor(levels[seed % (levels.length)], fullPalettes, bodyColors[data.body]),
      _renderRects(bodies[data.body], fullPalettes),
      _renderRects(mouths[data.mouth], fullPalettes),
      _renderRects(eyes[data.eyes], fullPalettes),
      '</svg>'
    ));

    return image;
  }

  function getUnrevealedSVG(uint256 seed) external view returns (string memory) {
    return _getUnrevealedSVG(seed);
  }

  function _getUnrevealedSVG(uint256) internal view returns (string memory) {
    //CharacterData memory data = _generateCharacterData(seed);

    string memory image = string(abi.encodePacked(
      '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" shape-rendering="crispEdges" width="512" height="512">'
      //'<rect width="100%" height="100%" fill="#', bgPaletteColors[data.background], '"/>',
      '<rect width="100%" height="100%" fill="#122026"/>',
      _renderRects(misc[0], fullPalettes),
      '</svg>'
    ));

    return image;
  }

  function getTraitsMetadata(uint256 seed) external view returns (string memory) {
    return _getTraitsMetadata(seed);
  }

  function _getTraitsMetadata(uint256 seed) internal view returns (string memory) {
    CharacterData memory data = _generateCharacterData(seed);

    // just for backgrounds
    string[15] memory lookup = [
      '0', '1', '2', '3', '4', '5', '6', '7',
      '8', '9', '10', '11', '12', '13', '14'
    ];

    string memory metadata = string(abi.encodePacked(
      '{"trait_type":"Background", "value":"', lookup[data.background+1], '"},',
      '{"trait_type":"Body", "value":"', bodies_traits[data.body], '"},',
      '{"trait_type":"Eyes", "value":"', eyes_traits[data.eyes], '"},',
      '{"trait_type":"Mouth", "value":"', mouths_traits[data.mouth], '"},'
    ));

    return metadata;
  }

  function _renderRects(bytes memory data, string[] memory palette) private pure returns (string memory) {
    string[33] memory lookup = [
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 
      '10', '11', '12', '13', '14', '15', '16', '17', '18', '19',
      '20', '21', '22', '23', '24', '25', '26', '27', '28', '29',
      '30', '31', '32'
    ];

    string memory rects;
    uint256 drawIndex = 0;

    for (uint256 i = 0; i < data.length; i = i+2) {
      uint8 runLength = uint8(data[i]); // we assume runLength of any non-transparent segment cannot exceed image width (32px)
      uint8 colorIndex = uint8(data[i+1]);

      if (colorIndex != 0) { // transparent
        uint8 x = uint8(drawIndex % 32);
        uint8 y = uint8(drawIndex / 32);
        string memory color = palette[colorIndex];

        rects = string(abi.encodePacked(rects, '<rect width="', lookup[runLength], '" height="1" x="', lookup[x], '" y="', lookup[y], '" fill="#', color, '"/>'));
      }
      drawIndex += runLength;
    }

    return rects;
  }

  function _renderRectsSingleColor(bytes memory data, string[] memory palette, string memory color) private pure returns (string memory) {
    string[33] memory lookup = [
      '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 
      '10', '11', '12', '13', '14', '15', '16', '17', '18', '19',
      '20', '21', '22', '23', '24', '25', '26', '27', '28', '29',
      '30', '31', '32'
    ];

    string memory rects;
    uint256 drawIndex = 0;

    for (uint256 i = 0; i < data.length; i = i+2) {
      uint8 runLength = uint8(data[i]); // we assume runLength of any non-transparent segment cannot exceed image width (32px)
      uint8 colorIndex = uint8(data[i+1]);

      if (colorIndex == 0) { // transparent
      }
      else if (colorIndex==1) { // black - replace color

        uint8 x = uint8(drawIndex % 32);
        uint8 y = uint8(drawIndex / 32);

        rects = string(abi.encodePacked(rects, '<rect width="', lookup[runLength], '" height="1" x="', lookup[x], '" y="', lookup[y], '" fill="#', color, '"/>'));
      }
      else { // any othe rcolor
        uint8 x = uint8(drawIndex % 32);
        uint8 y = uint8(drawIndex / 32);

        rects = string(abi.encodePacked(rects, '<rect width="', lookup[runLength], '" height="1" x="', lookup[x], '" y="', lookup[y], '" fill="#', palette[colorIndex], '"/>'));
      }
      drawIndex += runLength;
    }

    return rects;
  }

  function _generateCharacterData(uint256 seed) private view returns (CharacterData memory) {
    return CharacterData({
      background: seed % bgPaletteColors.length,
      
      body: bodies_indices[(seed/2) % bodies_indices.length],
      eyes: eyes_indices[(seed/3) % eyes_indices.length],
      mouth: mouths_indices[(seed/4) % mouths_indices.length]
    });
  }
}

File 26 of 33 : IERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.2
// Creator: Chiru Labs

pragma solidity ^0.8.4;

/**
 * @dev Interface of ERC721A.
 */
interface IERC721A {
    /**
     * The caller must own the token or be an approved operator.
     */
    error ApprovalCallerNotOwnerNorApproved();

    /**
     * The token does not exist.
     */
    error ApprovalQueryForNonexistentToken();

    /**
     * The caller cannot approve to their own address.
     */
    error ApproveToCaller();

    /**
     * Cannot query the balance for the zero address.
     */
    error BalanceQueryForZeroAddress();

    /**
     * Cannot mint to the zero address.
     */
    error MintToZeroAddress();

    /**
     * The quantity of tokens minted must be more than zero.
     */
    error MintZeroQuantity();

    /**
     * The token does not exist.
     */
    error OwnerQueryForNonexistentToken();

    /**
     * The caller must own the token or be an approved operator.
     */
    error TransferCallerNotOwnerNorApproved();

    /**
     * The token must be owned by `from`.
     */
    error TransferFromIncorrectOwner();

    /**
     * Cannot safely transfer to a contract that does not implement the
     * ERC721Receiver interface.
     */
    error TransferToNonERC721ReceiverImplementer();

    /**
     * Cannot transfer to the zero address.
     */
    error TransferToZeroAddress();

    /**
     * The token does not exist.
     */
    error URIQueryForNonexistentToken();

    /**
     * The `quantity` minted with ERC2309 exceeds the safety limit.
     */
    error MintERC2309QuantityExceedsLimit();

    /**
     * The `extraData` cannot be set on an unintialized ownership slot.
     */
    error OwnershipNotInitializedForExtraData();

    // =============================================================
    //                            STRUCTS
    // =============================================================

    struct TokenOwnership {
        // The address of the owner.
        address addr;
        // Stores the start time of ownership with minimal overhead for tokenomics.
        uint64 startTimestamp;
        // Whether the token has been burned.
        bool burned;
        // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
        uint24 extraData;
    }

    // =============================================================
    //                         TOKEN COUNTERS
    // =============================================================

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() external view returns (uint256);

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    // =============================================================
    //                            IERC721
    // =============================================================

    /**
     * @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,
        bytes calldata data
    ) external;

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` 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 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 the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

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

    // =============================================================
    //                           IERC2309
    // =============================================================

    /**
     * @dev Emitted when tokens in `fromTokenId` to `toTokenId`
     * (inclusive) is transferred from `from` to `to`, as defined in the
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
     *
     * See {_mintERC2309} for more details.
     */
    event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}

File 27 of 33 : EthKunData.sol
// SPDX-License-Identifier: MIT
// AUTOGENERATED FILE by @eddietree on Mon Sep 05 2022 16:40:03 GMT-0700 (Pacific Daylight Time)

pragma solidity ^0.8.0;

contract EthKunData {
	string[] public fullPalettes = ['ff00ff', '000000', 'ffffff', 'ff0000', '00ff00', '0000ff', '1e2528', 'eadece', 'ea6a6a', '80b0bb', '7991a1', 'e1624a', 'cb4227', '56b7e9', '3a88de', '85ae36', '509434', 'e7b509', 'da7e0d', 'f6b099', 'e37d74', 'de953a', 'c36c2d', 'efc567', 'f9dea3', 'e6b64d', '6ddeee', 'fdd3f6', '9ce5de', '276cd7', 'ed8dde', 'be3ccd', 'e56dd3', 'f7baee', 'dd5bca', '9035b4', 'debb45', 'ac622d', '813c22', '211d1a', '979fa1', '6b757d', 'fefefe'];

	///////////////////////////////////////
	// eyes
	bytes[] public eyes = [
		bytes(hex'ff00ff000f00010604000106'),
		bytes(hex'ff00ee00010604000106'),
		bytes(hex'ff008e00010604000106'),
		bytes(hex'ff002f00010602000106'),
		bytes(hex'ff00ce00020602000206'),
		bytes(hex'ff006e00020602000206'),
		bytes(hex'ff00cd000206040002061900020602000206'),
		bytes(hex'ff008d000206040002061900020602000206'),
		bytes(hex'ff00ad0002060400020619000206020002061a00010604000106'),
		bytes(hex'ff00ec0001060200010602000106020001061700020604000206'),
		bytes(hex'ff00cd0002060400020617000106020001060200010602000106'),
		bytes(hex'ff00ce000106040001061b00010602000106'),
		bytes(hex'ff006e000106040001061b00010602000106'),
		bytes(hex'ff00cf000106020001061b00010604000106'),
		bytes(hex'ff004f000106020001061b00010604000106'),
		bytes(hex'ff00ce000106040001061a00010604000106'),
		bytes(hex'ff006e000106040001061a00010604000106'),
		bytes(hex'ff00cd000206040002061900010604000106'),
		bytes(hex'ff00cd000306020003061900010604000106'),
		bytes(hex'ff00ad0003060200030619000206020002063a00020602000206'),
		bytes(hex'ff006d00020604000206180003060200030619000206020002063a00010604000106'),
		bytes(hex'ff00ac00040602000406140003060207040602070306140001060207010602000106020701061700020604000206'),
		bytes(hex'ff00ac0004060200040614000e0614000406020004061700020604000206'),
		bytes(hex'ff008c00030604000306150005060200050614000c0614000506020005061500030604000306'),
		bytes(hex'ff00cd000206040002061700010608000106'),
		bytes(hex'ff008c00020620000206030002061b00060617000206030006061b000206'),
		bytes(hex'ff00ec00010608000106'),
		bytes(hex'ff00ad000206040002061700020601070106020002060107010616000406020004061700020604000206'),
		bytes(hex'ff004d000206040002061700020601070106020002060107010616000406020004061700020604000206'),
		bytes(hex'ff00ad0003060200030638000107010601070200010701060107'),
		bytes(hex'ff004d0003060200030638000107010601070200010701060107'),
		bytes(hex'ff00ad00020604000206190002060200020619000107010601070200010701060107'),
		bytes(hex'ff004d00020604000206190002060200020619000107010601070200010701060107'),
		bytes(hex'ff00ad00020604000206170003070106020001060307160001070206010702000107020601071700020704000207'),
		bytes(hex'ff00ad000207040002071700040702000407160002070106010702000107010602071700020704000207'),
		bytes(hex'ff00cd00020704000207180001070106040001060107'),
		bytes(hex'ff006d00020704000207180001070106040001060107'),
		bytes(hex'ff00cd00030602000306180002070106020001060207180002070106020001060207'),
		bytes(hex'ff008d00030602000306180002070106020001060207180002070106020001060207'),
		bytes(hex'ff00d30002071700040602000107020601071d000207'),
		bytes(hex'ff00ee0001060400010619000208040002081800020804000208'),
		bytes(hex'ff00ac00040602000406140003060207040602070306140001060207010602000106020701061700020604000206160001080100010806000108010001083500010808000108'),
		bytes(hex'ff00ac0003070400030715000107030601070200010703060107140001070306010702000107030601071500030704000307'),
		bytes(hex'ff008e000206020002061900010606000106390001070106020001070106'),
		bytes(hex'ff00ad00030602000306180001070106010702000107010601071900010704000107'),
		bytes(hex'ff00cd00080617000a061800010604000106'),
		bytes(hex'ff004f000106020001061a0002060400020618000207040002071700020702060200020702061600020702060200020702061700020704000207'),
		bytes(hex'ff006d000306020003061700020602070200020702061600010601070206020002060107010615000208010702060200020601070208130004080600040812000408060004081300020808000208'),
		bytes(hex'ff00cd000206040002061700020606000206'),
		bytes(hex'ff008e00020602000206190003060200030618000206040002061a00010602000106')
	];

	string[] public eyes_traits = [
		'Vacant Low',
		'Vacant Medium',
		'Vacant High',
		'Vacant Too High',
		'Sleepy',
		'Sleepy High',
		'Angry',
		'Angry High',
		'Hero',
		'Somber',
		'Happy',
		'Slant',
		'Slant High',
		'Inverse',
		'Inverse High',
		'Cartoon',
		'Cartoon High',
		'Pensive',
		'Judgmental',
		'Dad',
		'Mad Dad',
		'Glasses',
		'Sunglasses',
		'Beeg Sunglasses',
		'Tired',
		'Pirate',
		'Dumb',
		'Animal',
		'Animal High',
		'Unsettling',
		'Unsettling High',
		'Villain',
		'Villain High',
		'Froggish',
		'Wide',
		'Beady',
		'Beady High',
		'JRPG',
		'JRPG High',
		'Wink',
		'Shy',
		'Nerd',
		'Stoned',
		'Sus',
		'Grump',
		'Unibrow',
		'Terrified',
		'Blushing',
		'Ambivalent',
		'Trustworthy'
	];

	uint8[] public eyes_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49];

	///////////////////////////////////////
	// mouths
	bytes[] public mouths = [
		bytes(hex'ff00ff0051000206'),
		bytes(hex'ff00ff0091000206'),
		bytes(hex'ff00ff0050000406'),
		bytes(hex'ff00ff0090000406'),
		bytes(hex'ff00ff0050000106020001061d000206'),
		bytes(hex'ff00ff00510002061d00010602000106'),
		bytes(hex'ff00ff004e0001060600010619000606'),
		bytes(hex'ff00ff004f0006061900010606000106'),
		bytes(hex'ff00ff006e0001060100010601000106010001061a000106010001060100010601000106'),
		bytes(hex'ff00ff00510002061e000206'),
		bytes(hex'ff00ff00910002061e000206'),
		bytes(hex'ff00ff00510002061d0004061c000406'),
		bytes(hex'ff00ff00500004061c0004061d000206'),
		bytes(hex'ff00ff00500004061b0006061a00020602000206'),
		bytes(hex'ff00ff004f000206020002061a0006061b000406'),
		bytes(hex'ff00ff004f0006061b000406'),
		bytes(hex'ff00ff004e0001060100040601000106180008061900020602000206'),
		bytes(hex'ff00ff00500004061b000106040701061a0006061b000406'),
		bytes(hex'ff00ff00530001061c0004061f000106'),
		bytes(hex'ff00ff0050000106020001061c0004061c00010602000106'),
		bytes(hex'ff00ff00540001061a0006061f000106'),
		bytes(hex'ff00ff004f000106040001061a0006061a00010604000106'),
		bytes(hex'ff00ff004f000106050001061a0005061b00010603000106'),
		bytes(hex'ff00ff004f00060619000106030701060207010619000606'),
		bytes(hex'ff00ff00510002061c000206020002061900010606000106'),
		bytes(hex'ff00ff005000010620000206'),
		bytes(hex'ff00ff00530001061d000206'),
		bytes(hex'ff00ff00720001061e000106'),
		bytes(hex'ff00ff00510002061d000106020001061c00010602000106'),
		bytes(hex'ff00ff006d000a06'),
		bytes(hex'ff00ff00510002061c00020602000206'),
		bytes(hex'ff00ff004f00020602000206190001060200020602000106'),
		bytes(hex'ff00ff006c0003060600030617000606'),
		bytes(hex'ff00ff0050000106020001061c000106020001061d000206'),
		bytes(hex'ff00ff006e00010602000206020001061900020602000206'),
		bytes(hex'ff00ff00520003061a00030601070106010701061c000306'),
		bytes(hex'ff00ff006e00020601070206010702061a000406'),
		bytes(hex'ff00ff0070000206010701061d000206'),
		bytes(hex'ff00ff00510002061d0004061c0004061d000206'),
		bytes(hex'ff00ff00300004061b0006061a0006061a0006061b000406'),
		bytes(hex'ff00ff0071000106'),
		bytes(hex'ff00ff0073000106'),
		bytes(hex'ff00ff006f00010620000206'),
		bytes(hex'ff00ff00740002061d000106'),
		bytes(hex'ff00ff00510002061d000106020001061c000106020001061d000206'),
		bytes(hex'ff00ff00700004061b000606'),
		bytes(hex'ff00ff006f00010620000206'),
		bytes(hex'ff00ff004d0001060800010616000a06'),
		bytes(hex'ff00ff0052000106200001061e000106200001061e000106'),
		bytes(hex'ff00ff006f000106040701061b0004061d000207')
	];

	string[] public mouths_traits = [
		'Smol',
		'Smol Low',
		'Normal',
		'Normal Low',
		'Smile',
		'Frown',
		'Wide Smile',
		'Wide Frown',
		'Cursed',
		'Oh',
		'Oh Low',
		'Yell',
		'Announce',
		'Shriek',
		'Address',
		'Naive',
		'Gentleman',
		'Teethy Yell',
		'Acorn',
		'Two Acorns',
		'Chewing',
		'Chomping',
		'Bubblecheeks',
		'Tyson',
		'Froggish',
		'Smirk',
		'Antismirk',
		'Hmm',
		'Unhappy',
		'Mostly Mouth',
		'Chewing Lip',
		'Wavy',
		'Burger',
		'Cute',
		'Cat',
		'Half Shell',
		'Vamp',
		'Scamp',
		'O',
		'OOO',
		'Peck',
		'Dot',
		'Side Smirk',
		'Determined',
		'Outline',
		'Regret',
		'Too Happy',
		'Bracket',
		'Smooch',
		'Car Salesman'
	];

	uint8[] public mouths_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49];

	///////////////////////////////////////
	// bodies
	bytes[] public bodies = [
		bytes(hex'6f000109010a1e000109010a1d000209020a1c000209020a1b000309030a1a000309030a19000409040a18000409040a17000509050a16000509050a15000609060a14000609060a13000709070a12000709070a11000809080a10000809080a0f000909090a10000709070a1000020902000509050a0200020a0f00030902000309030a0200030a1100040902000109010a0200040a130005090200050a15000509050a17000409040a19000309030a1b000209020a1d000109010a'),
		bytes(hex'6f00010d010e1e00010d010e1d00020d020e1c00020d020e1b00030d030e1a00030d030e1900040d040e1800040d040e1700050d050e1600050d050e1500060d060e1400060d060e1300070d070e1200070d070e1100080d080e1000080d080e0f00090d090e1000070d070e1000020d0200050d050e0200020e0f00030d0200030d030e0200030e1100040d0200010d010e0200040e1300050d0200050e1500050d050e1700040d040e1900030d030e1b00020d020e1d00010d010e'),
		bytes(hex'6f00010b010c1e00010b010c1d00020b020c1c00020b020c1b00030b030c1a00030b030c1900040b040c1800040b040c1700050b050c1600050b050c1500060b060c1400060b060c1300070b070c1200070b070c1100080b080c1000080b080c0f00090b090c1000070b070c1000020b0200050b050c0200020c0f00030b0200030b030c0200030c1100040b0200010b010c0200040c1300050b0200050c1500050b050c1700040b040c1900030b030c1b00020b020c1d00010b010c'),
		bytes(hex'6f00010f01101e00010f01101d00020f02101c00020f02101b00030f03101a00030f03101900040f04101800040f04101700050f05101600050f05101500060f06101400060f06101300070f07101200070f07101100080f08101000080f08100f00090f09101000070f07101000020f0200050f0510020002100f00030f0200030f0310020003101100040f0200010f0110020004101300050f020005101500050f05101700040f04101900030f03101b00020f02101d00010f0110'),
		bytes(hex'6f00011101121e00011101121d00021102121c00021102121b00031103121a00031103121900041104121800041104121700051105121600051105121500061106121400061106121300071107121200071107121100081108121000081108120f000911091210000711071210000211020005110512020002120f00031102000311031202000312110004110200011101120200041213000511020005121500051105121700041104121900031103121b00021102121d0001110112'),
		bytes(hex'6f00011301141e00011301141d00021302141c00021302141b00031303141a00031303141900041304141800041304141700051305141600051305141500061306141400061306141300071307141200071307141100081308141000081308140f000913091410000713071410000213020005130514020002140f00031302000313031402000314110004130200011301140200041413000513020005141500051305141700041304141900031303141b00021302141d0001130114'),
		bytes(hex'6f00010f010b1e00010f010b1d00020f020b1c00020f020b1b00030f030b1a00030f030b1900040f040b1800040f040b1700050f050b1600050f050b1500060f060b1400060f060b1300070f070b1200070f070b1100080f080b1000080f080b0f00090f090b1000070f070b1000020e0200050f050b020002150f00030e0200030f030b020003151100040e0200010f010b020004151300050e020005151500050e05151700040e04151900030e03151b00020e02151d00010e0115'),
		bytes(hex'6f0002161e0002161d0001160117011501161c0001160117011501161b0001160217021501161a0001160117021801150116190001160117011502180117011501161800011601170215021701190116170001160117011903150319011616000116011702190315021901161500011601170215021903150219011614000116011703150219031501190116130001160117051502190315011901161200011601170615021903150116110001160117081502190315011610000116011709150219021501160f00011601170b150219021501160e0002160c15021902160e000116011702160a150216011901160f000116021702160615021602190116110001160115021702160215021602190115011613000116021502170216021902150116150001160315021703150116170001160615011619000116041501161b000116021501161d000216'),
		bytes(hex'6f00011a010e1e00011a010e1d00010d011b020e1c00010d011c020e1b00020d011c030e1a00020d011a030e1900030d011a040e1800030d011a040e1700050d050e1600050d050e1500060d060e1400060d060e1300050d010e010d021d050e1200030d030e010d041d030e1100020d050e010d061d020e1000070e010d081d0f00080e010d091d1000060e010d071d1000020e0200040e010d051d0200021d0f00030e0200020e010d031d0200031d1100040e0200010d011d0200041d1300050e0200051d1500040e010d051d1700030e010d041d1900020e010d031d1b00010e010d021d1d00010d011d'),
		bytes(hex'6f00011e011f1e00011e011f1d000120011b021f1c0001200121021f1b0002200121031f1a000220011e031f19000320011e041f180001220220011e041f170003220220051f160004220120051f150005220120061f140005220120061f13000522011f01200223051f12000322031f01200423031f11000222051f01200623021f1000071f012008230f00081f012009231000061f01200723100002220200041f012005230200021f0f0003220200021f012003230200031f110004220200012001230200041f130005220200051f150004220120051f170003220120041f190002220120031f1b0001220120021f1d000120011f'),
		bytes(hex'6f000109010a1e000109010a1d000209020a1c000209020a1b000309030a1a000309030a19000409040a18000409040a17000509050a16000509050a15000609060a14000809040a13000509040a0209030a12000309080a0209010a110002090c0a02091000100a0f00120a10000e0a1000020902000a0a0200020a0f0003090200060a0200030a110004090200020a0200040a130005090200050a15000509050a17000409040a19000309030a1b000209020a1d000109010a'),
		bytes(hex'6f00010d010e1e00010d010e1d00020d020e1c00020d020e1b00030d030e1a00030d030e1900040d040e1800040d040e1700050d050e1600050d050e1500060d060e1400080d040e1300050d040e020d030e1200030d080e020d010e1100020d0c0e020d1000100e0f00120e10000e0e1000020d02000a0e0200020e0f00030d0200060e0200030e1100040d0200020e0200040e1300050d0200050e1500050d050e1700040d040e1900030d030e1b00020d020e1d00010d010e'),
		bytes(hex'6f00010b010c1e00010b010c1d00020b020c1c00020b020c1b00030b030c1a00030b030c1900040b040c1800040b040c1700050b050c1600050b050c1500060b060c1400080b040c1300050b040c020b030c1200030b080c020b010c1100020b0c0c020b1000100c0f00120c10000e0c1000020b02000a0c0200020c0f00030b0200060c0200030c1100040b0200020c0200040c1300050b0200050c1500050b050c1700040b040c1900030b030c1b00020b020c1d00010b010c'),
		bytes(hex'6f00010f01101e00010f01101d00020f02101c00020f02101b00030f03101a00030f03101900040f04101800040f04101700050f05101600050f05101500060f06101400080f04101300050f0410020f03101200030f0810020f01101100020f0c10020f100010100f00121010000e101000020f02000a10020002100f00030f02000610020003101100040f02000210020004101300050f020005101500050f05101700040f04101900030f03101b00020f02101d00010f0110'),
		bytes(hex'6f00012401151e00012401151d00022402151c00022402151b00032403151a00032403151900042404151800042404151700052405151600052405151500062406151400082404151300052404150224031512000324081502240115110002240c150224100010150f00121510000e151000022402000a15020002150f000324020006150200031511000424020002150200041513000524020005151500052405151700042404151900032403151b00022402151d0001240115'),
		bytes(hex'6f00011301141e00011301141d00021302141c00021302141b00031303141a00031303141900041304141800041304141700051305141600051305141500061306141400081304141300051304140213031412000313081402130114110002130c140213100010140f00121410000e141000021302000a14020002140f000313020006140200031411000413020002140200041413000513020005141500051305141700041304141900031303141b00021302141d0001130114')
	];

	string[] public bodies_traits = [
		'Dull',
		'Cool',
		'Hot',
		'Envy',
		'Sand',
		'Flesh',
		'Web2',
		'Gold',
		'Sapphire',
		'Amethyst',
		'Duller',
		'Cooler',
		'Hotter',
		'Jealous',
		'Sandier',
		'Fleshier'
	];

	uint8[] public bodies_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];

	///////////////////////////////////////
	// levels
	bytes[] public levels = [
		bytes(hex'2e0004011c000101020001011b000101040001011a000101040001011900010106000101180001010600010117000101080001011600010108000101150001010a000101140001010a000101130001010c000101120001010c000101110001010e000101100001010e0001010f000101100001010e000101100001010d000101120001010c000101120001010b000101140001010a000101140001010a000101140001010b000101120001010d000101100001010f0001010e000101110001010c000101130001010a0001011500010108000101170001010600010119000101040001011b000101020001011d000201'),
		bytes(hex'0e0004011b0006011a00020102000201190002010400020118000201040002011700020106000201160002010600020115000201080002011400020108000201130002010a000201120002010a000201110002010c000201100002010c0002010f0002010e0002010e0002010e0002010d000201100002010c000201100002010b000201120002010a0002011200020109000201140002010800020114000201080002011400020109000201120002010b000201100002010d0002010e0002010f0002010c000201110002010a00020113000201080002011500020106000201170002010400020119000201020002011b000401'),
		bytes(hex'0d000601190008011800030102000301170003010400030116000301040003011500030106000301140003010600030113000301080003011200030108000301110003010a000301100003010a0003010f0003010c0003010e0003010c0003010d0003010e0003010c0003010e0003010b000301100003010a0003011000030109000301120003010800030112000301070003011400030106000301140003010600030114000301070003011200030109000301100003010b0003010e0003010d0003010c0003010f0003010a000301110003010800030113000301060003011500030104000301170003010200030119000601'),
		bytes(hex'0c00080117000a0116000401020004011500040104000401140004010400040113000401060004011200040106000401110004010800040110000401080004010f0004010a0004010e0004010a0004010d0004010c0004010c0004010c0004010b0004010e0004010a0004010e000401090004011000040108000401100004010700040112000401060004011200040105000401140004010400040114000401040004011400040105000401120004010700040110000401090004010e0004010b0004010c0004010d0004010a0004010f0004010800040111000401060004011300040104000401150004010200040117000801'),
		bytes(hex'0b000a0115000c01140005010200050113000501040005011200050104000501110005010600050110000501060005010f000501080005010e000501080005010d0005010a0005010c0005010a0005010b0005010c0005010a0005010c000501090005010e000501080005010e000501070005011000050106000501100005010500050112000501040005011200050103000501140005010200050114000501020005011400050103000501120005010500050110000501070005010e000501090005010c0005010b0005010a0005010d000501080005010f000501060005011100050104000501130005010200050115000a01'),
		bytes(hex'0a000c0113000e011200060102000601110006010400060110000601040006010f000601060006010e000601060006010d000601080006010c000601080006010b0006010a0006010a0006010a000601090006010c000601080006010c000601070006010e000601060006010e00060105000601100006010400060110000601030006011200060102000601120006010100060114000601060114000601060114000601000101000601120006010300060110000601050006010e000601070006010c000601090006010a0006010b000601080006010d000601060006010f00060104000601110006010200060113000c01'),
		bytes(hex'09000e011100100110000701020007010f000701040007010e000701040007010d000701060007010c000701060007010b000701080007010a00070108000701090007010a000701080007010a000701070007010c000701060007010c000701050007010e000701040007010e00070103000701100007010200070110000701010007011200070107011200070106011400060106011400060106011400060107011200070100010100070110000701030007010e000701050007010c000701070007010a00070109000701080007010b000701060007010d000701040007010f0007010200070111000e01'),
		bytes(hex'080010010f0012010e000801020008010d000801040008010c000801040008010b000801060008010a0008010600080109000801080008010800080108000801070008010a000801060008010a000801050008010c000801040008010c000801030008010e000801020008010e00080101000801100008010801100008010701120007010701120007010601140006010601140006010601140006010701120007010801100008010001010008010e000801030008010c000801050008010a000801070008010800080109000801060008010b000801040008010d000801020008010f001001'),
		bytes(hex'070012010d0014010c000901020009010b000901040009010a000901040009010900090106000901080009010600090107000901080009010600090108000901050009010a000901040009010a000901030009010c000901020009010c000901010009010e00090109010e00090108011000080108011000080107011200070107011200070106011400060106011400060106011400060107011200070108011000080109010e0009010001010009010c000901030009010a0009010500090108000901070009010600090109000901040009010b000901020009010d001201'),
		bytes(hex'060014010b0016010a000a0102000a0109000a0104000a0108000a0104000a0107000a0106000a0106000a0106000a0105000a0108000a0104000a0108000a0103000a010a000a0102000a010a000a0101000a010c000a010a010c000a0109010e00090109010e00090108011000080108011000080107011200070107011200070106011400060106011400060106011400060107011200070108011000080109010e0009010a010c000a01000101000a010a000a0103000a0108000a0105000a0106000a0107000a0104000a0109000a0102000a010b001401'),
		bytes(hex'050016010900180108000b0102000b0107000b0104000b0106000b0104000b0105000b0106000b0104000b0106000b0103000b0108000b0102000b0108000b0101000b010a000b010b010a000b010a010c000a010a010c000a0109010e00090109010e00090108011000080108011000080107011200070107011200070106011400060106011400060106011400060107011200070108011000080109010e0009010a010c000a010b010a000b01000101000b0108000b0103000b0106000b0105000b0104000b0107000b0102000b0109001601'),
		bytes(hex'0400180107001a0106000c0102000c0105000c0104000c0104000c0104000c0103000c0106000c0102000c0106000c0101000c0108000c010c0108000c010b010a000b010b010a000b010a010c000a010a010c000a0109010e00090109010e00090108011000080108011000080107011200070107011200070106011400060106011400060106011400060107011200070108011000080109010e0009010a010c000a010b010a000b010c0108000c01000101000c0106000c0103000c0104000c0105000c0102000c0107001801'),
		bytes(hex'03001a0105001c0104000d0102000d0103000d0104000d0102000d0104000d0101000d0106000d010d0106000d010c0108000c010c0108000c010b010a000b010b010a000b010a010c000a010a010c000a0109010e00090109010e00090108011000080108011000080107011200070107011200070106011400060106011400060106011400060107011200070108011000080109010e0009010a010c000a010b010a000b010c0108000c010d0106000d01000101000d0104000d0103000d0102000d0105001a01'),
		bytes(hex'02001c0103001e0102000e0102000e0101000e0104000e010e0104000e010d0106000d010d0106000d010c0108000c010c0108000c010b010a000b010b010a000b010a010c000a010a010c000a0109010e00090109010e00090108011000080108011000080107011200070107011200070106011400060106011400060106011400060107011200070108011000080109010e0009010a010c000a010b010a000b010c0108000c010d0106000d010e0104000e01000101000e0102000e0103001c01'),
		bytes(hex'01001e01010020010f0102000f010e0104000e010e0104000e010d0106000d010d0106000d010c0108000c010c0108000c010b010a000b010b010a000b010a010c000a010a010c000a0109010e00090109010e00090108011000080108011000080107011200070107011200070106011400060106011400060106011400060107011200070108011000080109010e0009010a010c000a010b010a000b010c0108000c010d0106000d010e0104000e010f0102000f01000101001e01'),
		bytes(hex'200120010f0102000f010e0104000e010e0104000e010d0106000d010d0106000d010c0108000c010c0108000c010b010a000b010b010a000b010a010c000a010a010c000a0109010e00090109010e00090108011000080108011000080107011200070107011200070106011400060106011400060106011400060107011200070108011000080109010e0009010a010c000a010b010a000b010c0108000c010d0106000d010e0104000e010f0102000f0120010001'),
		bytes(hex'0e0104000e010d010100040101000d010d01010001010200010101000d010c01010001010400010101000c010c01010001010400010101000c010b01010001010600010101000b010b01010001010600010101000b010a01010001010800010101000a010a01010001010800010101000a010901010001010a000101010009010901010001010a000101010009010801010001010c000101010008010801010001010c000101010008010701010001010e000101010007010701010001010e000101010007010601010001011000010101000601060101000101100001010100060105010100010112000101010005010501010001011200010101000501040101000101140001010100040104010100010114000101010004010401010001011400010101000401050101000101120001010100050106010100010110000101010006010701010001010e000101010007010801010001010c000101010008010901010001010a000101010009010a01010001010800010101000a010b01010001010600010101000b010c01010001010400010101000c010d01010001010200010101000d010e010100020101000e010001'),
		bytes(hex'0c01010001010400010101000c010b0101000101010004010100010101000b010b010100010101000101020001010100010101000b010a010100010101000101040001010100010101000a010a010100010101000101040001010100010101000a0109010100010101000101060001010100010101000901090101000101010001010600010101000101010009010801010001010100010108000101010001010100080108010100010101000101080001010100010101000801070101000101010001010a0001010100010101000701070101000101010001010a0001010100010101000701060101000101010001010c0001010100010101000601060101000101010001010c0001010100010101000601050101000101010001010e0001010100010101000501050101000101010001010e0001010100010101000501040101000101010001011000010101000101010004010401010001010100010110000101010001010100040103010100010101000101120001010100010101000301030101000101010001011200010101000101010003010201010001010100010114000101010001010100020102010100010101000101140001010100010101000201020101000101010001011400010101000101010002010301010001010100010112000101010001010100030104010100010101000101100001010100010101000401050101000101010001010e0001010100010101000501060101000101010001010c0001010100010101000601070101000101010001010a000101010001010100070108010100010101000101080001010100010101000801090101000101010001010600010101000101010009010a010100010101000101040001010100010101000a010b010100010101000101020001010100010101000b010c0101000101010002010100010101000c010001'),
		bytes(hex'0a010100010101000101040001010100010101000a01090101000101010001010100040101000101010001010100090109010100010101000101010001010200010101000101010001010100090108010100010101000101010001010400010101000101010001010100080108010100010101000101010001010400010101000101010001010100080107010100010101000101010001010600010101000101010001010100070107010100010101000101010001010600010101000101010001010100070106010100010101000101010001010800010101000101010001010100060106010100010101000101010001010800010101000101010001010100060105010100010101000101010001010a00010101000101010001010100050105010100010101000101010001010a00010101000101010001010100050104010100010101000101010001010c00010101000101010001010100040104010100010101000101010001010c00010101000101010001010100040103010100010101000101010001010e00010101000101010001010100030103010100010101000101010001010e0001010100010101000101010003010201010001010100010101000101100001010100010101000101010002010201010001010100010101000101100001010100010101000101010002010101010001010100010101000101120001010100010101000101010001010101010001010100010101000101120001010100010101000101010001010001010001010100010101000101140001010100010101000101020001010100010101000101140001010100010101000101020001010100010101000101140001010100010101000101010001010100010101000101010001011200010101000101010001010100010102010100010101000101010001011000010101000101010001010100020103010100010101000101010001010e00010101000101010001010100030104010100010101000101010001010c00010101000101010001010100040105010100010101000101010001010a0001010100010101000101010005010601010001010100010101000101080001010100010101000101010006010701010001010100010101000101060001010100010101000101010007010801010001010100010101000101040001010100010101000101010008010901010001010100010101000101020001010100010101000101010009010a01010001010100010101000201010001010100010101000a010001'),
		bytes(hex'05010300030103000401030003010300050105010200040102000601020004010200050104010300030103000201020002010300030103000401040102000401020002010400020102000401020004010301030003010300020104000201030003010300030103010200040102000201060002010200040102000301020103000301030002010600020103000301030002010201020004010200020108000201020004010200020101010300030103000201080002010300030103000101010102000401020002010a0002010200040102000101000103000301030002010a0002010300030105000401020002010c0002010200040104000301030002010c0002010300030103000401020002010e0002010200040102000301030002010e0002010300030101000401020002011000020102000401030103000201100002010300030103010200020112000201020003010201030002011200020103000201020102000201140002010200020101010300020114000201030001010101030002011400020103000101020103000201120002010300020103010300020110000201030003010401030002010e00020103000401000101000401030002010c0002010300040103000401030002010a000201030004010500040103000201080002010300040103000101030004010300020106000201030004010300010102010300040103000201040002010300040103000201030103000401030002010200020104000301030003010401030004010300040104000301030004010001'),
		bytes(hex'080103000a0103000801070104000a010400070107010300050102000501030007010601040004010400040104000601060103000501040005010300060105010400040106000401040005010501030005010600050103000501040104000401080004010400040104010300050108000501030004010301040004010a000401040003010301030005010a000501030003010201040004010c000401040002010201030005010c000501030002010101040004010e000401040001010101030005010e000501030001010001040004011000040107000501100005010600040112000401050005011200050104000401140004010300050114000501020005011400050103000501120005010500050110000501070005010e000501090005010c00050105000101050005010a000501050001010201050005010800050105000201030105000501060005010500030104010500050104000501050004010501050005010200050105000501060105000a01050006010001'),
		bytes(hex'05010400010104000401040001010400050105010300010104000601040001010300050104010400010104000201020002010400010104000401040103000101040002010400020104000101030004010301040001010400020104000201040001010400030103010300010104000201060002010400010103000301020104000101040002010600020104000101040002010201030001010400020108000201040001010300020101010400010104000201080002010400010104000101010103000101040002010a0002010400010103000101000104000101040002010a0002010400010107000101040002010c0002010400010106000101040002010c0002010400010105000101040002010e0002010400010104000101040002010e0002010400010103000101040002011000020104000101020001010400020110000201040001010100010104000201120002010400010101010400020112000201040001010001040002011400020108000201140002010800020114000201090002011200020105000101050002011000020105000101000101000101050002010e0002010500010103000101050002010c0002010500010105000101050002010a000201050001010700010105000201080002010500010104000101040001010500020106000201050001010400010102010400010105000201040002010500010104000201030104000101050002010200020105000101040003010401040001010500040105000101040004010001'),
		bytes(hex'06000101120001010c00010107000401070001010800020101000a0102000a01010002010400010102000901040009010200010106000a0104000a0106000b0106000b0102000d0106000d01000102000a0108000a0104000a0108000a01040009010a000901040009010a000901040008010c000801040008010c000801040007010e000701040007010e000701040006011000060104000601100006010400050112000501040005011200050104000401140004010400040114000401040004011400040104000501120005010400060110000601040007010e00070102000a010c000a010001020009010a00090106000801080008010600010102000801060008010200010104000201010009010400090101000201080001010600020102000201060001010c0001010700040107000101'),
		bytes(hex'06000101120001010c00010107000401070001010800020101000a0102000a01010002010400010102000101070001010400010107000101020001010600020101000701040007010100020106000301010007010600070101000301020003010200080106000801020003010001020001010100080108000801010001010400010101000801080008010100010104000101010007010a0007010100010104000101010007010a0007010100010104000101010006010c0006010100010104000101010006010c0006010100010104000101010005010e0005010100010104000101010005010e0005010100010104000101010004011000040101000101040001010100040110000401010001010400010101000301120003010100010104000101010003011200030101000101040001010100020114000201010001010400010101000201140002010100010104000101010002011400020101000101040001010100030112000301010001010400010101000401100004010100010104000101010005010e0005010100010102000301020005010c00050102000301000102000301010005010a000501010003010600020101000501080005010100020106000101020001010500020106000201050001010200010104000201010009010400090101000201080001010600020102000201060001010c0001010700040107000101'),
		bytes(hex'06000101120001010c00010107000401070001010800020101000a0102000a01010002010400010102000101070001010400010107000101020001010600020101000701040007010100020106000301010007010600070101000301020003010200080106000801020003010001020001010100080108000801010001010400010101000801080008010100010104000101010007010a0007010100010104000101010007010a0007010100010104000101010006010c0006010100010104000101010006010c0006010100010104000101010005010e0005010100010104000101010005010e0005010100010104000101010004011000040101000101040001010100040110000401010001010400010101000301120003010100010104000101010003011200030101000101040001010100020114000201010001010400010101000201140002010100010104000101010002011400020101000101040001010100030112000301010001010400010101000401100004010100010104000101010005010e0005010100010102000301020005010c00050102000301000102000301010005010a000501010003010600020101000501080005010100020106000101020001010500020106000201050001010200010104000201010009010400090101000201080001010600020102000201060001010c0001010700040107000101'),
		bytes(hex'06000101120001010700030102000101070004010700010102000301020001010100010101000a0102000a0101000101010001010200030101000101070001010400010107000101010003010600010101000701040007010100010107000401010006010600060101000401020003010300070106000701030003010001020001010100080108000801010001010400010101000801080008010100010104000101010007010a0007010100010104000101010007010a0007010100010104000101010006010c0006010100010104000101010006010c0006010100010104000101010005010e0005010100010104000101010005010e0005010100010104000101010004011000040101000101040001010100040110000401010001010400010101000301120003010100010104000101010003011200030101000101040001010100020114000201010001010400010101000201140002010100010104000101010002011400020101000101040001010100030112000301010001010400010101000401100004010100010104000101010005010e0005010100010102000301030004010c00040103000301000102000401010004010a0004010100040107000101010005010800050101000101060003010100010105000201060002010500010101000301020001010100010101000901040009010100010101000101020003010200010106000201020002010600010102000301070001010700040107000101'),
		bytes(hex'0500010114000101060003010100010108000401080001010100030102000101010001010200090102000901020001010100010102000501010001010500010104000101050001010100050104000101010001010100070104000701010001010100010103000201010003010100060106000601010003010100020100010200010103000701060007010300010104000a0108000a010400010101000801080008010100010104000101010007010a0007010100010104000101010007010a0007010100010104000101010006010c0006010100010104000101010006010c0006010100010104000101010005010e0005010100010104000101010005010e00050101000101040001010100040110000401010001010400010101000401100004010100010104000101010003011200030101000101040001010100030112000301010001010400010101000201140002010100010104000101010002011400020101000101040001010100020114000201010001010400010101000301120003010100010104000101010004011000040101000101040007010e00070104000101030004010c000401030001010200020101000301010004010a00040101000301010002010001030001010100010101000501080005010100010101000101040005010100010103000201060002010300010101000501020001010100010102000801040008010200010101000101020003010100010107000201020002010700010101000301060001010800040108000101'),
		bytes(hex'05000101140001010600030101000101080004010800010101000301020001010100010102000101060002010200020106000101020001010100010102000501010001010500010104000101050001010100050104000101010001010100070104000701010001010100010103000201010003010100060106000601010003010100020100010200010103000701060007010300010105000901080009010700080108000801080007010a000701080007010a000701080006010c000601080006010c000601080005010e000501080005010e000501080004011000040108000401100004010800030112000301080003011200030108000201140002010800020114000201080002011400020108000301120003010800040110000401070006010e00060105000101030004010c000401030001010200020101000301010004010a000401010003010100020100010300010101000101010005010800050101000101010001010400050101000101030002010600020103000101010005010200010101000101020001010500020104000201050001010200010101000101020003010100010107000201020002010700010101000301060001010800040108000101'),
		bytes(hex'05000101140001010600030101000101020001010200010102000401020001010200010102000101010003010200010101000101020001010200020102000201020002010200020102000101020001010100010102000501010001010500010104000101050001010100050104000101010001010100070104000701010001010100010103000201010003010100060106000601010003010100020100010200010103000701060007010300010105000901080009010400010102000801080008010200010102000101020007010a0007010200010103000101010007010a0007010100010104000101010006010c0006010100010103000101020006010c0006010200010102000101020005010e0005010200010103000101010005010e0005010100010104000101010004011000040101000101030001010200040110000401020001010200010102000301120003010200010103000101010003011200030101000101040001010100020114000201010001010300010102000201140002010200010102000101020002011400020102000101030001010100030112000301010001010600040110000401070006010e00060105000101030004010c000401030001010200020101000301010004010a00040101000301010002010001030001010100010101000501080005010100010101000101040005010100010103000201060002010300010101000501020001010100010102000101020001010200020104000201020001010200010102000101010001010200030101000101020001010400020102000201040001010200010101000301060001010800040108000101'),
		bytes(hex'0225012603250126072501270201012707250126032501260225022501260325012606250127040101270625012603250126022500250226032501260127012604250127020102000201012704250126012701260325022600260525012701010127012602250127020104000201012702250126012701010127052504250126012702010327030104000301032702010127012604250225012602270801060008010227012602250025022601270a0106000a01012702260026022501260127080108000801012701260225032501260127070108000701012701260325002501260325012706010a0006010127032501260026012501260225012706010a0006010127022501260125012501260225012705010c0005010127022501260125002501260325012705010c000501012703250126002603250126012704010e00040101270126032503250126012704010e000401012701260325032501270401100004010127032503250127040110000401012703250325012601270201120002010127012603250325012601270201120002010127012603250025012603250127010114000101012703250126002601250126022501270101140001010127022501260125012501260225012701011400010101270225012601250025012603250127020112000201012703250126002603250126012703011000030101270126032502250126012705010e00050101270126022500250226012707010c00070101270226002602250126022706010a000601022701260225042501260127020103270101080001010327020101270126042505250127010101270126022501270101060001010127022501260127010101270525002502260325012601270126042501270101040001010127042501260127012603250226002602250126032501260625012701010200010101270625012603250126022502250126032501260725012702010127072501260325012602250025'),
		bytes(hex'0228012903280129072801270201012707280129032801290228022801290328012906280127040101270628012903280129022800280229032801290127012904280127020102000201012704280129012701290328022900290528012701010127012902280127020104000201012702280129012701010127052804280129012702010327030104000301032702010127012904280228012902270801060008010227012902280028022901270a0106000a01012702290029022801290127080108000801012701290228032801290127070108000701012701290328002801290328012706010a0006010127032801290029012801290228012706010a0006010127022801290128012801290228012705010c0005010127022801290128002801290328012705010c000501012703280129002903280129012704010e00040101270129032803280129012704010e000401012701290328032801270401100004010127032803280127040110000401012703280328012901270201120002010127012903280328012901270201120002010127012903280028012903280127010114000101012703280129002901280129022801270101140001010127022801290128012801290228012701011400010101270228012901280028012903280127020112000201012703280129002903280129012703011000030101270129032802280129012705010e00050101270129022800280229012707010c00070101270229002902280129022706010a000601022701290228042801290127020103270101080001010327020101270129042805280127010101270129022801270101060001010127022801290127010101270528002802290328012901270129042801270101040001010127042801290127012903280229002902280129032801290628012701010200010101270628012903280129022802280129032801290728012702010127072801290328012902280028'),
		bytes(hex'0215011603150116071501270201012707150116031501160215021501160315011606150127040101270615011603150116021500150216031501160127011604150127020102000201012704150116012701160315021600160515012701010127011602150127020104000201012702150116012701010127051504150116012702010327030104000301032702010127011604150215011602270801060008010227011602150015021601270a0106000a01012702160016021501160127080108000801012701160215031501160127070108000701012701160315001501160315012706010a0006010127031501160016011501160215012706010a0006010127021501160115011501160215012705010c0005010127021501160115001501160315012705010c000501012703150116001603150116012704010e00040101270116031503150116012704010e000401012701160315031501270401100004010127031503150127040110000401012703150315011601270201120002010127011603150315011601270201120002010127011603150015011603150127010114000101012703150116001601150116021501270101140001010127021501160115011501160215012701011400010101270215011601150015011603150127020112000201012703150116001603150116012703011000030101270116031502150116012705010e00050101270116021500150216012707010c00070101270216001602150116022706010a000601022701160215041501160127020103270101080001010327020101270116041505150127010101270116021501270101060001010127021501160127010101270515001502160315011601270116041501270101040001010127041501160127011603150216001602150116031501160615012701010200010101270615011603150116021502150116031501160715012702010127071501160315011602150015')
	];

	uint8[] public levels_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];

	///////////////////////////////////////
	// misc
	bytes[] public misc = [
		bytes(hex'6f00022a1e00022a1d00042a1c00042a1b00062a1a00062a1900082a1800082a17000a2a1600032a0400032a1500032a0600032a1400032a0200022a0200032a1300072a0300042a1200062a0300052a1100072a0200072a1000102a0f00082a0200082a1000062a0200062a1000022a02000a2a0200022a0f00032a0200062a0200032a1100042a0200022a0200042a1300052a0200052a15000a2a1700082a1900062a1b00042a1d00022a')
	];
}

File 28 of 33 : CryptoEddies.sol
// SPDX-License-Identifier: MIT

/*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  CRYPTO EDDIES  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   by @eddietree  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXNWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNWWWx'....................................:0WWWNXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXNNNo.                                    ,ONNNXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNWWNd'..;looooooooooooooooooooooooooooooooooooc,..;OWWWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNNWNl   ,xOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo.  .kWNNNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNWWNd,',:llldkOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOxollc;'';OWWWNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOd.  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ,kOOOOOOOOOOO0000000KKKKKKKKKKKKKKKKK00000000Kx.  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOOO000KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOO0KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOO0KKKKKKKOl;;ckKKKKKKKKKKKKKKKKkc;;lOXXk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOO0KKKKKKKk'  .oKKKKKKKKKKKKKKKXo.  .xXXk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXNNNXxllc.   ;kOOOOOO0KKKKKKK0occc::::cxKKKKKKKkc:::cccoOKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXNWMMX;       ;kOOOOOO0KKKKKKKKKKXO,    cKKKKKKKl   'OXXXKKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXNNNKxoolc:::::::okOOOOOO0KKKKKKK0occc:::::xKKKKKKKxc:::cccoOKXk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXNWMM0'  .oKKKKKKK0OOOOOOO0KKKKKKXk'  .oKKKKKKKKKKKKKKXKo.  .xKXk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXNWMM0'  .oKKKKKKKK000OOOO0KKKKKKKOl;;:kKKKKKKKKK0000KKKkc;;lOKKOl;;:lddd0NNNXXXXXXXXXXXXX
XXXXXXXXXXXNWMM0'  .oKKKKKKKKKKK0OOO0KKKKKKKKKKKKKKKKKKKKK0kkkOKKKKKKKKKKKKKKKO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXNWWKo;;:coooooookKKKK0000KKKKKKKKKKK0xooookKKKxc::d0KKOdood0KKKKKKO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXXXXNWWMX;       :0KKKKKKKKKKKKKKKKKXO,    cKKKc   ;0KXo.  .xKKKKKXO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXXXXXNWWXo,,,,,,,coodkKKKKKKKKKKKKKKK0c''',codo:''':oddc,'':kXKKKKXO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNWWWWWWNl   ;0KKKKKKKKKKKKKKKKKKKO;   :0K0l.  ,kKKKKKKKKKKO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNWWWWWWNx,'':dddkKKKKKKKKKKKKKKKX0l..'oKKKd'..:OXKKKKK0kddo:'',xWWWNXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNNNNd.  ,OXKKKKKKKKKKKKKKKK000KKKKK0000KKKKKKKk,  .dNNNNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXNXK000o'..;dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo;..,kWWWNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNWMWo...;k0Ol.                                    'xXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXKK0l...c0KKd'............................     ...,OWWWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNWWNl...:kOO0KKX0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOc.  .xKKXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX0c...cKKK0OOO0KKKKKKKKKKKKKKKKKKKKKKKKK0OOOl.  '0MMWNXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXNWWXc..'cxkk0KKKo...:OKKKKKKKOkkO0KKKK0kkO0KKKo'...   '0MMWNXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXWMMX;   lKKKKKKKl.  ,x000KKKKOkkk0KKKKOkkk0KKKl       ,ONNNXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXWMMX;   cKKKKKKK0xxxl'..;kXKKK000KKKKKK000KKKKl   .oxxo,'.:OWWWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXWMMX;  .c000KKKKKKKKo.  .xKKKKKKKKKKKKKKKKKKKKl   'kXXx.  .kMMWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXNNX0kkkc'''oKKKKKKKo.  .xKK0dlloxkkkkkkkk0KKKl   'kXXx.  .kMMWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMNc   :0KKKKKKo.  .xKKOl:::oxxxxxxxxOKKKl   'kKKd.  .kMMWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNNNX0xxxc,,,,,,,;loox0KKOl:::oxxxxxxxxOKKKl    ',,:oxxkKNNNXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNMMWl       'kXKKKKKOl;::oxxxxxxxxOKKKl       '0MMWNXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNNNN0ddd;   'OXXkc,,;;:::oxxxxxxxxOKKKl   .lddkKNNNXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNMMMd   'OXXd.   ':::oxxxxxxxxOKKKl   ,KMMWNXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNMMMd   'OKXx.  .lOOO0KKK0o,,,oKKKl   ,KMMWNXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNMMMd   'OKKd.  .kMMMMMMMNc   :0XKl   ,KMMWXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNWWWx'..:OXXk;..;OWWWWWWWNo...lKKKd'..cKWWNXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

pragma solidity ^0.8.4;

import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import 'base64-sol/base64.sol';

import "./EddieRenderer.sol";
import "./CryptoDeddies.sol";

/// @title CryptoEddies
/// @author Eddie Lee
/// @notice CryptoEddies is an 100% on-chain experimental NFT character project.
contract CryptoEddies is EddieRenderer, ERC721A, Ownable {
    
    uint256 public constant MAX_TOKEN_SUPPLY = 3500;

    // 3 pricing tiers
    uint256 public tier0_price = 0.01 ether;
    uint256 public tier1_price = 0.015 ether;
    uint256 public tier2_price = 0.02 ether;
    uint256 public tier0_supply = 2000;
    uint256 public tier1_supply = 1000;

    uint256 public maxMintsPerPersonPublic = 150;
    uint256 public maxMintsPerPersonWhitelist = 1;
    uint public constant MAX_HP = 5;

    CryptoDeddies public contractGhost;

    enum MintStatus {
        CLOSED, // 0
        WHITELIST, // 1
        PUBLIC // 2
    }

    MintStatus public mintStatus = MintStatus.CLOSED;
    bool public revealed = false;

    mapping(uint256 => uint256) public seeds; // seeds for image + stats
    mapping(uint256 => uint) public hp; // health power

    // events
    event EddieDied(uint256 indexed tokenId); // emitted when an HP goes to zero
    event EddieRerolled(uint256 indexed tokenId); // emitted when an Eddie gets re-rolled
    event EddieSacrificed(uint256 indexed tokenId); // emitted when an Eddie gets sacrificed

    constructor() ERC721A("CryptoEddies", "EDDIE") {
    }

    modifier verifySupply(uint256 numEddiesToMint) {
        //require(tx.origin == msg.sender,  "No bots");
        require(numEddiesToMint > 0, "Mint at least 1");
        require(_totalMinted() + numEddiesToMint <= MAX_TOKEN_SUPPLY, "Exceeds max supply");

        _;
    }

    modifier verifyTokenId(uint256 tokenId) {
        require(tokenId >= _startTokenId() && tokenId <= _totalMinted(), "Out of bounds");
        _;
    }

    function _mintEddies(address to, uint256 numEddiesToMint) private verifySupply(numEddiesToMint) {
        uint256 startTokenId = _startTokenId() + _totalMinted();
         for(uint256 tokenId = startTokenId; tokenId < startTokenId+numEddiesToMint; tokenId++) {
            _saveSeed(tokenId);
            hp[tokenId] = MAX_HP;
         }

         _safeMint(to, numEddiesToMint);
    }

    function reserveEddies(address to, uint256 numEddiesToMint) external onlyOwner {
        _mintEddies(to, numEddiesToMint);
    }

    function reserveEddiesToManyFolk(address[] calldata addresses, uint256 numEddiesToMint) external {
        uint256 num = addresses.length;
        for (uint256 i = 0; i < num; ++i) {
            address to = addresses[i];
            _mintEddies(to, numEddiesToMint);
        }
    }

    /// @notice Mints CryptoEddies into your wallet! payableAmount is the total amount of ETH to mint all numEddiesToMint (costPerCryptoEddie * numEddiesToMint)
    /// @param numEddiesToMint The number of CryptoEddies you want to mint
    function mintEddies(uint256 numEddiesToMint) external payable {
        require(mintStatus == MintStatus.PUBLIC, "Public mint closed");
        require(msg.value >= _getPrice(numEddiesToMint), "Incorrect ether" );
        require(_numberMinted(msg.sender) + numEddiesToMint <= maxMintsPerPersonPublic, "Exceeds max mints");

        _mintEddies(msg.sender, numEddiesToMint);
    }

    function _rerollEddie(uint256 tokenId) verifyTokenId(tokenId) private {
        require(revealed == true, "Not revealed");
        require(hp[tokenId] > 0, "No HP");
        require(msg.sender == ownerOf(tokenId), "Not yours");

        _saveSeed(tokenId);   
        _takeDamageHP(tokenId, msg.sender);

        emit EddieRerolled(tokenId);
    }

    /// @notice Rerolls the visuals and stats of one CryptoEddie, deals -1 HP damage!
    /// @param tokenId The token ID for the CryptoEddie to reroll
    function rerollEddie(uint256 tokenId) external {
        _rerollEddie(tokenId);
    }

    function rerollEddieMany(uint256[] calldata tokenIds) external {
        uint256 num = tokenIds.length;
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            _rerollEddie(tokenId);
        }
    }

    function _saveSeed(uint256 tokenId) private {
        seeds[tokenId] = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), tokenId, msg.sender)));
    }

    // @notice Destroys your CryptoEddie, spawning a ghost
    /// @param tokenId The token ID for the CryptoEddie
    function burnSacrifice(uint256 tokenId) external {
        require(msg.sender == ownerOf(tokenId), "Not yours");
        _burn(tokenId);

        // if not already dead, force kill and spawn ghost
        if (hp[tokenId] > 0) {
            hp[tokenId] = 0;
            emit EddieDied(tokenId);

            if (address(contractGhost) != address(0)) {
                contractGhost.spawnGhost(msg.sender, tokenId, seeds[tokenId]);
            }
        }

        emit EddieSacrificed(tokenId);
    }

    function _startTokenId() override internal pure virtual returns (uint256) {
        return 1;
    }

    // taken from 'ERC721AQueryable.sol'
    function tokensOfOwner(address owner) external view returns (uint256[] memory) {
        unchecked {
            uint256 tokenIdsIdx;
            address currOwnershipAddr;
            uint256 tokenIdsLength = balanceOf(owner);
            uint256[] memory tokenIds = new uint256[](tokenIdsLength);
            TokenOwnership memory ownership;
            for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            return tokenIds;
        }
    }

    function _getPrice(uint256 numPayable) private view returns (uint256) {
        uint256 numMintedAlready = _totalMinted();

        return numPayable 
            * (numMintedAlready < tier0_supply ? 
                tier0_price 
                : ( (numMintedAlready < (tier0_supply+tier1_supply)) ? tier1_price : tier2_price));
    }

    function setPricing(uint256[] calldata pricingData) external onlyOwner {
        tier0_supply = pricingData[0];
        tier0_price = pricingData[1];

        tier1_supply = pricingData[2];
        tier1_price = pricingData[3];

        tier2_price = pricingData[4];

        require(tier0_supply + tier1_supply <= MAX_TOKEN_SUPPLY);
    }

    function setPublicMintStatus(uint256 _status) external onlyOwner {
        mintStatus = MintStatus(_status);
    }

    function setMaxMints(uint256 _maxMintsPublic, uint256 _maxMintsWhitelist) external onlyOwner {
        maxMintsPerPersonPublic = _maxMintsPublic;
        maxMintsPerPersonWhitelist = _maxMintsWhitelist;
    }

    function setContractGhost(address newAddress) external onlyOwner {
        contractGhost = CryptoDeddies(newAddress);
    }

    function setRevealed(bool _revealed) external onlyOwner {
        revealed = _revealed;
    }

    // props to @cygaar_dev
    error SteveAokiNotAllowed();
    address public constant STEVE_AOKI_ADDRESS = 0xe4bBCbFf51e61D0D95FcC5016609aC8354B177C4;

    function _beforeTokenTransfers(address from, address to, uint256 startTokenId, uint256 quantity) internal override {
        if (to == STEVE_AOKI_ADDRESS) { // sorry Mr. Aoki
            revert SteveAokiNotAllowed();
        }

        if (from == address(0) || to == address(0))  // bypass for minting and burning
            return;

        for (uint256 tokenId = startTokenId; tokenId < startTokenId + quantity; ++tokenId) {
            //require(hp[tokenId] > 0, "No more HP"); // soulbound?

            // transfers reduces HP
            _takeDamageHP(tokenId, from);
        }
    }

    function _takeDamageHP(uint256 tokenId, address mintGhostTo) private verifyTokenId(tokenId){
        if (hp[tokenId] == 0) // to make sure it doesn't wrap around
            return;

        hp[tokenId] -= 1;

        if (hp[tokenId] == 0) {
            emit EddieDied(tokenId);

            if (address(contractGhost) != address(0)) {
                contractGhost.spawnGhost(mintGhostTo, tokenId, seeds[tokenId]);
            }
        }
    }

    function rewardHP(uint256 tokenId, uint hpRewarded) external onlyOwner verifyTokenId(tokenId) {
        require(hp[tokenId] > 0, "Already dead");
        hp[tokenId] += hpRewarded;

        if (hp[tokenId] > MAX_HP) 
            hp[tokenId] = MAX_HP;
    }

    function rewardManyHP(uint256[] calldata tokenIds, uint hpRewarded) external {
        uint256 num = tokenIds.length;
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];

            if (hp[tokenId] > 0 ) { // not dead
                hp[tokenId] += hpRewarded;

                if (hp[tokenId] > MAX_HP) 
                    hp[tokenId] = MAX_HP;
            }
        }
    }

    /// @notice Retrieves the HP
    /// @param tokenId The token ID for the CryptoEddie
    /// @return hp the amount of HP for the CryptoEddie
    function getHP(uint256 tokenId) external view verifyTokenId(tokenId) returns(uint){
        return hp[tokenId];
    }

    function numberMinted(address addr) external view returns(uint256){
        return _numberMinted(addr);
    }

    ///////////////////////////
    // -- MERKLE NERD STUFF --
    ///////////////////////////
    bytes32 public merkleRoot = 0x0;

    function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner {
        merkleRoot = _merkleRoot;
    }

    function _verifyMerkle(bytes32[] calldata _proof, bytes32 _leaf) private view returns (bool) {
        return MerkleProof.verify(_proof, merkleRoot, _leaf);
    }

    function verifyMerkle(bytes32[] calldata _proof, bytes32 _leaf) external view returns (bool) {
        return _verifyMerkle(_proof, _leaf);
    }

    function verifyMerkleAddress(bytes32[] calldata _proof, address from) external view returns (bool) {
        bytes32 leaf = keccak256(abi.encodePacked(from));
        return _verifyMerkle(_proof, leaf);
    }

    function mintEddiesMerkle(bytes32[] calldata _merkleProof, uint256 numEddiesToMint) external payable {
        require(mintStatus == MintStatus.WHITELIST || mintStatus == MintStatus.PUBLIC, "Merkle mint closed");
        
        uint256 numMintedAlready = _numberMinted(msg.sender);
        require(numMintedAlready + numEddiesToMint <= maxMintsPerPersonPublic, "Exceeds max mints");

        // calculate how much you need to pay beyond whitelisted amount
        uint256 numToMintFromWhitelist = 0;
        if (numMintedAlready < maxMintsPerPersonWhitelist) {
            numToMintFromWhitelist = (maxMintsPerPersonWhitelist - numMintedAlready);
        }

        // num to actually buy
        uint256 numToMintPayable = numEddiesToMint - numToMintFromWhitelist;
        require(msg.value >= _getPrice(numToMintPayable), "Incorrect ether sent" );
    
        // verify merkle        
        bytes32 leaf = keccak256(abi.encodePacked(msg.sender));
        require(_verifyMerkle(_merkleProof, leaf), "Invalid proof");

        _mintEddies(msg.sender, numEddiesToMint);
    }

    ///////////////////////////
    // -- TOKEN URI --
    ///////////////////////////
    function _tokenURI(uint256 tokenId) private view returns (string memory) {
        string[6] memory lookup = [  '0', '1', '2', '3', '4', '5'];
        uint256 seed = seeds[tokenId];
        string memory image = _getSVG(seed);

        string memory json = Base64.encode(
            bytes(string(
                abi.encodePacked(
                    '{"name": ', '"CryptoEddie #', Strings.toString(tokenId),'",',
                    '"description": "CryptoEddies is an 100% on-chain experimental NFT character project with unique functionality, inspired by retro Japanese RPGs.",',
                    '"attributes":[',
                        _getTraitsMetadata(seed),
                        _getStatsMetadata(seed),
                        '{"trait_type":"HP", "value":',lookup[hp[tokenId]],', "max_value":',lookup[MAX_HP],'}'
                    '],',
                    '"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}' 
                )
            ))
        );

        return string(abi.encodePacked('data:application/json;base64,', json));
    }

    function _tokenUnrevealedURI(uint256 tokenId) private view returns (string memory) {
        uint256 seed = seeds[tokenId];
        string memory image = _getUnrevealedSVG(seed);

        string memory json = Base64.encode(
            bytes(string(
                abi.encodePacked(
                    '{"name": ', '"CryptoEddie #', Strings.toString(tokenId),'",',
                    '"description": "CryptoEddies is an 100% on-chain experimental character art project, chillin on the Ethereum blockchain.",',
                    '"attributes":[{"trait_type":"Unrevealed", "value":"True"}],',
                    '"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}' 
                )
            ))
        );

        return string(abi.encodePacked('data:application/json;base64,', json));
    }

    function tokenURI(uint256 tokenId) override(ERC721A) public view verifyTokenId(tokenId) returns (string memory) {
        if (revealed) 
            return _tokenURI(tokenId);
        else
            return _tokenUnrevealedURI(tokenId);
    }

    function _randStat(uint256 seed, uint256 div, uint256 min, uint256 max) private pure returns (uint256) {
        return min + (seed/div) % (max-min);
    }

    function _getStatsMetadata(uint256 seed) private pure returns (string memory) {
        string[11] memory lookup = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ];

        string memory metadata = string(abi.encodePacked(
          '{"trait_type":"Determination", "display_type": "number", "value":', lookup[_randStat(seed, 2, 2, 10)], '},',
          '{"trait_type":"Love", "display_type": "number", "value":', lookup[_randStat(seed, 3, 2, 10)], '},',
          '{"trait_type":"Cringe", "display_type": "number", "value":', lookup[_randStat(seed, 4, 2, 10)], '},',
          '{"trait_type":"Bonk", "display_type": "number", "value":', lookup[_randStat(seed, 5, 2, 10)], '},',
          '{"trait_type":"Magic Defense", "display_type": "number", "value":', lookup[_randStat(seed, 6, 2, 10)], '},'
        ));

        return metadata;
    }

    function withdraw() external onlyOwner {
        uint balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }
}

File 29 of 33 : EddieRenderer.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import 'base64-sol/base64.sol';

import "./EddieData.sol";

contract EddieRenderer is EddieData {

  string[] public bgPaletteColors = [
    'b5eaea', 'b5c7ea', 'eab6b5', 'c3eab5', 'eab5d9',
    'fafc51', '3a89ff', '5eff8f', 'ff6efa', 'a1a1a1'
  ];
  
  struct CharacterData {
    uint background;

    uint body;
    uint head;
    uint eyes;
    uint mouth;
    uint hair;
  }

  function getSVG(uint256 seed) external view returns (string memory) {
    return _getSVG(seed);
  }

  function _getSVG(uint256 seed) internal view returns (string memory) {
    CharacterData memory data = _generateCharacterData(seed);

    string memory image = string(abi.encodePacked(
      '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" shape-rendering="crispEdges" width="768" height="768">'
      '<rect width="100%" height="100%" fill="#', bgPaletteColors[data.background], '"/>',
      _renderRects(heads[data.head], fullPalettes),
      _renderRects(bodies[data.body], fullPalettes),
      _renderRects(hair[data.hair], fullPalettes),
      _renderRects(mouths[data.mouth], fullPalettes),
      _renderRects(eyes[data.eyes], fullPalettes),
      '</svg>'
    ));

    return image;
  }

  function getGhostSVG(uint256 seed) external view returns (string memory) {
    return _getGhostSVG(seed);
  }

  function _getGhostSVG(uint256 seed) internal view returns (string memory) {
    CharacterData memory data = _generateCharacterData(seed);

    string memory image = string(abi.encodePacked(
      '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" shape-rendering="crispEdges" width="768" height="768">'
      '<rect width="100%" height="100%" fill="#3b89ff"/>',
      //_renderRects(bodies[data.body], fullPalettes),
      //_renderRects(heads[data.head], fullPalettes),
      _renderRects(misc[0], fullPalettes), // ghost body
      _renderRects(hair[data.hair], fullPalettes),
      _renderRects(mouths[data.mouth], fullPalettes),
      _renderRects(eyes[data.eyes], fullPalettes),
      '</svg>'
    ));

    return image;
  }

  function getUnrevealedSVG(uint256 seed) external view returns (string memory) {
    return _getUnrevealedSVG(seed);
  }

  function _getUnrevealedSVG(uint256 seed) internal view returns (string memory) {
    CharacterData memory data = _generateCharacterData(seed);

    string memory image = string(abi.encodePacked(
      '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" shape-rendering="crispEdges" width="768" height="768">'
      '<rect width="100%" height="100%" fill="#', bgPaletteColors[data.background], '"/>',
      _renderRects(misc[1], fullPalettes), // ghost body
      '</svg>'
    ));

    return image;
  }

  function getTraitsMetadata(uint256 seed) external view returns (string memory) {
    return _getTraitsMetadata(seed);
  }

  function _getTraitsMetadata(uint256 seed) internal view returns (string memory) {
    CharacterData memory data = _generateCharacterData(seed);

    string[24] memory lookup = [
      '0', '1', '2', '3', '4', '5', '6', '7',
      '8', '9', '10', '11', '12', '13', '14', '15',
      '16', '17', '18', '19', '20', '21', '22', '23'
    ];

    string memory metadata = string(abi.encodePacked(
      '{"trait_type":"Background", "value":"', lookup[data.background+1], '"},',
      '{"trait_type":"Outfit", "value":"', bodies_traits[data.body], '"},',
      '{"trait_type":"Class", "value":"', heads_traits[data.head], '"},',
      '{"trait_type":"Eyes", "value":"', eyes_traits[data.eyes], '"},',
      '{"trait_type":"Mouth", "value":"', mouths_traits[data.mouth], '"},',
      '{"trait_type":"Head", "value":"', hair_traits[data.hair], '"},'
    ));

    return metadata;
  }

  function _renderRects(bytes memory data, string[] memory palette) private pure returns (string memory) {
    string[24] memory lookup = [
      '0', '1', '2', '3', '4', '5', '6', '7',
      '8', '9', '10', '11', '12', '13', '14', '15',
      '16', '17', '18', '19', '20', '21', '22', '23'
    ];

    string memory rects;
    uint256 drawIndex = 0;

    for (uint256 i = 0; i < data.length; i = i+2) {
      uint8 runLength = uint8(data[i]); // we assume runLength of any non-transparent segment cannot exceed image width (24px)
      uint8 colorIndex = uint8(data[i+1]);

      if (colorIndex != 0) { // transparent
        uint8 x = uint8(drawIndex % 24);
        uint8 y = uint8(drawIndex / 24);
        string memory color = palette[colorIndex];

        rects = string(abi.encodePacked(rects, '<rect width="', lookup[runLength], '" height="1" x="', lookup[x], '" y="', lookup[y], '" fill="#', color, '"/>'));
      }
      drawIndex += runLength;
    }

    return rects;
  }

  function _generateCharacterData(uint256 seed) private view returns (CharacterData memory) {
    return CharacterData({
      background: seed % bgPaletteColors.length,
      
      body: bodies_indices[(seed/2) % bodies_indices.length],
      head: heads_indices[(seed/3) % heads_indices.length],
      eyes: eyes_indices[(seed/4) % eyes_indices.length],
      mouth: mouths_indices[(seed/5) % mouths_indices.length],
      hair: hair_indices[(seed/6) % hair_indices.length]
    });
  }
}

File 30 of 33 : CryptoDeddies.sol
// SPDX-License-Identifier: MIT

/*
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000  CRYPTO EDDIE GHOST 0000000000000000000000000000000000000
000000000000000000000000000000000000000000    by @eddietree    0000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000KXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXK000000000000000000000000000
00000000000000000000000000000000KNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWK000000000000000000000000000
00000000000000000000000000000KXXKOxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxk0XXKK00000000000000000000000
0000000000000000000000000000KNWMK;                                     .kMMWX00000000000000000000000
000000000000000000000000KKKKKOOOxc''''''''''''''''''''''''''''''''''''';dOOO0KKKK0000000000000000000
000000000000000000000000XWWW0,  .xNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNO,  .dWWWX0000000000000000000
000000000000000000000KKKK000x;..,OWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMKc..'o000KKKKK000000000000000
00000000000000000000XWWWk'..,kXXNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNXX0c...oNWWXK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMWWWWWWWWWWWWWWWWWWWMMMMWWWWWWWWWWWK:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMWKkxxxxxxxxxxxxxxxxKWMWKkxxxxxxxxxxdc,,;xNMMNK00000000000000
00000000000000000000XWMWx.  .OMMMMMMMMMWWOlccccccccccccccclkNWW0lcccccccccccccclkNMMNK00000000000000
0000000000000000KNNXkc::'   .lkkkkkkkkkkxdlccokO0xl;..';cccoxkxdlccok00x;..';cclkNMMNK00000000000000
0000000000000000NWMWo       .;cccccccccccccccxXWM0o'   ,cccccccccccdXWM0,   ,cclkNMMNK00000000000000
000000000000KXXXxlclloolollodkOOOOOOOOOOOdlccxXWM0o'   ,ccldkOOxlccdXWM0,   ,cclkNMMNK00000000000000
00000000000KNWMNc   cNMMMMMMMMMMMMMMMMMMWOlccxXWM0o'   ,cclONWW0lccdXWM0,   ,cclkNMMNK00000000000000
00000000000KNMMNc   cNMMMMMMMMMMMMMMMMMMWOlccokOOxl;..';cclONMW0lccokOOx;..';cccloookKXXK00000000000
00000000000KNMMNc   cNMMMMMMMMMMMMMMMMMMW0lccccccccccccccclONWW0lccccccccccccccc'   ;XMMNK0000000000
00000000000KXNNXd:;:ldxxxxxxONMMMMMMMMMMWKkxxo;,,;coxxxxxxkKWMWXkxxxxxxxxxxxxxxx;   ;XMMNK0000000000
000000000000000KXWWNo.      'OMMMMMMMMMMMMWWWx.  .cOWWWWWWWWMMMMWWWWWWWWWWWWWWWNl   ;XMMNK0000000000
0000000000000000XNNNx;,,,,,,:dkkOXMMMMMMMMMMM0:,,:ldkkkO000O000Okkk0WMMMMMMMMMMNl   ;XMMNK0000000000
00000000000000000000XNNNNNNNO'  .kWMMMMMMMMMMWWNNOo,  .',,,,;,,'.  ;KMMMMMMMMMMNl   ;XMMNK0000000000
00000000000000000000XNWWWWWW0:..,d000XMMMMMMMMMMMKxc..'',,,,,,,''..cKMMMMMMWX00Ol'..lKWWNK0000000000
0000000000000000000000KKK0K0KXXX0:. .dWMMMMMMMMMMWWNXX0l,,,,,,,l0XXNWMMMMMMXc...lKNXXK0K000000000000
0000000000000000000000000KKKKKKKO:...l0KKKKKKKKKKKKKKKOc'''''''cOKKKKKKKKKKOc...oNWWXK00000000000000
000000000000000000000000KNWW0;..'dKK0l.................         ...........'oKKKKKKK0000000000000000
00000000000000000000000KKXXXk,..'kWMNo..       ... .. .............      . .xWWWX0000000000000000000
00000000000000000000XNWNk;..;x00KNMMWX00000000000000000000000000000o.  .o0000KKKK0000000000000000000
00000000000000000000XNNNx.  '0MMMWNNWWMMMMMMMMMMMMMMMMMMMMMMMMMWWNNk.  .kMMWX00000000000000000000000
0000000000000000XNNNx;,,cxkk0NMMXo,,;kWMMMMMMMMMMMMMMMMMMMMMMMWO:,,.   .kMMWX00000000000000000000000
000000000000000KNWMWo   ;KMMMMMMK;   oNWWMMMMMMMMMMMMMMMMMMMMMWd.      .kWWWX00000000000000000000000
0000000KXNNNNNNNWMMWo   ,KMMMMMMW0xddl:;:xNMMMMMMMMMMMMMMMMMMMWd.  .lxddc;;ckXNNK0000000000000000000
0000000KWMMMMMMMMMMWo   ;KMMMMMMMMMMNc   :XMMMMMMMMMMMMMMMMMMMWd.  ,0MM0,  .dWMWX0000000000000000000
000KXNN0occccccl0WMWKdoolcccdXMMMMMMNc   :XMMMMMMMMMMMMMMMMMMMWd.  ,0MM0'  .dWMWX0000000000000000000
000XWMMO.       oWMMMMMMx.  .OMMMMMMNc   :XMMMMMMMMMMMMMMMMMMMWd.  ,0MM0,  .dWMWX0000000000000000000
XXXOollllllllllllllllllllllllllllllllllllkWMMMMMMMMMMMMMMMMMMMWd.  .:lllllloOXXXK0000000000000000000
MMWx.  '0MMMMMMNc       ;KMMO'       oWMMMMMMMMMMMMMMMMMMMMMMMWd.      .kMMWX00000000000000000000000
NNNOl::coddxXMMWkc::::::dNMMXo::::::cOWMMMMMMMMMMMMMMMMMMMMMMMWd.  .,::l0NNXK00000000000000000000000
000XWWWO.  .kWMMMWWMMWMMMMMMMWWWWMWMMMMMMMMMMMMMMMMMMMMMMMMMMMWd.  ,0WWNK000000000000000000000000000
000KNNN0c,,:oxxkXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWKkkxo;,;lKNNXK000000000000000000000000000
0000000KNWW0;  .dWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNl.  :KWWNK0000000000000000000000000000000
0000000KWMMK,   oWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNl   :XMMNK0000000000000000000000000000000
*/
// thx CB1 for the name

pragma solidity ^0.8.4;

import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import 'base64-sol/base64.sol';

import "./EddieRenderer.sol";

contract CryptoDeddies is ERC721A, Ownable {
    struct GhostData {
        uint256 eddieTokenId;
        uint256 eddieTokenSeed;
    }

    EddieRenderer public contractRenderer;

    mapping(uint256 => GhostData) public ghostData; // tokenid => ghost data
    error EddieGhostIsSoulbound();
    event EddieGhostSpawned(uint256 indexed tokenId, uint256 indexed eddieTokenId, uint256 indexed eddieTokenSeed); // emitted when an HP goes to zero

    constructor(address _contractRenderer) ERC721A("CryptoDeddies", "DEDDIE") {
        contractRenderer = EddieRenderer(_contractRenderer);
    }

    modifier verifyTokenId(uint256 tokenId) {
        require(tokenId >= _startTokenId() && tokenId <= _totalMinted(), "Out of bounds");
        _;
    }

    function _startTokenId() override internal pure virtual returns (uint256) {
        return 1;
    }

    function spawnGhost(address to, uint256 eddieTokenId, uint256 eddieTokenSeed) external {
        require(msg.sender == address(contractRenderer), "Only callable from contract");
        _mintGhost(to, eddieTokenId, eddieTokenSeed);
    }

    function spawnGhostAdmin(address to, uint256 eddieTokenId, uint256 eddieTokenSeed) external onlyOwner {
        _mintGhost(to, eddieTokenId, eddieTokenSeed);
    }

    function _mintGhost(address to, uint256 eddieTokenId, uint256 eddieTokenSeed) private {
        _safeMint(to, 1);

        // save ghost data
        uint256 tokenId = _totalMinted();
        ghostData[tokenId] = GhostData({
            eddieTokenId: eddieTokenId,
            eddieTokenSeed: eddieTokenSeed
        });

        emit EddieGhostSpawned(tokenId, eddieTokenId, eddieTokenSeed);
    }

    // block transfers (soulbound)
    function _beforeTokenTransfers(address from, address, uint256, uint256) internal pure override {
        //if (from != address(0) && to != address(0)) {
        if (from != address(0)) { // not burnable
            revert EddieGhostIsSoulbound();
        }
    }

    function setContractRenderer(address newAddress) external onlyOwner {
        contractRenderer = EddieRenderer(newAddress);
    }

    function tokenURI(uint256 tokenId) override(ERC721A) public view verifyTokenId(tokenId) returns (string memory) {
        require(_exists(tokenId), "Nonexistent token");

        GhostData memory ghost = ghostData[tokenId];
        uint256 eddieTokenId = ghost.eddieTokenId;
        uint256 seed = ghost.eddieTokenSeed;

        string memory image = contractRenderer.getGhostSVG(seed);

        string memory json = Base64.encode(
            bytes(string(
                abi.encodePacked(
                    '{"name": ', '"CryptoDeddie Ghost #', Strings.toString(eddieTokenId),'",',
                    '"description": "CryptoDeddie Ghost is a memorialized ghost of your original CryptoEddie, forever soulbound to your wallet.",',
                    '"attributes":[',
                        contractRenderer.getTraitsMetadata(seed),
                        '{"trait_type":"Dead", "value":"True"}, {"trait_type":"Soulbound", "value":"True"}'
                    '],',
                    '"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}' 
                )
            ))
        );

        return string(abi.encodePacked('data:application/json;base64,', json));
    }

    function withdraw() public onlyOwner {
        uint balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }
}

File 31 of 33 : EddieData.sol
// SPDX-License-Identifier: MIT
// AUTOGENERATED FILE by @eddietree on Thu Aug 18 2022 01:31:47 GMT-0700 (Pacific Daylight Time)

pragma solidity ^0.8.0;

contract EddieData {
	string[] public fullPalettes = ['ff00ff', '000000', 'ffffff', 'ff0000', '00ff00', '0000ff', '65656e', '212124', '343438', '212123', 'f83a00', 'fff200', 'ff5900', '0096ff', '2e07f2', '1f1f21', '858ac7', 'e31e27', '7e00de', 'f200ff', '292929', 'f5368f', 'ffff00', 'ff8282', '599cff', 'b2e1f8', 'ff9696', 'ff4747', '919191', 'b8b8b8', 'ff5e00', 'ff995e', 'ff3300', 'd32027', 'f3e106', 'd46a6d', '172f3b', '163545', 'f73b3b', '2c7899', '3fabd9', '2e81a5', '2f82a6', '44b0de', '237843', '47a66b', 'f3f700', 'ba6047', 'a85740', '592f23', '44c3c9', 'ede068', 'ffed4f', '68b84d', '599e42', '038604', '9c9083', '7a7166', '696158', '7ddcff', '00bbff', '009bd4', '5ed4ff', 'edda9d', 'eda200', '004f24', '00c458', '00a44b', '00ad4e', 'ff9500', 'f7ff0f', 'eaf041', 'cfd60d', 'faf5aa', 'ced439', 'b5b535', 'ffa3a3', 'a37b46', '966930', '579aff', '217aff', '4eff00', 'fffc00', 'ffff26', '007dfc', '0067cf', 'fcca97', '8a633c', 'cb8d52', 'fcf0c6', '180d1f', 'a16010', 'e5a925', '3a3a3a', '2057a8', 'b82323', 'ff3030', '3c3c3c', '0004fa', '2b2b2b', 'ff0009', '3150d6', '7c541a', 'ba2b00', 'bfb731', '505050', '729144', '9aa6c1', '3f3556', 'd246e8', 'e74dff', '00974c', '9ec45c', '20d47a', 'eded61', '78573e', 'b89174', '2b478f', '0024ff', '363b3c', '202324', '3587ab', '0044ff', '0145fd', 'b4633b', 'b5643b', '40b2e6', '83c6e5', '115c52', 'ffcc99', '64c0e8', '3a8228', 'fcd502', '165c58', 'f7c328', '8a1212', '008787', '2c3aa8', '8a3c3c', 'e8fd4d', '439958', '5e83ec', '00a800', '006600', '404040', 'c5b2a0', 'fd8c69', 'f7e83e', 'f75a3e', 'fccf03', '68d4cc', 'be8ade', 'b778de', '568746', '67ab50', 'fce2a9', '6edbb7', 'fcb39d', '79dbba', 'c74832', '40cfbc', '7dd8ff', 'dbf4ff', '9ce1ff', 'fbdd97', 'f9de9a', 'f9de9b', 'fade9a', 'f9df9b', 'fadf9b', 'fade9b', 'f8dfa0', 'f8e0a0', 'f7e0a0', 'f5e1a6', 'f4e2a6', 'f5e2a6', 'f4e2a7', 'f5e2a7', 'f2e4ad', 'f3e4ad', 'f2e3ad', 'efe6b5', 'efe5b4', 'f0e5b5', 'efe6b4', 'efe5b5', 'ece8bc', 'ece9bd', 'ece8bd', 'ece9bc', 'e9ebc5', 'e8ebc5', 'e9eac5', 'e9ebc4', 'e6edcd', 'e5eecd', 'e5eece', 'e6eecd', 'e5edcd', 'e5edce', 'e2f0d5', 'e2efd6', 'e2f0d6', 'e2efd5', 'dff2de', 'dcf4e5', 'dcf4e4', 'dcf5e5', 'dbf4e5', 'dcf5e4', 'd9f7ec', 'd9f6ec', 'd7f9f2', 'd7f8f2', 'd6f8f2', 'd4f9f7', 'd4faf7', 'd3fbfb', 'b7c6e8', 'e5edff', 'fae848', 'fae248'];

	///////////////////////////////////////
	// eyes
	bytes[] public eyes = [
		bytes(hex'840003061700020616000206040001020d000106090701020a00040604070108040701020a0004060307010801070108030701020d0001060907010217000102'),
		bytes(hex'c400010201090100010113000102010903020200040a03000101090001020101010201090302010a010b020a0100020101020b000102010901020200030a0300010101020b0003021700010117000101'),
		bytes(hex'e300020e0300020e0d00040e0202030e0202010e0f00010e0202010e0100010e0202010e1000020e0300020e'),
		bytes(hex'd300010101020d00040201000402010101020a0004020205030202030102010101020d000102020501020100010202030102010101020d000402010004020101'),
		bytes(hex'e200040d0100040d0c00040d01020101030d01020101010d0f00010d01020101010d0100010d01020101010d0f00040d0100040d'),
		bytes(hex'e200040c0100040c0c00040c01020101030c01020101010c0f00010c01020101010c0100010c01020101010c0f00040c0100040c'),
		bytes(hex'e30001010400010113000101020001011300010104000101'),
		bytes(hex'df000b011000030102000102010111000301'),
		bytes(hex'df00050f0210020f0210010f0f00010f0210020f0210010f11000110020f01000110020f'),
		bytes(hex'df0003110212021302120213100001120213021202130112110001130212010001130212'),
		bytes(hex'e2000101010001010200010101000101110001010400010111000101010001010200010101000101'),
		bytes(hex'e200040101000301100001020201020001020201'),
		bytes(hex'e30001010400010111000101010001010200010101000101'),
		bytes(hex'e200030102000301110001020101020001020101'),
		bytes(hex'9c00070110000101060201010f0001010802010101020d00010102020101030201010102010101020a000401040201030302010101020d00010102020101030201010102010101020d00010103020301020201010f0001010602010111000601'),
		bytes(hex'9c00070110000101060201010f0001010802010101020d00010101020117010101170102011701010117010101020a00040102020118030201180102010101020d0001010202011801010102010101180102010101020d000101020201180102010101020118010201010f0001010102011803020118010111000601'),
		bytes(hex'9b000801010001020d0001010816010101020c00010108160101010001020c0001010216010103160101011601010e000101081601010e0001010216010103160101011601010e00010103160301021601010f000101081610000801'),
		bytes(hex'e200031402000314100001140115011402000114011501141000031402000314'),
		bytes(hex'e2000302020003021000020201010200010102021000030202000302'),
		bytes(hex'e200030202000302100001020101010202000102010101021000030202000302'),
		bytes(hex'e300030101000301110001020101020001020101120001020101020001020101'),
		bytes(hex'cc0001160300011613000b0301030a0001160103010203160102061601160c000b0301030c00011603000116'),
		bytes(hex'e200030102000301110001020101020001020101120001020101020001020101'),
		bytes(hex'cc000101030001011100020105000101110001020101030001010102110001020101030001010102'),
		bytes(hex'b2000319140005191300011903010119030001010f00011901010103010101190100020101020f000119030101190200010101020f0005191200041914000219'),
		bytes(hex'e200030102000301110001020101020001020101120001010102020001010102'),
		bytes(hex'e3000301010003011100011a0101011a0100011a0101011a1100031a0100031a'),
		bytes(hex'e2000301020003011100010201010200010201011200020202000202'),
		bytes(hex'e900010110000401010002010102110001020101030001010102'),
		bytes(hex'e200020117000102020101000301110001020101030001010102'),
		bytes(hex'e200020105000101110001020201010002010102110001020101030001010102'),
		bytes(hex'e200030102000301290001010102030001010102')
	];

	string[] public eyes_traits = [
		'Virtual Reality',
		'Scouter',
		'Glasses',
		'3D Glasses',
		'Big Blue Glasses',
		'Big Red Glasses',
		'Shut',
		'Pirate',
		'Future Too Bright',
		'Stunners',
		'RIP',
		'Smug',
		'Overjoyed',
		'Sus',
		'Good Face',
		'Sad Face',
		'Happy Note',
		'Corrupted',
		'Dizzy',
		'Low Key Shook',
		'Optimistic',
		'Maximalist',
		'Watchful',
		'Worried',
		'Terminatooor',
		'Senpai',
		'Stoney Baloney',
		'Skyward',
		'Raised Left',
		'Raise Right',
		'U Mad Bro',
		'Naughty'
	];

	uint8[] public eyes_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];

	///////////////////////////////////////
	// mouths
	bytes[] public mouths = [
		bytes(hex'ff004400010118000301'),
		bytes(hex'ff004500010101000101010001011400010101000101'),
		bytes(hex'ff00450001010300010114000301'),
		bytes(hex'ff004400010118000101021b010115000203'),
		bytes(hex'ff001000010117000c010d0001010a1c0e000101021c011d031c011d021c0f000101071c11000101021c011d021c13000101031c15000101011c010116000101'),
		bytes(hex'ff001000010117000c010d0001010a030e0001010203021e0103021e02030f0001010703110001010103021e0203130001010303150001010103010116000101'),
		bytes(hex'2d000102300001022e0001021700010248000102170001022f00010229000101011f0202012015000201'),
		bytes(hex'ff005c000201'),
		bytes(hex'ff004300010f0600010f1100060f'),
		bytes(hex'ff005c0002010102010101020201'),
		bytes(hex'ff00460003011500010101000101'),
		bytes(hex'ff00460003011400010103000101'),
		bytes(hex'ff005e000301'),
		bytes(hex'ff005c000601')
	];

	string[] public mouths_traits = [
		'Smirk',
		'Uwu',
		'Smile',
		'Silly',
		'Grey Bandana',
		'Red Bandana',
		'Smoking',
		'Hmmm',
		'Big Honkin Smile',
		'Buck',
		'Micro Sad',
		'Sad',
		'Blah',
		'Unsatisfied'
	];

	uint8[] public mouths_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13];

	///////////////////////////////////////
	// hair
	bytes[] public hair = [
		bytes(hex'200009020e000102090101020c000102010103240625010101020a000102010102240925010101020500050201010124062502000225010101020500010205010124052504000125010101020500010201010424062504260125010106000202030114000302'),
		bytes(hex'200009020e000102090101020c00010201010921010101020a0001020101042101220121012201210122022101010102090001020101042105220221010101020a0001010b210101010001020900010101210b23020101020b000c230101010214000201010216000102'),
		bytes(hex'200009020e000102090103020a00010201010129022a022b07010102080001020101022a022b0201072a01010102070001020101012a022b0101092a0101010208000101012a012b01010a2a0101010208000101012a01010a2a01010102'),
		bytes(hex'200009020e000102090101020c000102010103270628010101020a000102010102270928010101020500050201010127062802000228010101020500010205010127052804000128010101020500010201010427062804260128010106000202030114000302'),
		bytes(hex'200009020e000102090101020c0001020101032c062d010101020a0001020101022c092d01010102050005020101012c062d0201022d01010102050001020501012c052d0401012d01010102050001020101042c062d042e012d010106000202030114000302'),
		bytes(hex'0b00010201010202130001020101012f02010102110001020101012f0130022f010101020f0001020101033102300131010101020d0001020101012f0630012f010101020b0001020101012f01300731010101020b000102010101310730022f010101020c000a31'),
		bytes(hex'200009020e00020204010102030101020c0002020101043501010335010101020b0001020101013501360137010201010236010201010135010101020a0001020101013509360101010209000102010101350a3601010102090001020101013502360300023603000101010209000102010102360900010101020b0002360900010101020b0002360900010101020b0002360900010101020c000136'),
		bytes(hex'3a00050211000202050102020e00010202010532020101020c00010201010932010101020a000102010101330a34010101020b0001330a34'),
		bytes(hex'2800010216000102010101020e00070201010102010101020c00010207010202010101020b00010201010a02010101020900010201010b020101010209000102010103020300020203000101010209000102010102020900010101020b0002020900010101020b0002020900010101020b0002020900010101020c000102'),
		bytes(hex'2100020201000202010002020f0001020201010202010102020102020c000102010102380101023801010238020101020a000102010102380139013802390138013903380101010209000102010101380a390138010108000102010101380c39010108000102010103390300023903000201010208000102010102390900010101020b0002390900010101020b0002390900010101020b0002390900010101020c000139'),
		bytes(hex'090007020e00030204010102020102020b0001020301043b0101023b02010102090001020101043b033c013b023c023b01010102070001020101023b0b3c01010102060001020101023b043c023d013c023d013c013d013c013b01010102050001020101013b033c0a3d023c01010102040001020101013b013c013d013c033d0600023d013c01010102040001020101013b013c033d0900013d013c01010102040002020101023c023d0900023d01010102040001020101023c033d0900013d01010102050001020101023c033d0900013d01010102060001020101013c0200013d130001020101013d17000101013d160001020101'),
		bytes(hex'090007020f000202070102020c00010202010738020101020a000102010103380139013802390138013902380101010208000102010102380a3901380101010206000102010102380439013a0339013a0339010101020600010201010539073a03390101010204000102010102380239023a0700023a01390101010204000102010101380239023a0900023a0101010204000102010101380139013a0139013a0900023a01010102040001020101013a0139033a0900013a0101010206000102010101390100023a0b00010206000102010101390200013a130001020101013a160001020101013a160001020101'),
		bytes(hex'200009020e000102090101020c00010201010938010101020a0001020101023809390101010209000102010101380a39010101020900010201010b3901010102090001020101033908000101010209000102010102390900010101020b0002390900010101020b0002390900010101020b0002390900010101020c000139'),
		bytes(hex'390008020e000202080101020c0001020201083e010101020a0001020101023e093c01010102080001020101023e0a3c01010102080001020101013e073c0100033c01010102080001020101043c080001010102080001020101033c0900010101020b00023c0900010101020b00023c0900010101020c00013c2b0001020101013c150001020101023c14000202'),
		bytes(hex'2800010216000102010101020e0007020101013f010101020c0001020701013f0140010101020b00010201010a40010101020900010201010b400101010209000102010103400300024003000101010209000102010102400900010101020b0002400900010101020b0002400900010101020b0002400900010101020c000140'),
		bytes(hex'2800010216000102010101020e00070201010138010101020c000102070101380139010101020b00010201010a39010101020900010201010b390101010209000102010103390300023903000101010209000102010102390900010101020b0002390900010101020b0002390900010101020b0002390900010101020c000139'),
		bytes(hex'2100010205000102100001020101010203000102010101020e00010201010103010101020100010201010103010101020d00010201010203010101000101020301010102'),
		bytes(hex'0a0001020141010215000202014103021100010206410102100001410342014101430142014101020e00014104440142014101440142014101020e00014107440141100003410344024113000341'),
		bytes(hex'0b00010203010102110002020101014501010145010101020f00010204010145030101020d00010201010846010101020b00010201010346010201010146010201010246010102020800010201010b460301010209000346014709450101010209000246014702000745010101020a000246014715000146014716000146014716000247170001471700014717000148'),
		bytes(hex'080001020201010203000102010101020d000102010102490101030201010149010101020c00010201010149014602010102010101490146010101020c000102010103460101010001010246010101020e0001010246010102000146020001020d000249064601490e0001490246074a01460d0001490146014a0700014a0d000146014a16000146014a16000146014a16000146014a1700014a'),
		bytes(hex'2100010205000102100001020101010203000102010101020e00010201010102010101020100010201010102010101020d00010201010202010101000101020201010102'),
		bytes(hex'08000b020c00020203010302030102020b000102010103020101010201010302010101020b00010201010102014c01020101010001010102014c0102010101020b00010201000102014c0102010102000102014c0102010101020c000a02010101020b00020216000102170001021700010217000102'),
		bytes(hex'05000402020003020200040209000102020104020101040202010102090001020101014b0101020201010116010102020101011601010102090001020101014b0116020103160201021601010102090001020101024b091601010102090001020101024b011601030216010302160103011601010102090001020101034b081601010b000101'),
		bytes(hex'ff00'),
		bytes(hex'090004021300020203010302100001020101034d0301010211000201014e034d010101020d000102020101000101044e014d010101020b0001020101094e014d010101020900010201010b4e01010102090001020101034e0300024e030001010102090001020101024e0900010101020b00024e0900010101020b00024e0900010101020b00024e0900010101020c00014e'),
		bytes(hex'1d0003021400010203010102120001020101034f0101120001020101014f025003011000010202010b500b00010202000b500a000102020003501500025016000250160002501600025017000150'),
		bytes(hex'1d000302140001020301010212000102010103530101120001020101035303011000010202010b530b00010202000b530a000102020003531500025316000253160002531600025317000153'),
		bytes(hex'800001510152015101520151015203510e0003510152015101520151015203510d0003511500025116000251160002511600025117000151'),
		bytes(hex'63000254170002541700015401550b5401550800025402550b54015507000254'),
		bytes(hex'6300025a1700025a17000e5a0800105a0700025a')
	];

	string[] public hair_traits = [
		'Black Hat',
		'Bear Market Hat',
		'Cap Front',
		'Topo Hat',
		'Chill Green Hat',
		'Poop',
		'Froggy',
		'Eric',
		'Old But Still Cool',
		'Straight Bussin',
		'Clowin',
		'Success Perm',
		'Poppin',
		'Neetori',
		'Blonde',
		'Cool Guy',
		'Devil Horns',
		'Leaf',
		'Ducky',
		'Pipichu',
		'Catbot',
		'Easter',
		'King',
		'Bald',
		'90s',
		'3000',
		'Sun Bun',
		'Too Cool',
		'Blue Bandana',
		'Black Bandana'
	];

	uint8[] public hair_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,23,24,25,26,27,28,29];

	///////////////////////////////////////
	// bodies
	bytes[] public bodies = [
		bytes(hex'ff006e000102010101561400010201010356010112000102010104560157015804560101010209000102010103560159015701580659010101020800010201010256025901570158035901580259010101020800010201010256015901570158075901010102080001020101025601590157015802590158045901010102080001020101025601590157015805590158015901010102080001020101025601590157015801590158055901010102'),
		bytes(hex'ff006e0001020101015b140001020101035b01011200010201010a5b01010102090001020101065b065c01010102080001020101025b025c045b045c01010102080001020101035b055c045b01010102080001020101045b085c01010102080001020101025b015c035b065c01010102080001020101025b035c035b045c01010102'),
		bytes(hex'ff006e0001020101015f140001020101035f01011200010201010a5f01010102090001020101035f096001010102080001020101025f0a6001010102080001020101025f0a6001010102080001020101025f0a6001010102080001020101025f0a6001010102080001020101025f0a6001010102'),
		bytes(hex'ff006d0001020101025d140001020201025d0101120002020101045d0101015d0101025d0c0001020101025d0101025d0101015d0101015d0d0001020101015d02000101055d120006011200065e1200015e0400015e1200015e0400015e'),
		bytes(hex'ff00eb000561120006612a00010304000103'),
		bytes(hex'ff00eb00050214000302'),
		bytes(hex'ff008800010101631600046301010100010102630e00026301000363010102630f0001630300016301010363130005641200066312000163040001631200016304000163'),
		bytes(hex'ff00890001651600046501010100010102650e00026501000365010102650f000165030001650101036513000366010301661200066512000165040001651200016504000165'),
		bytes(hex'ff00b800010316000303070001030e0002030100050201000103100006621200016204000162'),
		bytes(hex'ff008900016f1600096f0e00026f0100026f0370016f0f00016f02710100016f017001720170016f010001710e0002710100016f0370016f010001711000066f1200016f0400016f1200016f0400016f'),
		bytes(hex'ff008900016a1600046a0101016b0101026a0e00026a0100026a0101016c0101016a0f00016a0300016a0101016b0101016a13000268010102681200066912000169040001691200016904000169'),
		bytes(hex'ff00890001021600040201010167010102020e000202010002020101010a010101020f000102030001020101010a0101010213000268010102681200066912000169040001691200016904000169'),
		bytes(hex'ff00890001021600040201010100010102020e00020201000302010102020f00010203000502130005681200060212000102040001021200010204000102'),
		bytes(hex'ff00eb00056d1300046e'),
		bytes(hex'ff00ff00030006761200017604000176'),
		bytes(hex'ff00890001731600027301740173017401730174017301740e00027301000173017401730174017301740f000173030001730174017301740173130005731200067512000175040001751200017504000175'),
		bytes(hex'ff0089000177160009770e000277010006770f00017703000577130005781200067912000179040001791200017904000179'),
		bytes(hex'ff008900017e1600017e017f017e017f018001000180017f017e0e0002810100017f017e017f0180017f017e0f0001810300017f017e017f017e017f1300017e017f017e017f017e1200017e017f017e017f017e017f1200017e0400017e'),
		bytes(hex'ff008900017a1600097a0e00017b017a0100067a0f00017a0300057a1300057a1200017c047d017c1200017c0400017c'),
		bytes(hex'ff0089000182160009820e0002820100028201160182011601820f000182030001820316018213000582120006161200011604000116'),
		bytes(hex'ff00a3000583120003830184028313000183018401830184018313000583120006851200018504000185'),
		bytes(hex'ff00a300010203000102120006021300050213000502120006881200018804000188'),
		bytes(hex'ff0089000189160009890e00028901000389020101890f0001890300018902010289130005891200068a1200018a0400018a'),
		bytes(hex'ff0089000186160009860e00028601000286012b0186012b01860f00018603000286012b0286130005861200068712000187040001871200018704000187'),
		bytes(hex'ff008900018b1600098b0e00028b0100038b018c028b0f00018b0300018b038c018b1300058b1200068d1200018d0400018d1200018d0400018d'),
		bytes(hex'ff00a300019001000190010001901200019001000190010001901400019001000190010001901400019001000190140001900100019001000190'),
		bytes(hex'ff00ed00018e1600038e1500018e018f018e')
	];

	string[] public bodies_traits = [
		'Burrito',
		'Monk',
		'Comfy',
		'Hoodie',
		'Astro',
		'Underwear',
		'Ninja',
		'Jiu Jitsu Gi Blue',
		'Boxer',
		'Andy',
		'Myles',
		'Business Time',
		'Freddie',
		'Hot Speedo',
		'Swimmer',
		'Argyle',
		'Steve',
		'Romphim',
		'Meme Frog',
		'Go Bruins',
		'Staying Fit',
		'LA Summer',
		'Bicyclist',
		'Funktronic',
		'Ganja Shirt From College',
		'Net',
		'Leaf'
	];

	uint8[] public bodies_indices = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26];

	///////////////////////////////////////
	// heads
	bytes[] public heads = [
		bytes(hex'500009020e000102090101020c00010201010991010101020a00010201010b910101010209000102010103910881010101020900010201010291098101010102090001020101029109810101010208000102020102910981010101020700010201010281029109810101010207000102010103810191058101920481010101020700010202010c81010101020800020201010b81010101020a00010201010981010101020a00010201010181090101020a00010201010981010101020a00010201010281010102810192018101920181020101020a000102010103810101058101010181010101020a000102010102810101058101010181010101020b00010202010681020101020d0001020101018104010181010101020e00010201010181010102020101018101010102'),
		bytes(hex'500009020e000102090101020c00010201010993010101020a00010201010b930101010209000102010103930894010101020900010201010293099401010102090001020101029309940101010208000102020102930994010101020700010201010294029309940101010207000102010103940193059401950494010101020700010202010c94010101020800020201010b94010101020a00010201010994010101020a00010201010194090101020a00010201010994010101020a00010201010294010102940195019401950194020101020a000102010103940101059401010194010101020a000102010102940101059401010194010101020b00010202010694020101020d0001020101019404010194010101020e00010201010194010102020101019401010102'),
		bytes(hex'500009020e000102090101020c00010201010999010101020a00010201010b99010101020900010201010399089a010101020900010201010299099a010101020900010201010299099a010101020800010202010299099a01010102070001020101029a0299099a01010102070001020101039a0199059a0192049a010101020700010202010c9a010101020800020201010b9a010101020a0001020101099a010101020a00010201010136090101020a0001020101099a010101020a0001020101029a01010136059a020101020a0001020101039a01010136049a0101019a010101020a0001020101029a01010136049a0101019a010101020b0001020201069a020101020d0001020101019a0401019a010101020e0001020101019a010102020101019a01010102'),
		bytes(hex'500009020e000102090101020c0001020101099b010101020a00010201010b9b01010102090001020101039b089c01010102090001020101029b099c01010102090001020101029b099c01010102080001020201029b099c01010102070001020101029c029b099c01010102070001020101039c019b059c019d049c010101020700010202010c9c010101020800020201010b9c010101020a0001020101099c010101020a0001020101019e090101020a0001020101099e010101020a0001020101029e0101029e019f019e019f019e020101020a0001020101039e0101059e010101a0010101020a0001020101029e0101059e010101a0010101020b0001020201069e020101020d0001020101019e0401019e010101020e0001020101019e010102020101019e01010102'),
		bytes(hex'500009020e000102090101020c00010201010996010101020a00010201010b960101010209000102010103960897010101020900010201010296099701010102090001020101029609970101010208000102020102960997010101020700010201010297029609970101010207000102010103970196059701920497010101020700010202010c97010101020800020201010b97010101020a00010201010997010101020a00010201010198090101020a00010201010998010101020a00010201010298010102980192019801920198020101020a000102010103980101059801010198010101020a000102010102980101059801010198010101020b00010202010698020101020d0001020101019804010198010101020e00010201010198010102020101019801010102'),
		bytes(hex'500009020e000102090101020c00010201010902010101020a00010201010b02010101020900010201010b02010101020900010201010b02010101020900010201010b02010101020800010202010b02010101020700010201010d0201010102070001020101090201920402010101020700010202010c02010101020800020201010b02010101020a00010201010902010101020a00010201010102090101020a00010201010902010101020a00010201010202010102020192010201920102020101020a000102010103020101050201010102010101020a000102010102020101050201010102010101020b00010202010602020101020d0001020101010204010102010101020e00010201010102010102020101010201010102'),
		bytes(hex'500009020e000102090101020c000102010109a1010101020a00010201010ba10101010209000102010103a108a20101010209000102010102a109a20101010209000102010102a109a20101010209000102010102a109a20101010209000102010102a109a20101010209000102010102a105a2019204a20101010208000102010102a10aa20101010209000102010101a10aa2010101020a000102010109a2010101020a000102010101a3090101020a000102010108a201a3010101020a000102010102a2010101a305a2020101020a000102010103a2010101a304a2010101a2010101020a000102010102a2010101a304a2010101a2010101020b000102020106a2020101020d000102010101a2040101a2010101020e000102010101a201010202010101a201010102'),
		bytes(hex'500009020e000102090101020c000102010109a4010101020a00010201010ba40101010209000102010101a505a601a701a801a901a601aa0101010209000102010101ab01ac01ad01ac01ad01ac01ad01ac03ad0101010209000102010101ae01af01b001b102b001b201ae01b001ae01b00101010208000102020102b301b402b301b401b501b401b501b301b40101010207000102010101b601b701b601b801b901b701ba02b604b90101010207000102010101bb01bc01bd01be01bd02bb03bd01bb01be01bc01bd0101010207000102020102bf01c001c101c202c002bf01c001bf01c00101010208000202010101c301c401c501c401c601c402c702c801c3010101020a000102010101c901ca01c902cb01cc01cb01c901cb010101020a000102010101cd090101020a000102010101ce01cf02ce02d001d101d001d2010101020a000102010101d301d4010102d404d3020101020a000102010101d501d601d7010102d601d702d5010101d6010101020a000102010101d801d9010101d804d9010101d9010101020b000102020106da020101020d000102010101da040101da010101020e000102010101da01010202010101da01010102'),
		bytes(hex'500009020e000102090101020c000102010109dd010101020a000102010102dd070202dd0101010209000102010101dd010209dd0101010209000102010101dd010209dd0101010209000102010101dd010209dd010101020800010202010bdd0101010207000102010102020bdd0101010207000102010103dd010205dd019203dd0102010101020700010202010cdd010101020800020201010bdd010101020a000102010109dd010101020a000102010101de090101020a000102010101dd010207dd010101020a000102010101dd0102010102dd019f01dd019f01dd020101020a000102010102dd0102010105dd01010102010101020a000102010102dd010101dd020202dd010101dd010101020b000102020106dd020101020d000102010101dd040101dd010101020e000102010101dd01010202010101dd01010102')
	];

	string[] public heads_traits = [
		'Human',
		'Tengu',
		'Meme Frog',
		'Orc',
		'Night Elf',
		'Spoopy',
		'AI Bot',
		'Prismatic',
		'Golden Boy'
	];

	uint8[] public heads_indices = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,2,2,2,3,3,3,4,4,5,6,6,7,8];

	///////////////////////////////////////
	// misc
	bytes[] public misc = [
		bytes(hex'500009020e000102090101020c000102010109db010101020a000102010103db08dc0101010209000102010102db09dc0101010209000102010102db09dc0101010209000102010102db09dc0101010208000102020102db09dc0101010207000102010104db09dc0101010207000102010103db03dc029203dc029201dc010101020700010202010cdc010101020800020201010bdc010101020a000102010109dc010101020a000102010101db090101020a000102010104db05dc010101020a000102010102db010106dc0201010208000302010101db02dc010105dc010101dc010101020600010202010202010102dc010105dc010101dc0101010205000102010102db020101db020106dc0201010207000102010104db08dc0101010209000102010103db07dc01010102'),
		bytes(hex'500009020e000102090101020c0001020b0101020a0001020d0101020900010205010302050101020900010204010502040101020900010203010202030102020301010208000102040102020301020203010102070001020a010202030101020700010209010202050101020700010207010202060101020800020205010202060101020a0001020b0101020a00010205010202040101020a00010206010202030101020a0001020c0101020a0001020d0101020a0001020c0101020b0001020a0101020d000102080101020e0001020301020203010102')
	];

	string[] public misc_traits = [
		'Ghost',
		'Mystery'
	];
}

File 32 of 33 : CryptoEddiesV2.sol
// SPDX-License-Identifier: MIT

/*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  CRYPTO EDDIES  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX   by @eddietree  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  (LET TRY THIS AGAIN SHALL WE?) XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXNWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNWWWx'....................................:0WWWNXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXNNNo.                                    ,ONNNXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNWWNd'..;looooooooooooooooooooooooooooooooooooc,..;OWWWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNNWNl   ,xOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOo.  .kWNNNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNWWNd,',:llldkOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOxollc;'';OWWWNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOd.  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ,kOOOOOOOOOOO0000000KKKKKKKKKKKKKKKKK00000000Kx.  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOOO000KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOO0KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOO0KKKKKKKOl;;ckKKKKKKKKKKKKKKKKkc;;lOXXk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMN:   ;kOOOOOO0KKKKKKKk'  .oKKKKKKKKKKKKKKKXo.  .xXXk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXNNNXxllc.   ;kOOOOOO0KKKKKKK0occc::::cxKKKKKKKkc:::cccoOKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXNWMMX;       ;kOOOOOO0KKKKKKKKKKXO,    cKKKKKKKl   'OXXXKKKk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXNNNKxoolc:::::::okOOOOOO0KKKKKKK0occc:::::xKKKKKKKxc:::cccoOKXk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXNWMM0'  .oKKKKKKK0OOOOOOO0KKKKKKXk'  .oKKKKKKKKKKKKKKXKo.  .xKXk'  .xMMMNXXXXXXXXXXXXXXXX
XXXXXXXXXXXNWMM0'  .oKKKKKKKK000OOOO0KKKKKKKOl;;:kKKKKKKKKK0000KKKkc;;lOKKOl;;:lddd0NNNXXXXXXXXXXXXX
XXXXXXXXXXXNWMM0'  .oKKKKKKKKKKK0OOO0KKKKKKKKKKKKKKKKKKKKK0kkkOKKKKKKKKKKKKKKKO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXNWWKo;;:coooooookKKKK0000KKKKKKKKKKK0xooookKKKxc::d0KKOdood0KKKKKKO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXXXXNWWMX;       :0KKKKKKKKKKKKKKKKKXO,    cKKKc   ;0KXo.  .xKKKKKXO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXXXXXNWWXo,,,,,,,coodkKKKKKKKKKKKKKKK0c''',codo:''':oddc,'':kXKKKKXO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNWWWWWWNl   ;0KKKKKKKKKKKKKKKKKKKO;   :0K0l.  ,kKKKKKKKKKKO,   oWMMNXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNWWWWWWNx,'':dddkKKKKKKKKKKKKKKKX0l..'oKKKd'..:OXKKKKK0kddo:'',xWWWNXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNNNNd.  ,OXKKKKKKKKKKKKKKKK000KKKKK0000KKKKKKKk,  .dNNNNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXNXK000o'..;dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxo;..,kWWWNXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNWMWo...;k0Ol.                                    'xXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXKK0l...c0KKd'............................     ...,OWWWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNWWNl...:kOO0KKX0OOOOOOOOOOOOOOOOOOOOOOOOOOOOOc.  .xKKXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX0c...cKKK0OOO0KKKKKKKKKKKKKKKKKKKKKKKKK0OOOl.  '0MMWNXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXNWWXc..'cxkk0KKKo...:OKKKKKKKOkkO0KKKK0kkO0KKKo'...   '0MMWNXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXWMMX;   lKKKKKKKl.  ,x000KKKKOkkk0KKKKOkkk0KKKl       ,ONNNXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXWMMX;   cKKKKKKK0xxxl'..;kXKKK000KKKKKK000KKKKl   .oxxo,'.:OWWWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXWMMX;  .c000KKKKKKKKo.  .xKKKKKKKKKKKKKKKKKKKKl   'kXXx.  .kMMWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXNNX0kkkc'''oKKKKKKKo.  .xKK0dlloxkkkkkkkk0KKKl   'kXXx.  .kMMWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXWMMNc   :0KKKKKKo.  .xKKOl:::oxxxxxxxxOKKKl   'kKKd.  .kMMWNXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXNNNX0xxxc,,,,,,,;loox0KKOl:::oxxxxxxxxOKKKl    ',,:oxxkKNNNXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNMMWl       'kXKKKKKOl;::oxxxxxxxxOKKKl       '0MMWNXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXNNNN0ddd;   'OXXkc,,;;:::oxxxxxxxxOKKKl   .lddkKNNNXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNMMMd   'OXXd.   ':::oxxxxxxxxOKKKl   ,KMMWNXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNMMMd   'OKXx.  .lOOO0KKK0o,,,oKKKl   ,KMMWNXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNMMMd   'OKKd.  .kMMMMMMMNc   :0XKl   ,KMMWXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXNWWWx'..:OXXk;..;OWWWWWWWNo...lKKKd'..cKWWNXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/
// special thanks to 0xmetazen and troph for reviewing the code

pragma solidity ^0.8.4;

import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import 'base64-sol/base64.sol';

import "./EddieRenderer.sol";
import "./CryptoDeddiesV2.sol";
import "./CryptoEddies.sol"; // OG

/// @title CryptoEddies V2
/// @author @eddietree
/// @notice CryptoEddies is an 100% on-chain experimental NFT character project.
contract CryptoEddiesV2 is ERC721A, Ownable {
    
    uint256 public constant MAX_TOKEN_SUPPLY = 3500;
    uint public constant MAX_HP = 5;

    // contracts
    CryptoDeddiesV2 public contractGhost;
    CryptoEddies public contractEddieOG;
    address public contractHpEffector;

    bool public revealed = true;
    bool public rerollingEnabled = true;
    bool public claimEnabled = true;
    bool public burnSacrificeEnabled = false;

    mapping(uint256 => uint256) public ogTokenId; // tokenId=>ogTokenId (From original contract)
    mapping(uint256 => uint256) public seeds; // seeds for image + stats
    mapping(uint256 => uint) public hp; // health power

    // events
    event EddieDied(uint256 indexed tokenId); // emitted when an HP goes to zero
    event EddieRerolled(uint256 indexed tokenId); // emitted when an Eddie gets re-rolled
    event EddieSacrificed(uint256 indexed tokenId); // emitted when an Eddie gets sacrificed

    constructor(address _contractEddieOG) ERC721A("CryptoEddiesV2", "EDDIEV2") {
        contractEddieOG = CryptoEddies(_contractEddieOG);
    }

    modifier verifyTokenId(uint256 tokenId) {
        require(tokenId >= _startTokenId() && tokenId <= _totalMinted(), "Out of bounds");
        _;
    }

    modifier onlyApprovedOrOwner(uint256 tokenId) {
        require(
            _ownershipOf(tokenId).addr == _msgSender() ||
                getApproved(tokenId) == _msgSender(),
            "Not approved nor owner"
        );
        
        _;
    }

    function claimMany(uint256[] calldata tokenIds) external {
        require(claimEnabled == true);

        // clamp the total minted
        //require(_totalMinted() + tokenIds.length <= MAX_TOKEN_SUPPLY );

        uint256 num = tokenIds.length;
        uint256 startTokenId = _startTokenId() + _totalMinted();
        address sender = msg.sender;

        for (uint256 i = 0; i < num; ++i) {
            uint256 originalTokenId = tokenIds[i];
            uint256 newTokenId = startTokenId + i;

            //require(sender == contractEddieOG.ownerOf(originalTokenId)); // check ownership
            //require(ogTokenId[newTokenId] == 0); // check not already claimed

            // transfer each token to this contract and then call the burn function
            // since the 'burnSacrifice' call can only be called on the owner,
            // we had to first transfer to this contract before excuting burnSacrifice
            contractEddieOG.transferFrom(sender, address(this), originalTokenId);
            contractEddieOG.burnSacrifice(originalTokenId);

            // save data on new token
            ogTokenId[newTokenId] = originalTokenId;
            hp[newTokenId] = MAX_HP;
            _saveSeed(newTokenId); // reshuffle
            //seeds[newTokenId] = contractEddieOG.seeds(originalTokenId); // copy seed over
        }

        //_safeMint(sender, num);
        _mint(sender, num);
    }

    function _rerollEddie(uint256 tokenId) verifyTokenId(tokenId) private {
        require(revealed == true, "Not revealed");
        require(hp[tokenId] > 0, "No HP");
        require(msg.sender == ownerOf(tokenId), "Not yours");

        _saveSeed(tokenId);   
        _takeDamageHP(tokenId, msg.sender);

        emit EddieRerolled(tokenId);
    }

    /// @notice Rerolls the visuals and stats of one CryptoEddie, deals -1 HP damage!
    /// @param tokenId The token ID for the CryptoEddie to reroll
    function rerollEddie(uint256 tokenId) external {
        require(rerollingEnabled == true);
        _rerollEddie(tokenId);
    }

    /// @notice Rerolls the visuals and stats of many CryptoEddies, deals -1 HP damage!
    /// @param tokenIds An array of token IDs
    function rerollEddieMany(uint256[] calldata tokenIds) external {
        require(rerollingEnabled == true);
        uint256 num = tokenIds.length;
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            _rerollEddie(tokenId);
        }
    }

    function _saveSeed(uint256 tokenId) private {
        seeds[tokenId] = uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), tokenId, msg.sender)));
    }

    /// @notice Destroys your CryptoEddie, spawning a ghost
    /// @param tokenId The token ID for the CryptoEddie
    function burnSacrifice(uint256 tokenId) external onlyApprovedOrOwner(tokenId) {
        //require(msg.sender == ownerOf(tokenId), "Not yours");
        require(burnSacrificeEnabled == true);

        address ownerOfEddie = ownerOf(tokenId);

        _burn(tokenId);

        // if not already dead, force kill and spawn ghost
        if (hp[tokenId] > 0) {
            hp[tokenId] = 0;
        
             // cancel vibing
            _resetAndCancelVibing(tokenId);

            emit EddieDied(tokenId);

            if (address(contractGhost) != address(0)) {
                contractGhost.spawnGhost(ownerOfEddie, tokenId, seeds[tokenId]);
            }
        }

        emit EddieSacrificed(tokenId);
    }

    function _startTokenId() override internal pure virtual returns (uint256) {
        return 1;
    }

    // taken from 'ERC721AQueryable.sol'
    function tokensOfOwner(address owner) external view returns (uint256[] memory) {
        unchecked {
            uint256 tokenIdsIdx;
            address currOwnershipAddr;
            uint256 tokenIdsLength = balanceOf(owner);
            uint256[] memory tokenIds = new uint256[](tokenIdsLength);
            TokenOwnership memory ownership;
            for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            return tokenIds;
        }
    }

    function setContractEddieOG(address newAddress) external onlyOwner {
        contractEddieOG = CryptoEddies(newAddress);
    }

    function setContractGhost(address newAddress) external onlyOwner {
        contractGhost = CryptoDeddiesV2(newAddress);
    }

    function setClaimEnabled(bool _enabled) external onlyOwner {
        claimEnabled = _enabled;
    }

    function setContractHpEffector(address newAddress) external onlyOwner {
        contractHpEffector = newAddress;
    }

    function setRevealed(bool _revealed) external onlyOwner {
        revealed = _revealed;
    }

    function setRerollingEnabled(bool _enabled) external onlyOwner {
        rerollingEnabled = _enabled;
    }

    function setBurnSacrificeEnabled(bool _enabled) external onlyOwner {
        burnSacrificeEnabled = _enabled;
    }

    // props to @cygaar_dev
    //error SteveAokiNotAllowed();
    //address public constant STEVE_AOKI_ADDRESS = 0xe4bBCbFf51e61D0D95FcC5016609aC8354B177C4;

    function _beforeTokenTransfers(address from, address to, uint256 startTokenId, uint256 quantity) internal override {
        // removed to optimize gas, u are now re-admitted into the club, Mr. Aoki
        /*if (to == STEVE_AOKI_ADDRESS) { // sorry Mr. Aoki
            revert SteveAokiNotAllowed();
        }*/

        if (from == address(0) || to == address(0))  // bypass for minting and burning
            return;

        for (uint256 tokenId = startTokenId; tokenId < startTokenId + quantity; ++tokenId) {
            //require(hp[tokenId] > 0, "No more HP"); // soulbound?

            // transfers reduces HP
            _takeDamageHP(tokenId, from);
        }
    }

    function _takeDamageHP(uint256 tokenId, address mintGhostTo) private verifyTokenId(tokenId){
        if (hp[tokenId] == 0) // to make sure it doesn't wrap around
            return;

        hp[tokenId] -= 1;

        // taking damage resets your vibing
        _resetAndCancelVibing(tokenId);

        if (hp[tokenId] == 0) {
            emit EddieDied(tokenId);

            if (address(contractGhost) != address(0)) {
                contractGhost.spawnGhost(mintGhostTo, tokenId, seeds[tokenId]);
            }
        }
    }

    function rewardManyHP(uint256[] calldata tokenIds, int hpRewarded) external /*onlyOwner*/ {
        // only admin or another authorized smart contract can change HP
        // perhaps a hook for future content? ;)
        require(owner() == _msgSender() || (contractHpEffector != address(0) && _msgSender() == contractHpEffector), "Not authorized");

        uint256 num = tokenIds.length;
        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];

            if (hp[tokenId] > 0 ) { // not dead

                int newHp = int256(hp[tokenId]) + hpRewarded;

                // clamping between [0,MAX_HP]
                if (newHp > int(MAX_HP)) 
                    newHp = int(MAX_HP);
                
                else if (newHp <= 0) {
                    newHp = 0;

                    // spawn ghost
                    emit EddieDied(tokenId);
                    if (address(contractGhost) != address(0)) {
                        contractGhost.spawnGhost(ownerOf(tokenId), tokenId, seeds[tokenId]);
                    }
                }

                hp[tokenId] = uint256(newHp);

                // taking damage resets your vibing
                if (hpRewarded < 0) {
                     _resetAndCancelVibing(tokenId);
                }
            }
        }
    }

    /// @notice Retrieves the HP
    /// @param tokenId The token ID for the CryptoEddie
    /// @return hp the amount of HP for the CryptoEddie
    function getHP(uint256 tokenId) external view verifyTokenId(tokenId) returns(uint){
        return hp[tokenId];
    }

    function numberMinted(address addr) external view returns(uint256){
        return _numberMinted(addr);
    }

    ///////////////////////////
    // -- TOKEN URI --
    ///////////////////////////
    function _tokenURI(uint256 tokenId) private view returns (string memory) {
        string[6] memory lookup = [  '0', '1', '2', '3', '4', '5'];
        uint256 seed = seeds[tokenId];
        string memory image = contractEddieOG.getSVG(seed);

        string memory json = Base64.encode(
            bytes(string(
                abi.encodePacked(
                    '{"name": ', '"CryptoEddie #', Strings.toString(tokenId),'",',
                    '"description": "CryptoEddies is an 100% on-chain experimental NFT character project with unique functionality, inspired by retro Japanese RPGs. Formerly known as CryptoEddie #', Strings.toString(ogTokenId[tokenId]),'.",',
                    '"attributes":[',
                        contractEddieOG.getTraitsMetadata(seed),
                        _getStatsMetadata(seed),
                        '{"trait_type":"Vibing?", "value":', (vibingStartTimestamp[tokenId] != NULL_VIBING) ? '"Yes"' : '"Nah"', '},',
                        //'{"trait_type":"OG TokenID", "value":', Strings.toString(ogTokenId[tokenId]), '},',
                        '{"trait_type":"HP", "value":',lookup[hp[tokenId]],', "max_value":',lookup[MAX_HP],'}'
                    '],',
                    '"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}' 
                )
            ))
        );

        return string(abi.encodePacked('data:application/json;base64,', json));
    }

    function _tokenUnrevealedURI(uint256 tokenId) private view returns (string memory) {
        uint256 seed = seeds[tokenId];
        string memory image = contractEddieOG.getUnrevealedSVG(seed);

        string memory json = Base64.encode(
            bytes(string(
                abi.encodePacked(
                    '{"name": ', '"CryptoEddie #', Strings.toString(tokenId),'",',
                    '"description": "CryptoEddies is an 100% on-chain experimental character art project, chillin on the Ethereum blockchain.",',
                    '"attributes":[{"trait_type":"Unrevealed", "value":"True"}],',
                    '"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}' 
                )
            ))
        );

        return string(abi.encodePacked('data:application/json;base64,', json));
    }

    function tokenURI(uint256 tokenId) override(ERC721A) public view verifyTokenId(tokenId) returns (string memory) {
        if (revealed) 
            return _tokenURI(tokenId);
        else
            return _tokenUnrevealedURI(tokenId);
    }

    function _randStat(uint256 seed, uint256 div, uint256 min, uint256 max) private pure returns (uint256) {
        return min + (seed/div) % (max-min);
    }

    function _getStatsMetadata(uint256 seed) private pure returns (string memory) {
        string[11] memory lookup = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10' ];

        string memory metadata = string(abi.encodePacked(
          '{"trait_type":"Determination", "display_type": "number", "value":', lookup[_randStat(seed, 2, 2, 10)], '},',
          '{"trait_type":"Love", "display_type": "number", "value":', lookup[_randStat(seed, 3, 2, 10)], '},',
          '{"trait_type":"Cringe", "display_type": "number", "value":', lookup[_randStat(seed, 4, 2, 10)], '},',
          '{"trait_type":"Bonk", "display_type": "number", "value":', lookup[_randStat(seed, 5, 2, 10)], '},',
          '{"trait_type":"Magic Defense", "display_type": "number", "value":', lookup[_randStat(seed, 6, 2, 10)], '},'
        ));

        return metadata;
    }

    function withdraw() external onlyOwner {
        uint balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }

    ///////////////////////////
    // -- VIBING --
    ///////////////////////////

    bool public isVibingEnabled = false;

    // vibing
    mapping(uint256 => uint256) private vibingStartTimestamp; // tokenId -> vibing start time (0 = not vibing).
    mapping(uint256 => uint256) private vibingTotalTime; // tokenId -> cumulative vibing time, does not include current time if vibing
    
    uint256 private constant NULL_VIBING = 0;
    event EventStartVibing(uint256 indexed tokenId);
    event EventEndVibing(uint256 indexed tokenId);
    event EventForceEndVibing(uint256 indexed tokenId);

    // currentVibingTime: current vibing time in secs (0 = not vibing)
    // totalVibingTime: total time of vibing (in secs)
    function getVibingInfoForToken(uint256 tokenId) external view returns (uint256 currentVibingTime, uint256 totalVibingTime)
    {
        currentVibingTime = 0;
        uint256 startTimestamp = vibingStartTimestamp[tokenId];

        // is vibing?
        if (startTimestamp != NULL_VIBING) { 
            currentVibingTime = block.timestamp - startTimestamp;
        }

        totalVibingTime = currentVibingTime + vibingTotalTime[tokenId];
    }

    function setVibingEnabled(bool allowed) external onlyOwner {
        require(allowed != isVibingEnabled);
        isVibingEnabled = allowed;
    }

    function _toggleVibing(uint256 tokenId) private onlyApprovedOrOwner(tokenId)
    {
        require(hp[tokenId] > 0);

        uint256 startTimestamp = vibingStartTimestamp[tokenId];

        if (startTimestamp == NULL_VIBING) { 
            // start vibing
            require(isVibingEnabled, "Disabled");
            vibingStartTimestamp[tokenId] = block.timestamp;

            emit EventStartVibing(tokenId);
        } else { 
            // start unvibing
            vibingTotalTime[tokenId] += block.timestamp - startTimestamp;
            vibingStartTimestamp[tokenId] = NULL_VIBING;

            emit EventEndVibing(tokenId);
        }
    }

    function toggleVibing(uint256[] calldata tokenIds) external {
        uint256 num = tokenIds.length;

        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            _toggleVibing(tokenId);
        }
    }

    function _resetAndCancelVibing(uint256 tokenId) private {
        if (vibingStartTimestamp[tokenId] != NULL_VIBING) {
            vibingStartTimestamp[tokenId] = NULL_VIBING;
            emit EventEndVibing(tokenId);
        }

        // clear total time
        if (vibingTotalTime[tokenId] != NULL_VIBING)    
            vibingTotalTime[tokenId] = NULL_VIBING;
    }

    function _adminForceStopVibing(uint256 tokenId) private {
        require(vibingStartTimestamp[tokenId] != NULL_VIBING, "Character not vibing");
        
        // accum current time
        uint256 deltaTime = block.timestamp - vibingStartTimestamp[tokenId];
        vibingTotalTime[tokenId] += deltaTime;

        // no longer vibing
        vibingStartTimestamp[tokenId] = NULL_VIBING;

        emit EventEndVibing(tokenId);
        emit EventForceEndVibing(tokenId);
    }

    function adminForceStopVibing(uint256[] calldata tokenIds) external onlyOwner {
        uint256 num = tokenIds.length;

        for (uint256 i = 0; i < num; ++i) {
            uint256 tokenId = tokenIds[i];
            _adminForceStopVibing(tokenId);
        }
    }
}

File 33 of 33 : CryptoDeddiesV2.sol
// SPDX-License-Identifier: MIT

/*
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000  CRYPTO EDDIE GHOST 0000000000000000000000000000000000000
000000000000000000000000000000000000000000    by @eddietree    0000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000KXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXK000000000000000000000000000
00000000000000000000000000000000KNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWK000000000000000000000000000
00000000000000000000000000000KXXKOxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxk0XXKK00000000000000000000000
0000000000000000000000000000KNWMK;                                     .kMMWX00000000000000000000000
000000000000000000000000KKKKKOOOxc''''''''''''''''''''''''''''''''''''';dOOO0KKKK0000000000000000000
000000000000000000000000XWWW0,  .xNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNO,  .dWWWX0000000000000000000
000000000000000000000KKKK000x;..,OWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMKc..'o000KKKKK000000000000000
00000000000000000000XWWWk'..,kXXNWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWNXX0c...oNWWXK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMX:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMMWWWWWWWWWWWWWWWWWWWMMMMWWWWWWWWWWWK:   lNMMNK00000000000000
00000000000000000000XWMMx.  .OMMMMMMMMMMWKkxxxxxxxxxxxxxxxxKWMWKkxxxxxxxxxxdc,,;xNMMNK00000000000000
00000000000000000000XWMWx.  .OMMMMMMMMMWWOlccccccccccccccclkNWW0lcccccccccccccclkNMMNK00000000000000
0000000000000000KNNXkc::'   .lkkkkkkkkkkxdlccokO0xl;..';cccoxkxdlccok00x;..';cclkNMMNK00000000000000
0000000000000000NWMWo       .;cccccccccccccccxXWM0o'   ,cccccccccccdXWM0,   ,cclkNMMNK00000000000000
000000000000KXXXxlclloolollodkOOOOOOOOOOOdlccxXWM0o'   ,ccldkOOxlccdXWM0,   ,cclkNMMNK00000000000000
00000000000KNWMNc   cNMMMMMMMMMMMMMMMMMMWOlccxXWM0o'   ,cclONWW0lccdXWM0,   ,cclkNMMNK00000000000000
00000000000KNMMNc   cNMMMMMMMMMMMMMMMMMMWOlccokOOxl;..';cclONMW0lccokOOx;..';cccloookKXXK00000000000
00000000000KNMMNc   cNMMMMMMMMMMMMMMMMMMW0lccccccccccccccclONWW0lccccccccccccccc'   ;XMMNK0000000000
00000000000KXNNXd:;:ldxxxxxxONMMMMMMMMMMWKkxxo;,,;coxxxxxxkKWMWXkxxxxxxxxxxxxxxx;   ;XMMNK0000000000
000000000000000KXWWNo.      'OMMMMMMMMMMMMWWWx.  .cOWWWWWWWWMMMMWWWWWWWWWWWWWWWNl   ;XMMNK0000000000
0000000000000000XNNNx;,,,,,,:dkkOXMMMMMMMMMMM0:,,:ldkkkO000O000Okkk0WMMMMMMMMMMNl   ;XMMNK0000000000
00000000000000000000XNNNNNNNO'  .kWMMMMMMMMMMWWNNOo,  .',,,,;,,'.  ;KMMMMMMMMMMNl   ;XMMNK0000000000
00000000000000000000XNWWWWWW0:..,d000XMMMMMMMMMMMKxc..'',,,,,,,''..cKMMMMMMWX00Ol'..lKWWNK0000000000
0000000000000000000000KKK0K0KXXX0:. .dWMMMMMMMMMMWWNXX0l,,,,,,,l0XXNWMMMMMMXc...lKNXXK0K000000000000
0000000000000000000000000KKKKKKKO:...l0KKKKKKKKKKKKKKKOc'''''''cOKKKKKKKKKKOc...oNWWXK00000000000000
000000000000000000000000KNWW0;..'dKK0l.................         ...........'oKKKKKKK0000000000000000
00000000000000000000000KKXXXk,..'kWMNo..       ... .. .............      . .xWWWX0000000000000000000
00000000000000000000XNWNk;..;x00KNMMWX00000000000000000000000000000o.  .o0000KKKK0000000000000000000
00000000000000000000XNNNx.  '0MMMWNNWWMMMMMMMMMMMMMMMMMMMMMMMMMWWNNk.  .kMMWX00000000000000000000000
0000000000000000XNNNx;,,cxkk0NMMXo,,;kWMMMMMMMMMMMMMMMMMMMMMMMWO:,,.   .kMMWX00000000000000000000000
000000000000000KNWMWo   ;KMMMMMMK;   oNWWMMMMMMMMMMMMMMMMMMMMMWd.      .kWWWX00000000000000000000000
0000000KXNNNNNNNWMMWo   ,KMMMMMMW0xddl:;:xNMMMMMMMMMMMMMMMMMMMWd.  .lxddc;;ckXNNK0000000000000000000
0000000KWMMMMMMMMMMWo   ;KMMMMMMMMMMNc   :XMMMMMMMMMMMMMMMMMMMWd.  ,0MM0,  .dWMWX0000000000000000000
000KXNN0occccccl0WMWKdoolcccdXMMMMMMNc   :XMMMMMMMMMMMMMMMMMMMWd.  ,0MM0'  .dWMWX0000000000000000000
000XWMMO.       oWMMMMMMx.  .OMMMMMMNc   :XMMMMMMMMMMMMMMMMMMMWd.  ,0MM0,  .dWMWX0000000000000000000
XXXOollllllllllllllllllllllllllllllllllllkWMMMMMMMMMMMMMMMMMMMWd.  .:lllllloOXXXK0000000000000000000
MMWx.  '0MMMMMMNc       ;KMMO'       oWMMMMMMMMMMMMMMMMMMMMMMMWd.      .kMMWX00000000000000000000000
NNNOl::coddxXMMWkc::::::dNMMXo::::::cOWMMMMMMMMMMMMMMMMMMMMMMMWd.  .,::l0NNXK00000000000000000000000
000XWWWO.  .kWMMMWWMMWMMMMMMMWWWWMWMMMMMMMMMMMMMMMMMMMMMMMMMMMWd.  ,0WWNK000000000000000000000000000
000KNNN0c,,:oxxkXWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMWKkkxo;,;lKNNXK000000000000000000000000000
0000000KNWW0;  .dWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNl.  :KWWNK0000000000000000000000000000000
0000000KWMMK,   oWMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNl   :XMMNK0000000000000000000000000000000
*/
// thx CB1 for the name

pragma solidity ^0.8.4;

import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import 'base64-sol/base64.sol';

import "./EddieRenderer.sol";
import "./CryptoEddiesV2.sol";

contract CryptoDeddiesV2 is ERC721A, Ownable {
    struct GhostData {
        uint256 eddieTokenId;
        uint256 eddieTokenSeed;
    }

    EddieRenderer public contractRenderer;
    CryptoEddiesV2 public contractEddiesV2;

    mapping(uint256 => GhostData) public ghostData; // tokenid => ghost data
    error EddieGhostIsSoulbound();
    event EddieGhostSpawned(uint256 indexed tokenId, uint256 indexed eddieTokenId, uint256 indexed eddieTokenSeed); // emitted when an HP goes to zero

    constructor(address _contractRenderer) ERC721A("CryptoDeddiesV2", "DEDDIEV2") {
        contractRenderer = EddieRenderer(_contractRenderer);
    }

    modifier verifyTokenId(uint256 tokenId) {
        require(tokenId >= _startTokenId() && tokenId <= _totalMinted(), "Out of bounds");
        _;
    }

    function _startTokenId() override internal pure virtual returns (uint256) {
        return 1;
    }

    function spawnGhost(address to, uint256 eddieTokenId, uint256 eddieTokenSeed) external {
        require(msg.sender == address(contractEddiesV2), "Only callable from contract");
        _mintGhost(to, eddieTokenId, eddieTokenSeed);
    }

    function spawnGhostAdmin(address to, uint256 eddieTokenId, uint256 eddieTokenSeed) external onlyOwner {
        _mintGhost(to, eddieTokenId, eddieTokenSeed);
    }

    function _mintGhost(address to, uint256 eddieTokenId, uint256 eddieTokenSeed) private {
        _safeMint(to, 1);

        // save ghost data
        uint256 tokenId = _totalMinted();
        ghostData[tokenId] = GhostData({
            eddieTokenId: eddieTokenId,
            eddieTokenSeed: eddieTokenSeed
        });

        emit EddieGhostSpawned(tokenId, eddieTokenId, eddieTokenSeed);
    }

    // block transfers (soulbound)
    function _beforeTokenTransfers(address from, address, uint256, uint256) internal pure override {
        //if (from != address(0) && to != address(0)) {
        if (from != address(0)) { // not burnable
            revert EddieGhostIsSoulbound();
        }
    }

    function setContractRenderer(address newAddress) external onlyOwner {
        contractRenderer = EddieRenderer(newAddress);
    }

    function setContractEddieV2(address newAddress) external onlyOwner {
        contractEddiesV2 = CryptoEddiesV2(newAddress);
    }


    function tokenURI(uint256 tokenId) override(ERC721A) public view verifyTokenId(tokenId) returns (string memory) {
        require(_exists(tokenId), "Nonexistent token");

        GhostData memory ghost = ghostData[tokenId];
        uint256 eddieTokenId = ghost.eddieTokenId;
        uint256 seed = ghost.eddieTokenSeed;

        string memory image = contractRenderer.getGhostSVG(seed);

        string memory json = Base64.encode(
            bytes(string(
                abi.encodePacked(
                    '{"name": ', '"CryptoDeddie Ghost #', Strings.toString(eddieTokenId),'",',
                    '"description": "CryptoDeddie Ghost is a memorialized ghost of your original CryptoEddie, forever soulbound to your wallet.",',
                    '"attributes":[',
                        contractRenderer.getTraitsMetadata(seed),
                        '{"trait_type":"Dead", "value":"True"}, {"trait_type":"Soulbound", "value":"True"}'
                    '],',
                    '"image": "data:image/svg+xml;base64,', Base64.encode(bytes(image)), '"}' 
                )
            ))
        );

        return string(abi.encodePacked('data:application/json;base64,', json));
    }

    function withdraw() public onlyOwner {
        uint balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200,
    "details": {
      "yul": false
    }
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"ApproveToCaller","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"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":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenIdDied","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"level","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"tokenMergedInto","type":"uint256"}],"name":"EthKunDied","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldLevel","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newLevel","type":"uint256"}],"name":"EthKunLevelUp","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"EthKunSacrificed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newLevel","type":"uint256"}],"name":"EthRerolled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenIdParent","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"tokenIdBaby","type":"uint256"}],"name":"EventBirthBaby","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"EventEndSteaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"EventForceEndSteaking","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"EventStartSteaking","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":"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":[],"name":"MAX_TOKEN_SUPPLY_GENESIS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SECS_PER_DAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"adminForceStopSteaking","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":"tokenId","type":"uint256"}],"name":"burnSacrifice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"burnSacrificeEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"canSpawnEthKunBaby","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"contractRenderer","outputs":[{"internalType":"contract IEthKunRenderer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"demoteRerollEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxMintsData","outputs":[{"internalType":"uint256","name":"maxTokensOwnedInWallet","type":"uint256"},{"internalType":"uint256","name":"maxMintsPerTransaction","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumBabiesMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"numToMint","type":"uint256"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getSecsSteakingRequiredToMintBaby","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getSteakingInfoForToken","outputs":[{"internalType":"uint256","name":"currentSteakingTime","type":"uint256"},{"internalType":"uint256","name":"totalSteakingTime","type":"uint256"},{"internalType":"bool","name":"steaking","type":"bool"}],"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":"tokenId","type":"uint256"}],"name":"isGenesis","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"level","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"merge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mergeBlockNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mergeEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleMintEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleMintMax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minSteakingLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"parentTokenIds","type":"uint256[]"}],"name":"mintEthKunBaby","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numToMint","type":"uint256"}],"name":"mintEthKunsGenesis","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"_merkleProof","type":"bytes32[]"},{"internalType":"uint256","name":"numToMint","type":"uint256"}],"name":"mintMerkle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintStatus","outputs":[{"internalType":"enum EthKun.MintStatus","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintingBabiesEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"numberMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"rerollMany","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"numToMint","type":"uint256"}],"name":"reserveEthKuns","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"recipients","type":"address[]"},{"internalType":"uint256","name":"numToMint","type":"uint256"}],"name":"reserveEthKunsMany","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"seeds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setBurnSacrificeEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"setContractRenderer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setDemoteRerollEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxLevel","type":"uint256"}],"name":"setMaxLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMergeBlockNumber","type":"uint256"}],"name":"setMergeBlockNumber","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setMergeEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_enabled","type":"bool"}],"name":"setMerkleMintEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"}],"name":"setMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_status","type":"uint256"}],"name":"setMintStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"allowed","type":"bool"}],"name":"setMintingBabiesEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"pricingData","type":"uint256[]"}],"name":"setPricing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_revealEnabled","type":"bool"}],"name":"setRevealed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"allowed","type":"bool"}],"name":"setSteakingEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minLvl","type":"uint256"}],"name":"setSteakingMinLevel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_steakingMinDays","type":"uint256"},{"internalType":"uint256","name":"_steakingCurveDivisor","type":"uint256"},{"internalType":"uint256","name":"_steakingLevelBoostDivisor","type":"uint256"}],"name":"setSteakingParams","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"steakingCurveDivisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"steakingEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"steakingLevelBoostDivisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"steakingMinDays","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","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":[],"name":"tier0_maxMintsPerTransaction","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tier0_maxTokensOwnedInWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tier0_price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tier0_supply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tier1_maxMintsPerTransaction","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tier1_maxTokensOwnedInWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tier1_price","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"toggleSteaking","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":[{"internalType":"address","name":"owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"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":"bytes32[]","name":"_proof","type":"bytes32[]"},{"internalType":"bytes32","name":"_leaf","type":"bytes32"}],"name":"verifyMerkle","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"_proof","type":"bytes32[]"},{"internalType":"address","name":"from","type":"address"}],"name":"verifyMerkleAddress","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060409081526009805464ffffffffff60a01b19169055600c8190556000600d8190556107d0600e55600f819055600260108181556001601155662386f26fc1000060125560138490556014939093556015919091556016805462ffffff1916905560086017819055601891909155601955601a553480156200008257600080fd5b506040518060400160405280600681526020016532ba3435bab760d11b8152506040518060400160405280600681526020016522aa2425aaa760d11b8152508160029080519060200190620000d99291906200015a565b508051620000ef9060039060208401906200015a565b5050600160005550620001023362000108565b62000247565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b828054620001689062000216565b90600052602060002090601f0160209004810192826200018c5760008555620001d7565b82601f10620001a757805160ff1916838001178555620001d7565b82800160010185558215620001d7579182015b82811115620001d7578251825591602001919060010190620001ba565b50620001e5929150620001e9565b5090565b5b80821115620001e55760008155600101620001ea565b634e487b7160e01b600052602260045260246000fd5b6002810460018216806200022b57607f821691505b6020821081141562000241576200024162000200565b50919050565b614a4580620002576000396000f3fe6080604052600436106104945760003560e01c80637e980e0011610260578063cb9d5b9e11610144578063e7b5ec0f116100c1578063f0503e8011610085578063f0503e8014610dd1578063f1e25ea814610dfe578063f2fde38b14610e21578063f5cbd52b14610e41578063f7da7b3b14610e57578063ffd3332e14610e6d57600080fd5b8063e7b5ec0f14610d23578063e8ff352514610d50578063e934028914610d70578063e985e9c514610d91578063efdb28db14610db157600080fd5b8063de62d84211610108578063de62d84214610c8c578063e035740314610cac578063e0a8085314610cc2578063e33e4b4914610ce2578063e757223014610d0357600080fd5b8063cb9d5b9e14610c05578063cc06c35914610c1c578063da97398e14610c32578063daeaeb0314610c4c578063dc33e68114610c6c57600080fd5b8063a22cb465116101dd578063afdb45a8116101a1578063afdb45a814610b45578063b88d4fde14610b65578063bc640bd014610b85578063bfa584d214610ba5578063c5c5c71c14610bc5578063c87b56dd14610be557600080fd5b8063a22cb46514610aba578063a3bcb09a14610ada578063acec8a5f14610afa578063ad031fb014610b19578063ad99cc8a14610b2f57600080fd5b80638da5cb5b116102245780638da5cb5b14610a2557806395d89b4114610a435780639ad7a0f614610a585780639aedee3a14610a795780639da3f8fd14610a8c57600080fd5b80637e980e001461098257806381bbc8ef146109a25780638462151c146109c2578063887fee31146109ef5780638cf4f3a514610a0f57600080fd5b8063344f1ba5116103875780636352211e1161030457806370a08231116102c857806370a08231146108d757806370f34a87146108f75780637149b6d314610917578063715018a614610937578063786d5b471461094c5780637cb647591461096257600080fd5b80636352211e1461084b578063668b63c41461086b578063697e2224146108815780636ca76d1f146108975780636d49cdfa146108b757600080fd5b80634a89c50b1161034b5780634a89c50b146107ca5780634bc9f48a146107e05780634d99d976146108005780635030c70714610815578063540da96c1461083557600080fd5b8063344f1ba51461074b5780633726230a1461076b57806337e348df146107805780633ccfd60b1461079557806342842e0e146107aa57600080fd5b806317cbab92116104155780632ddfd5ba116103d95780632ddfd5ba146106ad5780632eb4a7ab146106cd5780632f5b1cea146106e3578063324d34bc1461070657806332a125b31461073557600080fd5b806317cbab921461061a57806318160ddd1461063a5780631f8fe21a1461065757806323b872dd14610677578063295020be1461069757600080fd5b806306fdde031161045c57806306fdde031461056b578063081812fc1461058d57806308683e71146105ba578063095ea7b3146105da5780630b269898146105fa57600080fd5b806301ffc9a7146104995780630270a072146104cf578063034e39ee146104f157806304acc3771461051157806305c58df214610531575b600080fd5b3480156104a557600080fd5b506104b96104b43660046134a3565b610e8e565b6040516104c691906134ce565b60405180910390f35b3480156104db57600080fd5b506104ef6104ea36600461352d565b610ee0565b005b3480156104fd57600080fd5b506104ef61050c3660046135aa565b61102e565b34801561051d57600080fd5b506104ef61052c3660046135e7565b611044565b34801561053d57600080fd5b5061055e61054c366004613637565b600b6020526000908152604090205481565b6040516104c6919061365e565b34801561057757600080fd5b5061058061105a565b6040516104c691906136ca565b34801561059957600080fd5b506105ad6105a8366004613637565b6110ec565b6040516104c691906136e4565b3480156105c657600080fd5b506104ef6105d5366004613705565b611130565b3480156105e657600080fd5b506104ef6105f53660046135aa565b611156565b34801561060657600080fd5b506104ef61061536600461352d565b6111f6565b34801561062657600080fd5b506104b9610635366004613637565b6112e9565b34801561064657600080fd5b50600154600054036000190161055e565b34801561066357600080fd5b5061055e610672366004613637565b6112f4565b34801561068357600080fd5b506104ef610692366004613726565b6112ff565b3480156106a357600080fd5b5061055e60185481565b3480156106b957600080fd5b506104ef6106c8366004613705565b611495565b3480156106d957600080fd5b5061055e60155481565b3480156106ef57600080fd5b506106f86114bb565b6040516104c692919061375b565b34801561071257600080fd5b50610726610721366004613637565b6114ce565b6040516104c693929190613776565b34801561074157600080fd5b5061055e60115481565b34801561075757600080fd5b506104ef610766366004613637565b61151a565b34801561077757600080fd5b5061055e611527565b34801561078c57600080fd5b5061055e611536565b3480156107a157600080fd5b506104ef611540565b3480156107b657600080fd5b506104ef6107c5366004613726565b611577565b3480156107d657600080fd5b5061055e600d5481565b3480156107ec57600080fd5b506104ef6107fb366004613637565b611597565b34801561080c57600080fd5b5061055e600181565b34801561082157600080fd5b506104ef610830366004613705565b6115a4565b34801561084157600080fd5b5061055e60195481565b34801561085757600080fd5b506105ad610866366004613637565b6115c8565b34801561087757600080fd5b5061055e60105481565b34801561088d57600080fd5b5061055e600f5481565b3480156108a357600080fd5b506104ef6108b236600461352d565b6115d3565b3480156108c357600080fd5b506104ef6108d236600461352d565b61161e565b3480156108e357600080fd5b5061055e6108f236600461379e565b611628565b34801561090357600080fd5b506104ef610912366004613705565b611676565b34801561092357600080fd5b506104ef610932366004613705565b61169c565b34801561094357600080fd5b506104ef6116be565b34801561095857600080fd5b5061055e6116f381565b34801561096e57600080fd5b506104ef61097d366004613637565b6116d2565b34801561098e57600080fd5b506104ef61099d366004613637565b6116df565b3480156109ae57600080fd5b506104b96109bd3660046137bf565b61177f565b3480156109ce57600080fd5b506109e26109dd36600461379e565b6117c1565b6040516104c6919061386c565b3480156109fb57600080fd5b506104ef610a0a366004613637565b6118d0565b348015610a1b57600080fd5b5061055e60135481565b348015610a3157600080fd5b506008546001600160a01b03166105ad565b348015610a4f57600080fd5b50610580611914565b348015610a6457600080fd5b506009546104b990600160a81b900460ff1681565b6104ef610a87366004613637565b611923565b348015610a9857600080fd5b50600954610aad90600160a01b900460ff1681565b6040516104c691906138c6565b348015610ac657600080fd5b506104ef610ad53660046138d4565b611a49565b348015610ae657600080fd5b506104b9610af5366004613907565b611ae2565b348015610b0657600080fd5b506016546104b990610100900460ff1681565b348015610b2557600080fd5b5061055e601a5481565b348015610b3b57600080fd5b5061055e60125481565b348015610b5157600080fd5b506104ef610b60366004613907565b611af7565b348015610b7157600080fd5b506104ef610b80366004613a43565b611b5c565b348015610b9157600080fd5b506104ef610ba0366004613637565b611ba0565b348015610bb157600080fd5b506104ef610bc036600461379e565b611bad565b348015610bd157600080fd5b506016546104b99062010000900460ff1681565b348015610bf157600080fd5b50610580610c00366004613637565b611bd7565b348015610c1157600080fd5b5061055e6201518081565b348015610c2857600080fd5b5061055e600c5481565b348015610c3e57600080fd5b506016546104b99060ff1681565b348015610c5857600080fd5b506104ef610c67366004613907565b611c3a565b348015610c7857600080fd5b5061055e610c8736600461379e565b611d46565b348015610c9857600080fd5b506104ef610ca736600461352d565b611d51565b348015610cb857600080fd5b5061055e600e5481565b348015610cce57600080fd5b506104ef610cdd366004613705565b611d94565b348015610cee57600080fd5b506009546104b990600160b01b900460ff1681565b348015610d0f57600080fd5b5061055e610d1e366004613637565b611dba565b348015610d2f57600080fd5b50600954610d43906001600160a01b031681565b6040516104c69190613ae0565b348015610d5c57600080fd5b506104ef610d6b36600461352d565b611dc5565b348015610d7c57600080fd5b506009546104b990600160b81b900460ff1681565b348015610d9d57600080fd5b506104b9610dac366004613aee565b611e08565b348015610dbd57600080fd5b506104ef610dcc366004613705565b611e36565b348015610ddd57600080fd5b5061055e610dec366004613637565b600a6020526000908152604090205481565b348015610e0a57600080fd5b506104b9610e19366004613637565b6116f3101590565b348015610e2d57600080fd5b506104ef610e3c36600461379e565b611e51565b348015610e4d57600080fd5b5061055e60145481565b348015610e6357600080fd5b5061055e60175481565b348015610e7957600080fd5b506009546104b990600160c01b900460ff1681565b60006301ffc9a760e01b6001600160e01b031983161480610ebf57506380ac58cd60e01b6001600160e01b03198316145b80610eda5750635b5e139f60e01b6001600160e01b03198316145b92915050565b610ee8611e8b565b8015610efd5750600954600160b81b900460ff165b610f0657600080fd5b8060005b81811015611028576000848483818110610f2657610f26613b21565b9050602002013590506000600b6000838152602001908152602001600020549050610f4e3390565b6001600160a01b0316610f6083611eab565b516001600160a01b031614610f905760405162461bcd60e51b8152600401610f8790613b59565b60405180910390fd5b60018111610fb05760405162461bcd60e51b8152600401610f8790613b8e565b610fb982611ee0565b6000610fc6600183613bb4565b6000848152600b6020526040908190208290555190915083907fc6ca1ad742bbff176a4773a093de94df27d5d29669f999560882d57503dfaaed9061100c90849061365e565b60405180910390a25050508061102190613bcb565b9050610f0a565b50505050565b611036611f28565b6110408282611f52565b5050565b61104c611f28565b601892909255601955601a55565b60606002805461106990613bfc565b80601f016020809104026020016040519081016040528092919081815260200182805461109590613bfc565b80156110e25780601f106110b7576101008083540402835291602001916110e2565b820191906000526020600020905b8154815290600101906020018083116110c557829003601f168201915b5050505050905090565b60006110f782611fb4565b611114576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b611138611f28565b60098054911515600160c01b0260ff60c01b19909216919091179055565b6000611161826115c8565b9050336001600160a01b0382161461119a5761117d8133611e08565b61119a576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6111fe611f28565b8181600081811061121157611211613b21565b6020029190910135600e55508181600181811061123057611230613b21565b6020029190910135600f55508181600281811061124f5761124f613b21565b6020029190910135601055508181600381811061126e5761126e613b21565b6020029190910135601155508181600481811061128d5761128d613b21565b602002919091013560125550818160058181106112ac576112ac613b21565b602002919091013560135550818160068181106112cb576112cb613b21565b905060200201356014819055506116f3600e54111561104057600080fd5b6000610eda82611fe9565b6000610eda82612072565b600061130a82612125565b9050836001600160a01b0316816001600160a01b03161461133d5760405162a1148160e81b815260040160405180910390fd5b600082815260066020526040902080546113698187335b6001600160a01b039081169116811491141790565b611394576113778633611e08565b61139457604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166113bb57604051633a954ecd60e21b815260040160405180910390fd5b6113c8868686600161218e565b80156113d357600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260046020526040902055600160e11b831661145e576001840160008181526004602052604090205461145c57600054811461145c5760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b03166000805160206149f083398151915260405160405180910390a4505050505050565b61149d611f28565b60098054911515600160b81b0260ff60b81b19909216919091179055565b6000806114c66121f0565b915091509091565b6000818152601b60205260408120548190819080156114f4576114f18142613bb4565b93505b6000858152601c602052604090205461150d9085613c23565b9395939450151592915050565b611522611f28565b600c55565b6000611531612223565b905090565b600061153161222d565b611548611f28565b6040514790339082156108fc029083906000818181858888f19350505050158015611040573d6000803e3d6000fd5b61159283838360405180602001604052806000815250611b5c565b505050565b61159f611f28565b600d55565b6115ac611f28565b60168054911515620100000262ff000019909216919091179055565b6000610eda82612125565b6115db611f28565b8060005b818110156110285760008484838181106115fb576115fb613b21565b90506020020135905061160d8161225d565b5061161781613bcb565b90506115df565b6110408282612332565b60006001600160a01b038216611651576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b61167e611f28565b60098054911515600160b01b0260ff60b01b19909216919091179055565b6116a4611f28565b601680549115156101000261ff0019909216919091179055565b6116c6611f28565b6116d06000612485565b565b6116da611f28565b601555565b80336116ea82611eab565b516001600160a01b03161480611710575033611705826110ec565b6001600160a01b0316145b61172c5760405162461bcd60e51b8152600401610f8790613c68565b600954600160c01b900460ff16151560011461174757600080fd5b611750826124d7565b60405182907f0f1711c7762713c236f84b2fa04e1ef0923424ade89cb73e02eafab2ed4af22a90600090a25050565b600080826040516020016117939190613ca0565b6040516020818303038152906040528051906020012090506117b68585836124e2565b9150505b9392505050565b606060008060006117d185611628565b90506000816001600160401b038111156117ed576117ed613957565b604051908082528060200260200182016040528015611816578160200160208202803683370190505b50905061184360408051608081018252600080825260208201819052918101829052606081019190915290565b60015b8386146118c45761185681612525565b9150816040015115611867576118bc565b81516001600160a01b03161561187c57815194505b876001600160a01b0316856001600160a01b031614156118bc57808387806001019850815181106118af576118af613b21565b6020026020010181815250505b600101611846565b50909695505050505050565b6118d8611f28565b8060018111156118ea576118ea61387d565b6009805460ff60a01b1916600160a01b83600181111561190c5761190c61387d565b021790555050565b60606003805461106990613bfc565b80600081116119445760405162461bcd60e51b8152600401610f8790613cdb565b6116f381611950612223565b61195a9190613c23565b11156119785760405162461bcd60e51b8152600401610f8790613d09565b6001600954600160a01b900460ff1660018111156119985761199861387d565b146119b55760405162461bcd60e51b8152600401610f8790613d42565b6119be82612561565b3410156119dd5760405162461bcd60e51b8152600401610f8790613d7d565b6000806119e86121f0565b9150915081846119f73361258d565b611a019190613c23565b1115611a1f5760405162461bcd60e51b8152600401610f8790613db5565b80841115611a3f5760405162461bcd60e51b8152600401610f8790613df9565b6110283385611f52565b6001600160a01b038216331415611a735760405163b06307db60e01b815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b038716808552925291829020805460ff191685151517905590519091907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190611ad69085906134ce565b60405180910390a35050565b6000611aef8484846124e2565b949350505050565b611aff611f28565b8180611b0a57600080fd5b60005b81811015611b5557611b45858583818110611b2a57611b2a613b21565b9050602002016020810190611b3f919061379e565b84611f52565b611b4e81613bcb565b9050611b0d565b5050505050565b611b678484846112ff565b6001600160a01b0383163b1561102857611b83848484846125b5565b611028576040516368d2bf6b60e11b815260040160405180910390fd5b611ba8611f28565b601755565b611bb5611f28565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b60608160018110158015611bf25750611bee612223565b8111155b611c0e5760405162461bcd60e51b8152600401610f8790613d09565b611c16611e8b565b15611c2b57611c24836126ac565b9150611c34565b611c2483612901565b50919050565b8060008111611c5b5760405162461bcd60e51b8152600401610f8790613cdb565b6116f381611c67612223565b611c719190613c23565b1115611c8f5760405162461bcd60e51b8152600401610f8790613d09565b60165460ff161515600114611cb65760405162461bcd60e51b8152600401610f8790613e2d565b600182611cc23361258d565b611ccc9190613c23565b1115611cea5760405162461bcd60e51b8152600401610f8790613e64565b600033604051602001611cfd9190613ca0565b604051602081830303815290604052805190602001209050611d208585836124e2565b611d3c5760405162461bcd60e51b8152600401610f8790613e98565b611b553384611f52565b6000610eda8261258d565b611d59611e8b565b8015611d6e5750600954600160b01b900460ff165b611d8a5760405162461bcd60e51b8152600401610f8790613ecc565b61104082826129ed565b611d9c611f28565b60098054911515600160a81b0260ff60a81b19909216919091179055565b6000610eda82612561565b8060005b81811015611028576000848483818110611de557611de5613b21565b905060200201359050611df781612bc2565b50611e0181613bcb565b9050611dc9565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b611e3e611f28565b6016805460ff1916911515919091179055565b611e59611f28565b6001600160a01b038116611e7f5760405162461bcd60e51b8152600401610f8790613edc565b611e8881612485565b50565b600954600090600160a81b900460ff168015611531575050600d54431190565b604080516080810182526000808252602082018190529181018290526060810191909152610eda611edb83612125565b612d21565b611eeb600143613bb4565b408133604051602001611f0093929190613f26565b60408051601f1981840301815291815281516020928301206000938452600a90925290912055565b6008546001600160a01b031633146116d05760405162461bcd60e51b8152600401610f8790613f8f565b6000611f5c612223565b611f67906001613c23565b9050805b611f758383613c23565b811015611fa957611f8581611ee0565b6000818152600b602052604090206001905580611fa181613bcb565b915050611f6b565b506115928383612d68565b600081600111158015611fc8575060005482105b8015610eda575050600090815260046020526040902054600160e01b161590565b6000818152601b60205260408120548190801561200d5761200a8142613bb4565b91505b6000848152601c60205260408120546120269084613c23565b905061203185612072565b811015801561205057506017546000868152600b602052604090205410155b801561206957506000858152601b602052604090205415155b95945050505050565b60008061207d61222d565b9050600060195482620151806120939190613f9f565b61209d9190613fd4565b6000858152600b602052604081205460175492935090918111156120e557601a546017546120cb9083613bb4565b6120d89062015180613f9f565b6120e29190613fd4565b91505b828211156120f1578291505b60008284620151806018546121069190613f9f565b6121109190613c23565b61211a9190613bb4565b979650505050505050565b600081806001116121755760005481101561217557600081815260046020526040902054600160e01b8116612173575b806117ba575060001901600081815260046020526040902054612155565b505b604051636f96cda160e11b815260040160405180910390fd5b6001600160a01b03841615806121ab57506001600160a01b038316155b156121b557611028565b6001600160a01b0384161561102857815b6121d08284613c23565b811015611b55576121e081612d82565b6121e981613bcb565b90506121c6565b60008060006121fd612223565b9050600e5481106122135760135460145461221a565b6010546011545b92509250509091565b6000546000190190565b600080612238612223565b90506116f3811161224b57600091505090565b6122576116f382613bb4565b91505090565b6000818152601b60205260409020546122885760405162461bcd60e51b8152600401610f8790614015565b6000818152601b60205260408120546122a19042613bb4565b905080601c600084815260200190815260200160002060008282546122c69190613c23565b90915550506000828152601b60205260408082208290555183917f77b32aef15eac84703df273acc09c59be81471f28f8a9eecd503b40cfd7a314091a260405182907f9b890154087c644ebc131cc896b4fc9af428461c07cc581063101c8306adaf1d90600090a25050565b60165462010000900460ff16151560011461235f5760405162461bcd60e51b8152600401610f879061404b565b8060005b8181101561102857600084848381811061237f5761237f613b21565b90506020020135905061238f3390565b6001600160a01b03166123a182611eab565b516001600160a01b031614806123c75750336123bc826110ec565b6001600160a01b0316145b6123e35760405162461bcd60e51b8152600401610f8790614078565b6123ec81611fe9565b6124085760405162461bcd60e51b8152600401610f87906140a8565b61241c61241482611eab565b516001611f52565b6000818152601c60209081526040808320839055601b9091528120429055612442612223565b905080827fb631eca81f936326925370c4b06accb33f19ecea754a9f20fbe4f5edd93d230760405160405180910390a350508061247e90613bcb565b9050612363565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611e88816000612df4565b6000611aef848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506015549150859050612f33565b604080516080810182526000808252602082018190529181018290526060810191909152600082815260046020526040902054610eda90612d21565b60008061256c612223565b9050600e54811061257f57601254612583565b600f545b6117ba9084613f9f565b6001600160a01b03166000908152600560205260409081902054901c6001600160401b031690565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a02906125ea9033908990889088906004016140b8565b602060405180830381600087803b15801561260457600080fd5b505af1925050508015612634575060408051601f3d908101601f1916820190925261263191810190614107565b60015b61268f573d808015612662576040519150601f19603f3d011682016040523d82523d6000602084013e612667565b606091505b508051612687576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b6000818152600a6020908152604080832054600d54600b90935281842054600954925163176f05ed60e11b81526060959490920193909290916001600160a01b0390911690632ede0bda90612707908690869060040161375b565b60006040518083038186803b15801561271f57600080fd5b505afa158015612733573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261275b9190810190614180565b905060006128d461276b87612f49565b600954604051636404fcd160e01b81526001600160a01b0390911690636404fcd19061279b90899060040161365e565b60006040518083038186803b1580156127b357600080fd5b505afa1580156127c7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526127ef9190810190614180565b6127f98787613046565b6116f38a111561282557604051806040016040528060048152602001631127379160e11b815250612844565b60405180604001604052806005815260200164112cb2b99160d91b8152505b60008b8152601b602052604090205461287957604051806040016040528060048152602001631127379160e11b815250612898565b60405180604001604052806005815260200164112cb2b99160d91b8152505b6128a189612f49565b6128aa89613133565b6040516020016128c0979695949392919061433c565b604051602081830303815290604052613133565b9050806040516020016128e7919061449f565b604051602081830303815290604052945050505050919050565b6000818152600a6020526040808220546009549151633521481160e21b815260609391926001600160a01b03169063d48520449061294390859060040161365e565b60006040518083038186803b15801561295b57600080fd5b505afa15801561296f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526129979190810190614180565b905060006129c16129a786612f49565b6129b084613133565b6040516020016128c09291906144d1565b9050806040516020016129d4919061449f565b6040516020818303038152906040529350505050919050565b80806129f857600080fd5b600083836000818110612a0d57612a0d613b21565b9050602002013590506000805b83811015612b46576000868683818110612a3657612a36613b21565b9050602002013590506000600b6000838152602001908152602001600020549050612a5e3390565b6001600160a01b0316612a7083611eab565b516001600160a01b03161480612a96575033612a8b836110ec565b6001600160a01b0316145b612ab25760405162461bcd60e51b8152600401610f8790614078565b80612acf5760405162461bcd60e51b8152600401610f87906145a1565b612ad98185613c23565b93508215612b3357612aea826124d7565b84827ff4c8f45558b285c9b4d64b7e1643043dae934b4cc083c3afcb8d411692d4dd6883604051612b1b919061365e565b60405180910390a36000828152600b60205260408120555b505080612b3f90613bcb565b9050612a1a565b50600c54811115612b695760405162461bcd60e51b8152600401610f87906145da565b6000828152600b602052604090819020805490839055905183907f209ce12c88859afa4298582516e03b1eba9c466c9dff5db16130629f97b5d52c90612bb2908490869061375b565b60405180910390a2505050505050565b8033612bcd82611eab565b516001600160a01b03161480612bf3575033612be8826110ec565b6001600160a01b0316145b612c0f5760405162461bcd60e51b8152600401610f8790613c68565b6000828152601b602052604090205480612cb757601654610100900460ff16612c4a5760405162461bcd60e51b8152600401610f8790614609565b6017546000848152600b60205260409020541015612c7a5760405162461bcd60e51b8152600401610f8790614639565b6000838152601b60205260408082204290555184917f41fa9dacd23836615b00b8de96e10a64a50cd7de16ad167aabf4c023bfacd1da91a2505050565b612cc18142613bb4565b6000848152601c602052604081208054909190612cdf908490613c23565b90915550506000838152601b60205260408082208290555184917f77b32aef15eac84703df273acc09c59be81471f28f8a9eecd503b40cfd7a314091a2505050565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b611040828260405180602001604052806000815250613298565b6000818152601b602052604090205415612dcf576000818152601b60205260408082208290555182917f77b32aef15eac84703df273acc09c59be81471f28f8a9eecd503b40cfd7a314091a25b6000818152601c602052604090205415611e88576000908152601c6020526040812055565b6000612dff83612125565b905080600080612e1d86600090815260066020526040902080549091565b915091508415612e5d57612e32818433611354565b612e5d57612e408333611e08565b612e5d57604051632ce44b5f60e11b815260040160405180910390fd5b612e6b83600088600161218e565b8015612e7657600082555b6001600160a01b038316600081815260056020526040902080546fffffffffffffffffffffffffffffffff0190554260a01b17600360e01b17600087815260046020526040902055600160e11b8416612efd5760018601600081815260046020526040902054612efb576000548114612efb5760008181526004602052604090208590555b505b60405186906000906001600160a01b038616906000805160206149f0833981519152908390a45050600180548101905550505050565b600082612f4085846132fe565b14949350505050565b606081612f6d5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612f975780612f8181613bcb565b9150612f909050600a83613fd4565b9150612f71565b6000816001600160401b03811115612fb157612fb1613957565b6040519080825280601f01601f191660200182016040528015612fdb576020820181803683370190505b5090505b8415611aef57612ff0600183613bb4565b9150612ffd600a86614649565b613008906030613c23565b60f81b81838151811061301d5761301d613b21565b60200101906001600160f81b031916908160001a90535061303f600a86613fd4565b9450612fdf565b6060600061306a6130658560026001613060886005613c23565b61334b565b612f49565b613080613065866003600261306089600a613c23565b61309661306587600460026130608a600a613c23565b6130ac61306588600560026130608b600a613c23565b6130c261306589600660026130608c600a613c23565b6130d86130658a600760026130608d600a613c23565b6130ee6130658b600860026130608e600a613c23565b6131046130658c600960026130608f600a613c23565b60405160200161311b989796959493929190614700565b60408051808303601f19018152919052949350505050565b606081516000141561315357505060408051602081019091526000815290565b60006040518060600160405280604081526020016149b060409139905060006003845160026131829190613c23565b61318c9190613fd4565b613197906004613f9f565b905060006131a6826020613c23565b6001600160401b038111156131bd576131bd613957565b6040519080825280601f01601f1916602001820160405280156131e7576020820181803683370190505b509050818152600183018586518101602084015b81831015613253576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f81168501518253506001016131fb565b60038951066001811461326d576002811461327e5761328a565b613d3d60f01b60011983015261328a565b603d60f81b6000198301525b509398975050505050505050565b6132a28383613375565b6001600160a01b0383163b15611592576000548281035b6132cc60008683806001019450866125b5565b6132e9576040516368d2bf6b60e11b815260040160405180910390fd5b8181106132b9578160005414611b5557600080fd5b600081815b84518110156133435761332f8286838151811061332257613322613b21565b6020026020010151613455565b91508061333b81613bcb565b915050613303565b509392505050565b60006133578383613bb4565b6133618587613fd4565b61336b9190614649565b6120699084613c23565b600054816133965760405163b562e8dd60e01b815260040160405180910390fd5b6133a3600084838561218e565b6001600160a01b03831660008181526005602090815260408083208054680100000000000000018802019055848352600490915281206001851460e11b4260a01b178317905582840190839083906000805160206149f08339815191528180a4600183015b81811461342e57808360006000805160206149f0833981519152600080a4600101613408565b508161344c57604051622e076360e81b815260040160405180910390fd5b60005550505050565b60008183106134715760008281526020849052604090206117ba565b5060009182526020526040902090565b6001600160e01b031981165b8114611e8857600080fd5b8035610eda81613481565b6000602082840312156134b8576134b8600080fd5b6000611aef8484613498565b8015155b82525050565b60208101610eda82846134c4565b60008083601f8401126134f1576134f1600080fd5b5081356001600160401b0381111561350b5761350b600080fd5b60208301915083602082028301111561352657613526600080fd5b9250929050565b6000806020838503121561354357613543600080fd5b82356001600160401b0381111561355c5761355c600080fd5b613568858286016134dc565b92509250509250929050565b60006001600160a01b038216610eda565b61348d81613574565b8035610eda81613585565b8061348d565b8035610eda81613599565b600080604083850312156135c0576135c0600080fd5b60006135cc858561358e565b92505060206135dd8582860161359f565b9150509250929050565b6000806000606084860312156135ff576135ff600080fd5b600061360b868661359f565b935050602061361c8682870161359f565b925050604061362d8682870161359f565b9150509250925092565b60006020828403121561364c5761364c600080fd5b6000611aef848461359f565b806134c8565b60208101610eda8284613658565b60005b8381101561368757818101518382015260200161366f565b838111156110285750506000910152565b60006136a2825190565b8084526020840193506136b981856020860161366c565b601f01601f19169290920192915050565b602080825281016117ba8184613698565b6134c881613574565b60208101610eda82846136db565b80151561348d565b8035610eda816136f2565b60006020828403121561371a5761371a600080fd5b6000611aef84846136fa565b60008060006060848603121561373e5761373e600080fd5b600061374a868661358e565b935050602061361c8682870161358e565b604081016137698285613658565b6117ba6020830184613658565b606081016137848286613658565b6137916020830185613658565b611aef60408301846134c4565b6000602082840312156137b3576137b3600080fd5b6000611aef848461358e565b6000806000604084860312156137d7576137d7600080fd5b83356001600160401b038111156137f0576137f0600080fd5b6137fc868287016134dc565b9350935050602061362d8682870161358e565b600061381b8383613658565b505060200190565b600061382d825190565b80845260209384019383018060005b83811015613861578151613850888261380f565b97506020830192505060010161383c565b509495945050505050565b602080825281016117ba8184613823565b634e487b7160e01b600052602160045260246000fd5b60028110611e8857611e8861387d565b806138ad81613893565b919050565b6000610eda826138a3565b6134c8816138b2565b60208101610eda82846138bd565b600080604083850312156138ea576138ea600080fd5b60006138f6858561358e565b92505060206135dd858286016136fa565b60008060006040848603121561391f5761391f600080fd5b83356001600160401b0381111561393857613938600080fd5b613944868287016134dc565b9350935050602061362d8682870161359f565b634e487b7160e01b600052604160045260246000fd5b601f19601f83011681018181106001600160401b038211171561399257613992613957565b6040525050565b60006139a460405190565b90506138ad828261396d565b60006001600160401b038211156139c9576139c9613957565b601f19601f83011660200192915050565b82818337506000910152565b60006139f96139f4846139b0565b613999565b905082815260208101848484011115613a1457613a14600080fd5b6133438482856139da565b600082601f830112613a3357613a33600080fd5b8135611aef8482602086016139e6565b60008060008060808587031215613a5c57613a5c600080fd5b6000613a68878761358e565b9450506020613a798782880161358e565b9350506040613a8a8782880161359f565b92505060608501356001600160401b03811115613aa957613aa9600080fd5b613ab587828801613a1f565b91505092959194509250565b6000610eda82613574565b6000610eda82613ac1565b6134c881613acc565b60208101610eda8284613ad7565b60008060408385031215613b0457613b04600080fd5b6000613b10858561358e565b92505060206135dd8582860161358e565b634e487b7160e01b600052603260045260246000fd5b600881526000602082016726bab9ba1037bbb760c11b815291505b5060200190565b60208082528101610eda81613b37565b600e81526000602082016d4174206c65617374204c766c203160901b81529150613b52565b60208082528101610eda81613b69565b634e487b7160e01b600052601160045260246000fd5b600082821015613bc657613bc6613b9e565b500390565b6000600019821415613bdf57613bdf613b9e565b5060010190565b634e487b7160e01b600052602260045260246000fd5b600281046001821680613c1057607f821691505b60208210811415611c3457611c34613be6565b60008219821115613c3657613c36613b9e565b500190565b60168152600060208201752737ba1030b8383937bb32b2103737b91037bbb732b960511b81529150613b52565b60208082528101610eda81613c3b565b6000610eda8260601b90565b6000610eda82613c78565b6134c8613c9b82613574565b613c84565b6000613cac8284613c8f565b50601401919050565b600f81526000602082016e4d696e74206174206c65617374203160881b81529150613b52565b60208082528101610eda81613cb5565b6007815260006020820166125b9d985b1a5960ca1b81529150613b52565b60208082528101610eda81613ceb565b6012815260006020820171141d589b1a58c81b5a5b9d0818db1bdcd95960721b81529150613b52565b60208082528101610eda81613d19565b6014815260006020820173125b98dbdc9c9958dd08195d1a195c881cd95b9d60621b81529150613b52565b60208082528101610eda81613d52565b601181526000602082017045786365656473206d6178206d696e747360781b81529150613b52565b60208082528101610eda81613d8d565b601781526000602082017f45786365656473207472616e73616374696f6e206d617800000000000000000081529150613b52565b60208082528101610eda81613dc5565b600d81526000602082016c13595c9adb194818db1bdcd959609a1b81529150613b52565b60208082528101610eda81613e09565b601081526000602082016f43616e20636c61696d206f6e6c79203160801b81529150613b52565b60208082528101610eda81613e3d565b600d81526000602082016c24b73b30b634b210383937b7b360991b81529150613b52565b60208082528101610eda81613e74565b600d81526000602082016c4e6f74206d6572676561626c6560981b81529150613b52565b60208082528101610eda81613ea8565b60208082528101610eda81602681527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160208201526564647265737360d01b604082015260600190565b6000613f328286613658565b602082019150613f428285613658565b602082019150613f528284613c8f565b506014019392505050565b60208082527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657291019081526000613b52565b60208082528101610eda81613f5d565b6000816000190483118215151615613fb957613fb9613b9e565b500290565b634e487b7160e01b600052601260045260246000fd5b600082613fe357613fe3613fbe565b500490565b6016815260006020820175436861726163746572206e6f7420737465616b696e6760501b81529150613b52565b60208082528101610eda81613fe8565b600f81526000602082016e1098589a595cc8191a5cd8589b1959608a1b81529150613b52565b60208082528101610eda81614025565b600681526000602082016511195b9a595960d21b81529150613b52565b60208082528101610eda8161405b565b60098152600060208201684e6f7420726561647960b81b81529150613b52565b60208082528101610eda81614088565b608081016140c682876136db565b6140d360208301866136db565b6140e06040830185613658565b81810360608301526140f28184613698565b9695505050505050565b8051610eda81613481565b60006020828403121561411c5761411c600080fd5b6000611aef84846140fc565b60006141366139f4846139b0565b90508281526020810184848401111561415157614151600080fd5b61334384828561366c565b600082601f83011261417057614170600080fd5b8151611aef848260208601614128565b60006020828403121561419557614195600080fd5b81516001600160401b038111156141ae576141ae600080fd5b611aef8482850161415c565b6803d913730b6b2911d160bd1b815260005b5060090190565b68226574686b756e202360b81b815260006141cc565b60006141f3825190565b61420181856020860161366c565b9290920192915050565b61088b60f21b815260005b5060020190565b7f226465736372697074696f6e223a20226574686b756e20697320616e2031303081527f25206f6e2d636861696e2064796e616d6963204e46542070726f6a656374207760208201527f69746820756e697175652066756e6374696f6e616c69747920616e642066756e60408201527f206d65726765206d656368616e6963732c206d61646520746f2063656c65627260608201527f61746520546865204d65726765212047616d6261747465206574686b756e21226080820152600b60fa1b60a082015260a10190565b611f4b60f21b81526000614216565b7f22696d616765223a2022646174613a696d6167652f7376672b786d6c3b626173815263194d8d0b60e21b602082015260240190565b61227d60f01b81526000614216565b6000614347826141ba565b9150614352826141d3565b915061435e828a6141e9565b91506143698261420b565b91506143748261421d565b6d2261747472696275746573223a5b60901b8152600e01915061439782896141e9565b91506143a382886141e9565b7f7b2274726169745f74797065223a2247656e65736973222c202276616c7565228152601d60f91b602082015260210191506143df82876141e9565b91506143ea826142e8565b7f7b2274726169745f74797065223a22537465616b696e67222c202276616c7565815261111d60f11b6020820152602201915061442782866141e9565b9150614432826142e8565b7f7b2274726169745f74797065223a224c6576656c222c202276616c7565223a008152601f01915061446482856141e9565b621f574b60ea1b8152600301915061447b826142f7565b915061448782846141e9565b91506144928261432d565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152601d0160006117ba82846141e9565b60006144dc826141ba565b91506144e7826141d3565b91506144f382856141e9565b91506144fe8261420b565b91506145098261421d565b7f2261747472696275746573223a5b7b2274726169745f74797065223a2257616981527f74696e6720666f7220546865204d65726765222c202276616c7565223a2254726020820152651d59489f574b60d21b6040820152604601915061456f826142f7565b915061457b82846141e9565b9150611aef8261432d565b60048152600060208201631119585960e21b81529150613b52565b60208082528101610eda81614586565b6012815260006020820171115e18d959591959081b585e081b195d995b60721b81529150613b52565b60208082528101610eda816145b1565b6008815260006020820167111a5cd8589b195960c21b81529150613b52565b60208082528101610eda816145ea565b6009815260006020820168139bdd081b195d995b60ba1b81529150613b52565b60208082528101610eda81614619565b60008261465857614658613fbe565b500690565b7f7b2274726169745f74797065223a2246756e676962696c697479222c2022646981527f73706c61795f74797065223a20226e756d626572222c202276616c7565223a00602082015260005b50603f0190565b7f7b2274726169745f74797065223a224d6f6973747572697a6564222c2022646981527f73706c61795f74797065223a20226e756d626572222c202276616c7565223a00602082015260006146a9565b7f7b2274726169745f74797065223a224b696d6f63686969222c2022646973706c81527f61795f74797065223a20226e756d626572222c202276616c7565223a000000006020820152603c016000614758828b6141e9565b9150614763826142e8565b7f7b2274726169745f74797065223a22555755222c2022646973706c61795f747981527f7065223a20226e756d626572222c202276616c7565223a000000000000000000602082015260370191506147bb828a6141e9565b91506147c6826142e8565b7f7b2274726169745f74797065223a22556c747261736f756e646e657373222c2081527f22646973706c61795f74797065223a20226e756d626572222c202276616c7565602082015261111d60f11b6040820152604201915061482982896141e9565b9150614834826142e8565b915061483f8261465d565b915061484b82886141e9565b9150614856826142e8565b7f7b2274726169745f74797065223a225375676f696e657373222c20226469737081527f6c61795f74797065223a20226e756d626572222c202276616c7565223a0000006020820152603d0191506148ae82876141e9565b91506148b9826142e8565b7f7b2274726169745f74797065223a224b616b6b6f6969222c2022646973706c6181527f795f74797065223a20226e756d626572222c202276616c7565223a00000000006020820152603b01915061491182866141e9565b915061491c826142e8565b7f7b2274726169745f74797065223a224b6177616969222c2022646973706c617981527f5f74797065223a20226e756d626572222c202276616c7565223a0000000000006020820152603a01915061497482856141e9565b915061497f826142e8565b915061498a826146b0565b915061499682846141e9565b91506149a1826142e8565b9a995050505050505050505056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212201c12125d563d904029dce39420fe4b5fb3eb1bbf6f20ae2110eff2025b8925d364736f6c63430008090033

Deployed Bytecode

0x6080604052600436106104945760003560e01c80637e980e0011610260578063cb9d5b9e11610144578063e7b5ec0f116100c1578063f0503e8011610085578063f0503e8014610dd1578063f1e25ea814610dfe578063f2fde38b14610e21578063f5cbd52b14610e41578063f7da7b3b14610e57578063ffd3332e14610e6d57600080fd5b8063e7b5ec0f14610d23578063e8ff352514610d50578063e934028914610d70578063e985e9c514610d91578063efdb28db14610db157600080fd5b8063de62d84211610108578063de62d84214610c8c578063e035740314610cac578063e0a8085314610cc2578063e33e4b4914610ce2578063e757223014610d0357600080fd5b8063cb9d5b9e14610c05578063cc06c35914610c1c578063da97398e14610c32578063daeaeb0314610c4c578063dc33e68114610c6c57600080fd5b8063a22cb465116101dd578063afdb45a8116101a1578063afdb45a814610b45578063b88d4fde14610b65578063bc640bd014610b85578063bfa584d214610ba5578063c5c5c71c14610bc5578063c87b56dd14610be557600080fd5b8063a22cb46514610aba578063a3bcb09a14610ada578063acec8a5f14610afa578063ad031fb014610b19578063ad99cc8a14610b2f57600080fd5b80638da5cb5b116102245780638da5cb5b14610a2557806395d89b4114610a435780639ad7a0f614610a585780639aedee3a14610a795780639da3f8fd14610a8c57600080fd5b80637e980e001461098257806381bbc8ef146109a25780638462151c146109c2578063887fee31146109ef5780638cf4f3a514610a0f57600080fd5b8063344f1ba5116103875780636352211e1161030457806370a08231116102c857806370a08231146108d757806370f34a87146108f75780637149b6d314610917578063715018a614610937578063786d5b471461094c5780637cb647591461096257600080fd5b80636352211e1461084b578063668b63c41461086b578063697e2224146108815780636ca76d1f146108975780636d49cdfa146108b757600080fd5b80634a89c50b1161034b5780634a89c50b146107ca5780634bc9f48a146107e05780634d99d976146108005780635030c70714610815578063540da96c1461083557600080fd5b8063344f1ba51461074b5780633726230a1461076b57806337e348df146107805780633ccfd60b1461079557806342842e0e146107aa57600080fd5b806317cbab92116104155780632ddfd5ba116103d95780632ddfd5ba146106ad5780632eb4a7ab146106cd5780632f5b1cea146106e3578063324d34bc1461070657806332a125b31461073557600080fd5b806317cbab921461061a57806318160ddd1461063a5780631f8fe21a1461065757806323b872dd14610677578063295020be1461069757600080fd5b806306fdde031161045c57806306fdde031461056b578063081812fc1461058d57806308683e71146105ba578063095ea7b3146105da5780630b269898146105fa57600080fd5b806301ffc9a7146104995780630270a072146104cf578063034e39ee146104f157806304acc3771461051157806305c58df214610531575b600080fd5b3480156104a557600080fd5b506104b96104b43660046134a3565b610e8e565b6040516104c691906134ce565b60405180910390f35b3480156104db57600080fd5b506104ef6104ea36600461352d565b610ee0565b005b3480156104fd57600080fd5b506104ef61050c3660046135aa565b61102e565b34801561051d57600080fd5b506104ef61052c3660046135e7565b611044565b34801561053d57600080fd5b5061055e61054c366004613637565b600b6020526000908152604090205481565b6040516104c6919061365e565b34801561057757600080fd5b5061058061105a565b6040516104c691906136ca565b34801561059957600080fd5b506105ad6105a8366004613637565b6110ec565b6040516104c691906136e4565b3480156105c657600080fd5b506104ef6105d5366004613705565b611130565b3480156105e657600080fd5b506104ef6105f53660046135aa565b611156565b34801561060657600080fd5b506104ef61061536600461352d565b6111f6565b34801561062657600080fd5b506104b9610635366004613637565b6112e9565b34801561064657600080fd5b50600154600054036000190161055e565b34801561066357600080fd5b5061055e610672366004613637565b6112f4565b34801561068357600080fd5b506104ef610692366004613726565b6112ff565b3480156106a357600080fd5b5061055e60185481565b3480156106b957600080fd5b506104ef6106c8366004613705565b611495565b3480156106d957600080fd5b5061055e60155481565b3480156106ef57600080fd5b506106f86114bb565b6040516104c692919061375b565b34801561071257600080fd5b50610726610721366004613637565b6114ce565b6040516104c693929190613776565b34801561074157600080fd5b5061055e60115481565b34801561075757600080fd5b506104ef610766366004613637565b61151a565b34801561077757600080fd5b5061055e611527565b34801561078c57600080fd5b5061055e611536565b3480156107a157600080fd5b506104ef611540565b3480156107b657600080fd5b506104ef6107c5366004613726565b611577565b3480156107d657600080fd5b5061055e600d5481565b3480156107ec57600080fd5b506104ef6107fb366004613637565b611597565b34801561080c57600080fd5b5061055e600181565b34801561082157600080fd5b506104ef610830366004613705565b6115a4565b34801561084157600080fd5b5061055e60195481565b34801561085757600080fd5b506105ad610866366004613637565b6115c8565b34801561087757600080fd5b5061055e60105481565b34801561088d57600080fd5b5061055e600f5481565b3480156108a357600080fd5b506104ef6108b236600461352d565b6115d3565b3480156108c357600080fd5b506104ef6108d236600461352d565b61161e565b3480156108e357600080fd5b5061055e6108f236600461379e565b611628565b34801561090357600080fd5b506104ef610912366004613705565b611676565b34801561092357600080fd5b506104ef610932366004613705565b61169c565b34801561094357600080fd5b506104ef6116be565b34801561095857600080fd5b5061055e6116f381565b34801561096e57600080fd5b506104ef61097d366004613637565b6116d2565b34801561098e57600080fd5b506104ef61099d366004613637565b6116df565b3480156109ae57600080fd5b506104b96109bd3660046137bf565b61177f565b3480156109ce57600080fd5b506109e26109dd36600461379e565b6117c1565b6040516104c6919061386c565b3480156109fb57600080fd5b506104ef610a0a366004613637565b6118d0565b348015610a1b57600080fd5b5061055e60135481565b348015610a3157600080fd5b506008546001600160a01b03166105ad565b348015610a4f57600080fd5b50610580611914565b348015610a6457600080fd5b506009546104b990600160a81b900460ff1681565b6104ef610a87366004613637565b611923565b348015610a9857600080fd5b50600954610aad90600160a01b900460ff1681565b6040516104c691906138c6565b348015610ac657600080fd5b506104ef610ad53660046138d4565b611a49565b348015610ae657600080fd5b506104b9610af5366004613907565b611ae2565b348015610b0657600080fd5b506016546104b990610100900460ff1681565b348015610b2557600080fd5b5061055e601a5481565b348015610b3b57600080fd5b5061055e60125481565b348015610b5157600080fd5b506104ef610b60366004613907565b611af7565b348015610b7157600080fd5b506104ef610b80366004613a43565b611b5c565b348015610b9157600080fd5b506104ef610ba0366004613637565b611ba0565b348015610bb157600080fd5b506104ef610bc036600461379e565b611bad565b348015610bd157600080fd5b506016546104b99062010000900460ff1681565b348015610bf157600080fd5b50610580610c00366004613637565b611bd7565b348015610c1157600080fd5b5061055e6201518081565b348015610c2857600080fd5b5061055e600c5481565b348015610c3e57600080fd5b506016546104b99060ff1681565b348015610c5857600080fd5b506104ef610c67366004613907565b611c3a565b348015610c7857600080fd5b5061055e610c8736600461379e565b611d46565b348015610c9857600080fd5b506104ef610ca736600461352d565b611d51565b348015610cb857600080fd5b5061055e600e5481565b348015610cce57600080fd5b506104ef610cdd366004613705565b611d94565b348015610cee57600080fd5b506009546104b990600160b01b900460ff1681565b348015610d0f57600080fd5b5061055e610d1e366004613637565b611dba565b348015610d2f57600080fd5b50600954610d43906001600160a01b031681565b6040516104c69190613ae0565b348015610d5c57600080fd5b506104ef610d6b36600461352d565b611dc5565b348015610d7c57600080fd5b506009546104b990600160b81b900460ff1681565b348015610d9d57600080fd5b506104b9610dac366004613aee565b611e08565b348015610dbd57600080fd5b506104ef610dcc366004613705565b611e36565b348015610ddd57600080fd5b5061055e610dec366004613637565b600a6020526000908152604090205481565b348015610e0a57600080fd5b506104b9610e19366004613637565b6116f3101590565b348015610e2d57600080fd5b506104ef610e3c36600461379e565b611e51565b348015610e4d57600080fd5b5061055e60145481565b348015610e6357600080fd5b5061055e60175481565b348015610e7957600080fd5b506009546104b990600160c01b900460ff1681565b60006301ffc9a760e01b6001600160e01b031983161480610ebf57506380ac58cd60e01b6001600160e01b03198316145b80610eda5750635b5e139f60e01b6001600160e01b03198316145b92915050565b610ee8611e8b565b8015610efd5750600954600160b81b900460ff165b610f0657600080fd5b8060005b81811015611028576000848483818110610f2657610f26613b21565b9050602002013590506000600b6000838152602001908152602001600020549050610f4e3390565b6001600160a01b0316610f6083611eab565b516001600160a01b031614610f905760405162461bcd60e51b8152600401610f8790613b59565b60405180910390fd5b60018111610fb05760405162461bcd60e51b8152600401610f8790613b8e565b610fb982611ee0565b6000610fc6600183613bb4565b6000848152600b6020526040908190208290555190915083907fc6ca1ad742bbff176a4773a093de94df27d5d29669f999560882d57503dfaaed9061100c90849061365e565b60405180910390a25050508061102190613bcb565b9050610f0a565b50505050565b611036611f28565b6110408282611f52565b5050565b61104c611f28565b601892909255601955601a55565b60606002805461106990613bfc565b80601f016020809104026020016040519081016040528092919081815260200182805461109590613bfc565b80156110e25780601f106110b7576101008083540402835291602001916110e2565b820191906000526020600020905b8154815290600101906020018083116110c557829003601f168201915b5050505050905090565b60006110f782611fb4565b611114576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b611138611f28565b60098054911515600160c01b0260ff60c01b19909216919091179055565b6000611161826115c8565b9050336001600160a01b0382161461119a5761117d8133611e08565b61119a576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6111fe611f28565b8181600081811061121157611211613b21565b6020029190910135600e55508181600181811061123057611230613b21565b6020029190910135600f55508181600281811061124f5761124f613b21565b6020029190910135601055508181600381811061126e5761126e613b21565b6020029190910135601155508181600481811061128d5761128d613b21565b602002919091013560125550818160058181106112ac576112ac613b21565b602002919091013560135550818160068181106112cb576112cb613b21565b905060200201356014819055506116f3600e54111561104057600080fd5b6000610eda82611fe9565b6000610eda82612072565b600061130a82612125565b9050836001600160a01b0316816001600160a01b03161461133d5760405162a1148160e81b815260040160405180910390fd5b600082815260066020526040902080546113698187335b6001600160a01b039081169116811491141790565b611394576113778633611e08565b61139457604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166113bb57604051633a954ecd60e21b815260040160405180910390fd5b6113c8868686600161218e565b80156113d357600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260046020526040902055600160e11b831661145e576001840160008181526004602052604090205461145c57600054811461145c5760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b03166000805160206149f083398151915260405160405180910390a4505050505050565b61149d611f28565b60098054911515600160b81b0260ff60b81b19909216919091179055565b6000806114c66121f0565b915091509091565b6000818152601b60205260408120548190819080156114f4576114f18142613bb4565b93505b6000858152601c602052604090205461150d9085613c23565b9395939450151592915050565b611522611f28565b600c55565b6000611531612223565b905090565b600061153161222d565b611548611f28565b6040514790339082156108fc029083906000818181858888f19350505050158015611040573d6000803e3d6000fd5b61159283838360405180602001604052806000815250611b5c565b505050565b61159f611f28565b600d55565b6115ac611f28565b60168054911515620100000262ff000019909216919091179055565b6000610eda82612125565b6115db611f28565b8060005b818110156110285760008484838181106115fb576115fb613b21565b90506020020135905061160d8161225d565b5061161781613bcb565b90506115df565b6110408282612332565b60006001600160a01b038216611651576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b61167e611f28565b60098054911515600160b01b0260ff60b01b19909216919091179055565b6116a4611f28565b601680549115156101000261ff0019909216919091179055565b6116c6611f28565b6116d06000612485565b565b6116da611f28565b601555565b80336116ea82611eab565b516001600160a01b03161480611710575033611705826110ec565b6001600160a01b0316145b61172c5760405162461bcd60e51b8152600401610f8790613c68565b600954600160c01b900460ff16151560011461174757600080fd5b611750826124d7565b60405182907f0f1711c7762713c236f84b2fa04e1ef0923424ade89cb73e02eafab2ed4af22a90600090a25050565b600080826040516020016117939190613ca0565b6040516020818303038152906040528051906020012090506117b68585836124e2565b9150505b9392505050565b606060008060006117d185611628565b90506000816001600160401b038111156117ed576117ed613957565b604051908082528060200260200182016040528015611816578160200160208202803683370190505b50905061184360408051608081018252600080825260208201819052918101829052606081019190915290565b60015b8386146118c45761185681612525565b9150816040015115611867576118bc565b81516001600160a01b03161561187c57815194505b876001600160a01b0316856001600160a01b031614156118bc57808387806001019850815181106118af576118af613b21565b6020026020010181815250505b600101611846565b50909695505050505050565b6118d8611f28565b8060018111156118ea576118ea61387d565b6009805460ff60a01b1916600160a01b83600181111561190c5761190c61387d565b021790555050565b60606003805461106990613bfc565b80600081116119445760405162461bcd60e51b8152600401610f8790613cdb565b6116f381611950612223565b61195a9190613c23565b11156119785760405162461bcd60e51b8152600401610f8790613d09565b6001600954600160a01b900460ff1660018111156119985761199861387d565b146119b55760405162461bcd60e51b8152600401610f8790613d42565b6119be82612561565b3410156119dd5760405162461bcd60e51b8152600401610f8790613d7d565b6000806119e86121f0565b9150915081846119f73361258d565b611a019190613c23565b1115611a1f5760405162461bcd60e51b8152600401610f8790613db5565b80841115611a3f5760405162461bcd60e51b8152600401610f8790613df9565b6110283385611f52565b6001600160a01b038216331415611a735760405163b06307db60e01b815260040160405180910390fd5b3360008181526007602090815260408083206001600160a01b038716808552925291829020805460ff191685151517905590519091907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190611ad69085906134ce565b60405180910390a35050565b6000611aef8484846124e2565b949350505050565b611aff611f28565b8180611b0a57600080fd5b60005b81811015611b5557611b45858583818110611b2a57611b2a613b21565b9050602002016020810190611b3f919061379e565b84611f52565b611b4e81613bcb565b9050611b0d565b5050505050565b611b678484846112ff565b6001600160a01b0383163b1561102857611b83848484846125b5565b611028576040516368d2bf6b60e11b815260040160405180910390fd5b611ba8611f28565b601755565b611bb5611f28565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b60608160018110158015611bf25750611bee612223565b8111155b611c0e5760405162461bcd60e51b8152600401610f8790613d09565b611c16611e8b565b15611c2b57611c24836126ac565b9150611c34565b611c2483612901565b50919050565b8060008111611c5b5760405162461bcd60e51b8152600401610f8790613cdb565b6116f381611c67612223565b611c719190613c23565b1115611c8f5760405162461bcd60e51b8152600401610f8790613d09565b60165460ff161515600114611cb65760405162461bcd60e51b8152600401610f8790613e2d565b600182611cc23361258d565b611ccc9190613c23565b1115611cea5760405162461bcd60e51b8152600401610f8790613e64565b600033604051602001611cfd9190613ca0565b604051602081830303815290604052805190602001209050611d208585836124e2565b611d3c5760405162461bcd60e51b8152600401610f8790613e98565b611b553384611f52565b6000610eda8261258d565b611d59611e8b565b8015611d6e5750600954600160b01b900460ff165b611d8a5760405162461bcd60e51b8152600401610f8790613ecc565b61104082826129ed565b611d9c611f28565b60098054911515600160a81b0260ff60a81b19909216919091179055565b6000610eda82612561565b8060005b81811015611028576000848483818110611de557611de5613b21565b905060200201359050611df781612bc2565b50611e0181613bcb565b9050611dc9565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b611e3e611f28565b6016805460ff1916911515919091179055565b611e59611f28565b6001600160a01b038116611e7f5760405162461bcd60e51b8152600401610f8790613edc565b611e8881612485565b50565b600954600090600160a81b900460ff168015611531575050600d54431190565b604080516080810182526000808252602082018190529181018290526060810191909152610eda611edb83612125565b612d21565b611eeb600143613bb4565b408133604051602001611f0093929190613f26565b60408051601f1981840301815291815281516020928301206000938452600a90925290912055565b6008546001600160a01b031633146116d05760405162461bcd60e51b8152600401610f8790613f8f565b6000611f5c612223565b611f67906001613c23565b9050805b611f758383613c23565b811015611fa957611f8581611ee0565b6000818152600b602052604090206001905580611fa181613bcb565b915050611f6b565b506115928383612d68565b600081600111158015611fc8575060005482105b8015610eda575050600090815260046020526040902054600160e01b161590565b6000818152601b60205260408120548190801561200d5761200a8142613bb4565b91505b6000848152601c60205260408120546120269084613c23565b905061203185612072565b811015801561205057506017546000868152600b602052604090205410155b801561206957506000858152601b602052604090205415155b95945050505050565b60008061207d61222d565b9050600060195482620151806120939190613f9f565b61209d9190613fd4565b6000858152600b602052604081205460175492935090918111156120e557601a546017546120cb9083613bb4565b6120d89062015180613f9f565b6120e29190613fd4565b91505b828211156120f1578291505b60008284620151806018546121069190613f9f565b6121109190613c23565b61211a9190613bb4565b979650505050505050565b600081806001116121755760005481101561217557600081815260046020526040902054600160e01b8116612173575b806117ba575060001901600081815260046020526040902054612155565b505b604051636f96cda160e11b815260040160405180910390fd5b6001600160a01b03841615806121ab57506001600160a01b038316155b156121b557611028565b6001600160a01b0384161561102857815b6121d08284613c23565b811015611b55576121e081612d82565b6121e981613bcb565b90506121c6565b60008060006121fd612223565b9050600e5481106122135760135460145461221a565b6010546011545b92509250509091565b6000546000190190565b600080612238612223565b90506116f3811161224b57600091505090565b6122576116f382613bb4565b91505090565b6000818152601b60205260409020546122885760405162461bcd60e51b8152600401610f8790614015565b6000818152601b60205260408120546122a19042613bb4565b905080601c600084815260200190815260200160002060008282546122c69190613c23565b90915550506000828152601b60205260408082208290555183917f77b32aef15eac84703df273acc09c59be81471f28f8a9eecd503b40cfd7a314091a260405182907f9b890154087c644ebc131cc896b4fc9af428461c07cc581063101c8306adaf1d90600090a25050565b60165462010000900460ff16151560011461235f5760405162461bcd60e51b8152600401610f879061404b565b8060005b8181101561102857600084848381811061237f5761237f613b21565b90506020020135905061238f3390565b6001600160a01b03166123a182611eab565b516001600160a01b031614806123c75750336123bc826110ec565b6001600160a01b0316145b6123e35760405162461bcd60e51b8152600401610f8790614078565b6123ec81611fe9565b6124085760405162461bcd60e51b8152600401610f87906140a8565b61241c61241482611eab565b516001611f52565b6000818152601c60209081526040808320839055601b9091528120429055612442612223565b905080827fb631eca81f936326925370c4b06accb33f19ecea754a9f20fbe4f5edd93d230760405160405180910390a350508061247e90613bcb565b9050612363565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b611e88816000612df4565b6000611aef848480806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250506015549150859050612f33565b604080516080810182526000808252602082018190529181018290526060810191909152600082815260046020526040902054610eda90612d21565b60008061256c612223565b9050600e54811061257f57601254612583565b600f545b6117ba9084613f9f565b6001600160a01b03166000908152600560205260409081902054901c6001600160401b031690565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a02906125ea9033908990889088906004016140b8565b602060405180830381600087803b15801561260457600080fd5b505af1925050508015612634575060408051601f3d908101601f1916820190925261263191810190614107565b60015b61268f573d808015612662576040519150601f19603f3d011682016040523d82523d6000602084013e612667565b606091505b508051612687576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b6000818152600a6020908152604080832054600d54600b90935281842054600954925163176f05ed60e11b81526060959490920193909290916001600160a01b0390911690632ede0bda90612707908690869060040161375b565b60006040518083038186803b15801561271f57600080fd5b505afa158015612733573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261275b9190810190614180565b905060006128d461276b87612f49565b600954604051636404fcd160e01b81526001600160a01b0390911690636404fcd19061279b90899060040161365e565b60006040518083038186803b1580156127b357600080fd5b505afa1580156127c7573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526127ef9190810190614180565b6127f98787613046565b6116f38a111561282557604051806040016040528060048152602001631127379160e11b815250612844565b60405180604001604052806005815260200164112cb2b99160d91b8152505b60008b8152601b602052604090205461287957604051806040016040528060048152602001631127379160e11b815250612898565b60405180604001604052806005815260200164112cb2b99160d91b8152505b6128a189612f49565b6128aa89613133565b6040516020016128c0979695949392919061433c565b604051602081830303815290604052613133565b9050806040516020016128e7919061449f565b604051602081830303815290604052945050505050919050565b6000818152600a6020526040808220546009549151633521481160e21b815260609391926001600160a01b03169063d48520449061294390859060040161365e565b60006040518083038186803b15801561295b57600080fd5b505afa15801561296f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526129979190810190614180565b905060006129c16129a786612f49565b6129b084613133565b6040516020016128c09291906144d1565b9050806040516020016129d4919061449f565b6040516020818303038152906040529350505050919050565b80806129f857600080fd5b600083836000818110612a0d57612a0d613b21565b9050602002013590506000805b83811015612b46576000868683818110612a3657612a36613b21565b9050602002013590506000600b6000838152602001908152602001600020549050612a5e3390565b6001600160a01b0316612a7083611eab565b516001600160a01b03161480612a96575033612a8b836110ec565b6001600160a01b0316145b612ab25760405162461bcd60e51b8152600401610f8790614078565b80612acf5760405162461bcd60e51b8152600401610f87906145a1565b612ad98185613c23565b93508215612b3357612aea826124d7565b84827ff4c8f45558b285c9b4d64b7e1643043dae934b4cc083c3afcb8d411692d4dd6883604051612b1b919061365e565b60405180910390a36000828152600b60205260408120555b505080612b3f90613bcb565b9050612a1a565b50600c54811115612b695760405162461bcd60e51b8152600401610f87906145da565b6000828152600b602052604090819020805490839055905183907f209ce12c88859afa4298582516e03b1eba9c466c9dff5db16130629f97b5d52c90612bb2908490869061375b565b60405180910390a2505050505050565b8033612bcd82611eab565b516001600160a01b03161480612bf3575033612be8826110ec565b6001600160a01b0316145b612c0f5760405162461bcd60e51b8152600401610f8790613c68565b6000828152601b602052604090205480612cb757601654610100900460ff16612c4a5760405162461bcd60e51b8152600401610f8790614609565b6017546000848152600b60205260409020541015612c7a5760405162461bcd60e51b8152600401610f8790614639565b6000838152601b60205260408082204290555184917f41fa9dacd23836615b00b8de96e10a64a50cd7de16ad167aabf4c023bfacd1da91a2505050565b612cc18142613bb4565b6000848152601c602052604081208054909190612cdf908490613c23565b90915550506000838152601b60205260408082208290555184917f77b32aef15eac84703df273acc09c59be81471f28f8a9eecd503b40cfd7a314091a2505050565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b611040828260405180602001604052806000815250613298565b6000818152601b602052604090205415612dcf576000818152601b60205260408082208290555182917f77b32aef15eac84703df273acc09c59be81471f28f8a9eecd503b40cfd7a314091a25b6000818152601c602052604090205415611e88576000908152601c6020526040812055565b6000612dff83612125565b905080600080612e1d86600090815260066020526040902080549091565b915091508415612e5d57612e32818433611354565b612e5d57612e408333611e08565b612e5d57604051632ce44b5f60e11b815260040160405180910390fd5b612e6b83600088600161218e565b8015612e7657600082555b6001600160a01b038316600081815260056020526040902080546fffffffffffffffffffffffffffffffff0190554260a01b17600360e01b17600087815260046020526040902055600160e11b8416612efd5760018601600081815260046020526040902054612efb576000548114612efb5760008181526004602052604090208590555b505b60405186906000906001600160a01b038616906000805160206149f0833981519152908390a45050600180548101905550505050565b600082612f4085846132fe565b14949350505050565b606081612f6d5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612f975780612f8181613bcb565b9150612f909050600a83613fd4565b9150612f71565b6000816001600160401b03811115612fb157612fb1613957565b6040519080825280601f01601f191660200182016040528015612fdb576020820181803683370190505b5090505b8415611aef57612ff0600183613bb4565b9150612ffd600a86614649565b613008906030613c23565b60f81b81838151811061301d5761301d613b21565b60200101906001600160f81b031916908160001a90535061303f600a86613fd4565b9450612fdf565b6060600061306a6130658560026001613060886005613c23565b61334b565b612f49565b613080613065866003600261306089600a613c23565b61309661306587600460026130608a600a613c23565b6130ac61306588600560026130608b600a613c23565b6130c261306589600660026130608c600a613c23565b6130d86130658a600760026130608d600a613c23565b6130ee6130658b600860026130608e600a613c23565b6131046130658c600960026130608f600a613c23565b60405160200161311b989796959493929190614700565b60408051808303601f19018152919052949350505050565b606081516000141561315357505060408051602081019091526000815290565b60006040518060600160405280604081526020016149b060409139905060006003845160026131829190613c23565b61318c9190613fd4565b613197906004613f9f565b905060006131a6826020613c23565b6001600160401b038111156131bd576131bd613957565b6040519080825280601f01601f1916602001820160405280156131e7576020820181803683370190505b509050818152600183018586518101602084015b81831015613253576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f81168501518253506001016131fb565b60038951066001811461326d576002811461327e5761328a565b613d3d60f01b60011983015261328a565b603d60f81b6000198301525b509398975050505050505050565b6132a28383613375565b6001600160a01b0383163b15611592576000548281035b6132cc60008683806001019450866125b5565b6132e9576040516368d2bf6b60e11b815260040160405180910390fd5b8181106132b9578160005414611b5557600080fd5b600081815b84518110156133435761332f8286838151811061332257613322613b21565b6020026020010151613455565b91508061333b81613bcb565b915050613303565b509392505050565b60006133578383613bb4565b6133618587613fd4565b61336b9190614649565b6120699084613c23565b600054816133965760405163b562e8dd60e01b815260040160405180910390fd5b6133a3600084838561218e565b6001600160a01b03831660008181526005602090815260408083208054680100000000000000018802019055848352600490915281206001851460e11b4260a01b178317905582840190839083906000805160206149f08339815191528180a4600183015b81811461342e57808360006000805160206149f0833981519152600080a4600101613408565b508161344c57604051622e076360e81b815260040160405180910390fd5b60005550505050565b60008183106134715760008281526020849052604090206117ba565b5060009182526020526040902090565b6001600160e01b031981165b8114611e8857600080fd5b8035610eda81613481565b6000602082840312156134b8576134b8600080fd5b6000611aef8484613498565b8015155b82525050565b60208101610eda82846134c4565b60008083601f8401126134f1576134f1600080fd5b5081356001600160401b0381111561350b5761350b600080fd5b60208301915083602082028301111561352657613526600080fd5b9250929050565b6000806020838503121561354357613543600080fd5b82356001600160401b0381111561355c5761355c600080fd5b613568858286016134dc565b92509250509250929050565b60006001600160a01b038216610eda565b61348d81613574565b8035610eda81613585565b8061348d565b8035610eda81613599565b600080604083850312156135c0576135c0600080fd5b60006135cc858561358e565b92505060206135dd8582860161359f565b9150509250929050565b6000806000606084860312156135ff576135ff600080fd5b600061360b868661359f565b935050602061361c8682870161359f565b925050604061362d8682870161359f565b9150509250925092565b60006020828403121561364c5761364c600080fd5b6000611aef848461359f565b806134c8565b60208101610eda8284613658565b60005b8381101561368757818101518382015260200161366f565b838111156110285750506000910152565b60006136a2825190565b8084526020840193506136b981856020860161366c565b601f01601f19169290920192915050565b602080825281016117ba8184613698565b6134c881613574565b60208101610eda82846136db565b80151561348d565b8035610eda816136f2565b60006020828403121561371a5761371a600080fd5b6000611aef84846136fa565b60008060006060848603121561373e5761373e600080fd5b600061374a868661358e565b935050602061361c8682870161358e565b604081016137698285613658565b6117ba6020830184613658565b606081016137848286613658565b6137916020830185613658565b611aef60408301846134c4565b6000602082840312156137b3576137b3600080fd5b6000611aef848461358e565b6000806000604084860312156137d7576137d7600080fd5b83356001600160401b038111156137f0576137f0600080fd5b6137fc868287016134dc565b9350935050602061362d8682870161358e565b600061381b8383613658565b505060200190565b600061382d825190565b80845260209384019383018060005b83811015613861578151613850888261380f565b97506020830192505060010161383c565b509495945050505050565b602080825281016117ba8184613823565b634e487b7160e01b600052602160045260246000fd5b60028110611e8857611e8861387d565b806138ad81613893565b919050565b6000610eda826138a3565b6134c8816138b2565b60208101610eda82846138bd565b600080604083850312156138ea576138ea600080fd5b60006138f6858561358e565b92505060206135dd858286016136fa565b60008060006040848603121561391f5761391f600080fd5b83356001600160401b0381111561393857613938600080fd5b613944868287016134dc565b9350935050602061362d8682870161359f565b634e487b7160e01b600052604160045260246000fd5b601f19601f83011681018181106001600160401b038211171561399257613992613957565b6040525050565b60006139a460405190565b90506138ad828261396d565b60006001600160401b038211156139c9576139c9613957565b601f19601f83011660200192915050565b82818337506000910152565b60006139f96139f4846139b0565b613999565b905082815260208101848484011115613a1457613a14600080fd5b6133438482856139da565b600082601f830112613a3357613a33600080fd5b8135611aef8482602086016139e6565b60008060008060808587031215613a5c57613a5c600080fd5b6000613a68878761358e565b9450506020613a798782880161358e565b9350506040613a8a8782880161359f565b92505060608501356001600160401b03811115613aa957613aa9600080fd5b613ab587828801613a1f565b91505092959194509250565b6000610eda82613574565b6000610eda82613ac1565b6134c881613acc565b60208101610eda8284613ad7565b60008060408385031215613b0457613b04600080fd5b6000613b10858561358e565b92505060206135dd8582860161358e565b634e487b7160e01b600052603260045260246000fd5b600881526000602082016726bab9ba1037bbb760c11b815291505b5060200190565b60208082528101610eda81613b37565b600e81526000602082016d4174206c65617374204c766c203160901b81529150613b52565b60208082528101610eda81613b69565b634e487b7160e01b600052601160045260246000fd5b600082821015613bc657613bc6613b9e565b500390565b6000600019821415613bdf57613bdf613b9e565b5060010190565b634e487b7160e01b600052602260045260246000fd5b600281046001821680613c1057607f821691505b60208210811415611c3457611c34613be6565b60008219821115613c3657613c36613b9e565b500190565b60168152600060208201752737ba1030b8383937bb32b2103737b91037bbb732b960511b81529150613b52565b60208082528101610eda81613c3b565b6000610eda8260601b90565b6000610eda82613c78565b6134c8613c9b82613574565b613c84565b6000613cac8284613c8f565b50601401919050565b600f81526000602082016e4d696e74206174206c65617374203160881b81529150613b52565b60208082528101610eda81613cb5565b6007815260006020820166125b9d985b1a5960ca1b81529150613b52565b60208082528101610eda81613ceb565b6012815260006020820171141d589b1a58c81b5a5b9d0818db1bdcd95960721b81529150613b52565b60208082528101610eda81613d19565b6014815260006020820173125b98dbdc9c9958dd08195d1a195c881cd95b9d60621b81529150613b52565b60208082528101610eda81613d52565b601181526000602082017045786365656473206d6178206d696e747360781b81529150613b52565b60208082528101610eda81613d8d565b601781526000602082017f45786365656473207472616e73616374696f6e206d617800000000000000000081529150613b52565b60208082528101610eda81613dc5565b600d81526000602082016c13595c9adb194818db1bdcd959609a1b81529150613b52565b60208082528101610eda81613e09565b601081526000602082016f43616e20636c61696d206f6e6c79203160801b81529150613b52565b60208082528101610eda81613e3d565b600d81526000602082016c24b73b30b634b210383937b7b360991b81529150613b52565b60208082528101610eda81613e74565b600d81526000602082016c4e6f74206d6572676561626c6560981b81529150613b52565b60208082528101610eda81613ea8565b60208082528101610eda81602681527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160208201526564647265737360d01b604082015260600190565b6000613f328286613658565b602082019150613f428285613658565b602082019150613f528284613c8f565b506014019392505050565b60208082527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657291019081526000613b52565b60208082528101610eda81613f5d565b6000816000190483118215151615613fb957613fb9613b9e565b500290565b634e487b7160e01b600052601260045260246000fd5b600082613fe357613fe3613fbe565b500490565b6016815260006020820175436861726163746572206e6f7420737465616b696e6760501b81529150613b52565b60208082528101610eda81613fe8565b600f81526000602082016e1098589a595cc8191a5cd8589b1959608a1b81529150613b52565b60208082528101610eda81614025565b600681526000602082016511195b9a595960d21b81529150613b52565b60208082528101610eda8161405b565b60098152600060208201684e6f7420726561647960b81b81529150613b52565b60208082528101610eda81614088565b608081016140c682876136db565b6140d360208301866136db565b6140e06040830185613658565b81810360608301526140f28184613698565b9695505050505050565b8051610eda81613481565b60006020828403121561411c5761411c600080fd5b6000611aef84846140fc565b60006141366139f4846139b0565b90508281526020810184848401111561415157614151600080fd5b61334384828561366c565b600082601f83011261417057614170600080fd5b8151611aef848260208601614128565b60006020828403121561419557614195600080fd5b81516001600160401b038111156141ae576141ae600080fd5b611aef8482850161415c565b6803d913730b6b2911d160bd1b815260005b5060090190565b68226574686b756e202360b81b815260006141cc565b60006141f3825190565b61420181856020860161366c565b9290920192915050565b61088b60f21b815260005b5060020190565b7f226465736372697074696f6e223a20226574686b756e20697320616e2031303081527f25206f6e2d636861696e2064796e616d6963204e46542070726f6a656374207760208201527f69746820756e697175652066756e6374696f6e616c69747920616e642066756e60408201527f206d65726765206d656368616e6963732c206d61646520746f2063656c65627260608201527f61746520546865204d65726765212047616d6261747465206574686b756e21226080820152600b60fa1b60a082015260a10190565b611f4b60f21b81526000614216565b7f22696d616765223a2022646174613a696d6167652f7376672b786d6c3b626173815263194d8d0b60e21b602082015260240190565b61227d60f01b81526000614216565b6000614347826141ba565b9150614352826141d3565b915061435e828a6141e9565b91506143698261420b565b91506143748261421d565b6d2261747472696275746573223a5b60901b8152600e01915061439782896141e9565b91506143a382886141e9565b7f7b2274726169745f74797065223a2247656e65736973222c202276616c7565228152601d60f91b602082015260210191506143df82876141e9565b91506143ea826142e8565b7f7b2274726169745f74797065223a22537465616b696e67222c202276616c7565815261111d60f11b6020820152602201915061442782866141e9565b9150614432826142e8565b7f7b2274726169745f74797065223a224c6576656c222c202276616c7565223a008152601f01915061446482856141e9565b621f574b60ea1b8152600301915061447b826142f7565b915061448782846141e9565b91506144928261432d565b9998505050505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008152601d0160006117ba82846141e9565b60006144dc826141ba565b91506144e7826141d3565b91506144f382856141e9565b91506144fe8261420b565b91506145098261421d565b7f2261747472696275746573223a5b7b2274726169745f74797065223a2257616981527f74696e6720666f7220546865204d65726765222c202276616c7565223a2254726020820152651d59489f574b60d21b6040820152604601915061456f826142f7565b915061457b82846141e9565b9150611aef8261432d565b60048152600060208201631119585960e21b81529150613b52565b60208082528101610eda81614586565b6012815260006020820171115e18d959591959081b585e081b195d995b60721b81529150613b52565b60208082528101610eda816145b1565b6008815260006020820167111a5cd8589b195960c21b81529150613b52565b60208082528101610eda816145ea565b6009815260006020820168139bdd081b195d995b60ba1b81529150613b52565b60208082528101610eda81614619565b60008261465857614658613fbe565b500690565b7f7b2274726169745f74797065223a2246756e676962696c697479222c2022646981527f73706c61795f74797065223a20226e756d626572222c202276616c7565223a00602082015260005b50603f0190565b7f7b2274726169745f74797065223a224d6f6973747572697a6564222c2022646981527f73706c61795f74797065223a20226e756d626572222c202276616c7565223a00602082015260006146a9565b7f7b2274726169745f74797065223a224b696d6f63686969222c2022646973706c81527f61795f74797065223a20226e756d626572222c202276616c7565223a000000006020820152603c016000614758828b6141e9565b9150614763826142e8565b7f7b2274726169745f74797065223a22555755222c2022646973706c61795f747981527f7065223a20226e756d626572222c202276616c7565223a000000000000000000602082015260370191506147bb828a6141e9565b91506147c6826142e8565b7f7b2274726169745f74797065223a22556c747261736f756e646e657373222c2081527f22646973706c61795f74797065223a20226e756d626572222c202276616c7565602082015261111d60f11b6040820152604201915061482982896141e9565b9150614834826142e8565b915061483f8261465d565b915061484b82886141e9565b9150614856826142e8565b7f7b2274726169745f74797065223a225375676f696e657373222c20226469737081527f6c61795f74797065223a20226e756d626572222c202276616c7565223a0000006020820152603d0191506148ae82876141e9565b91506148b9826142e8565b7f7b2274726169745f74797065223a224b616b6b6f6969222c2022646973706c6181527f795f74797065223a20226e756d626572222c202276616c7565223a00000000006020820152603b01915061491182866141e9565b915061491c826142e8565b7f7b2274726169745f74797065223a224b6177616969222c2022646973706c617981527f5f74797065223a20226e756d626572222c202276616c7565223a0000000000006020820152603a01915061497482856141e9565b915061497f826142e8565b915061498a826146b0565b915061499682846141e9565b91506149a1826142e8565b9a995050505050505050505056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa26469706673582212201c12125d563d904029dce39420fe4b5fb3eb1bbf6f20ae2110eff2025b8925d364736f6c63430008090033

Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.