Contract 0x924bD347FcEf81c695f9799Cb11D46a2F94A7cf4

 
 
Txn Hash
Method
Block
From
To
Value
0x57a4dc2d5ee84d561d0f6074736b22f26f49cf25d31d07ca49fc75bd3f8966d5Set Approval For...149243342022-06-08 2:43:39114 days 19 hrs ago0xca11d10ceb098f597a0cab28117fc3465991a63c IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00507795 108.94325103
0x0897013d77cc572e6fdd8465a10983b76e4c40eda4c6b7686dd7d9f3b4df73a6Set Approval For...147810392022-05-15 16:42:35138 days 5 hrs ago0x2993e1d02b11377f44455aedc618c705acbb0591 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00240187 51.51705109
0xcdd88700852b0d23b828146c2d6915a10b301f51f54b8cae6d2b75c1b15d78b0Set Approval For...147810392022-05-15 16:42:35138 days 5 hrs ago0x2993e1d02b11377f44455aedc618c705acbb0591 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00240187 51.51705109
0x169d0c067c46d08bc6bb729712be214ad3ad98c9c964fc869242504498a5cc2aSet Approval For...146085432022-04-18 10:02:26165 days 12 hrs agoENS Name chiss.eth IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00116155 24.91374305
0xb761ccf25c3242dcc45ac943505b266cfbdcbd227969ba7bb369bf907077c03eWithdraw144850402022-03-30 2:59:58184 days 19 hrs agoCHROMA3: Deployer IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.0010831 35.57826405
0xcc16248509a2f2be2c5fd86716f797ae188182896bbac3262abcb2833629cb11Set Approval For...143281362022-03-05 17:09:06209 days 5 hrs agoENS Name garlicbread.eth IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00182781 39.20411031
0x73065fb69eca3da995c04f316db4a7f767791c6188071705de9822e79ef84d88Set Approval For...138978872021-12-29 3:52:20275 days 18 hrs ago0xe5f09b2fb16414519d90a650f87d0b3813996698 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00277528 59.54143375
0x5e93574d523831a823604367f0207420d2d370043f1af3a3fae43a19d8812c23Set Approval For...132555812021-09-19 10:22:59376 days 12 hrs ago0xa205921cb6ffffe2c567804292406200bd0672b0 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00161462 34.63145642
0x06f9fe493ce7ea72d13c94cf468fe292aa82f6a1204ea4ca347270aaa620f1b1Set Approval For...131987342021-09-10 15:07:38385 days 7 hrs ago0xa36da89068a55db12d63678ed9b48b7a7410a28d IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.0043359393
0x09e8b5bfc21e33dd886ad28d57e53ce335c6a0273a3f734ccb1d0f22db208067Set Approval For...131118692021-08-28 4:52:37398 days 17 hrs ago0x2993e1d02b11377f44455aedc618c705acbb0591 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00275182 59.022874
0x4318c82b284361985a734e621b7550e93b2690e53d9a918d2b4cb7cf482fbc5aBuy Code130983842021-08-26 2:50:42400 days 19 hrs agoCHROMA3: Deployer IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.68 Ether0.01400257 69.16492204
0x534883c7dbccc3a72d6f76ddb416b22bda5136de40d495a06f47052258e1ecc2Buy Code130888342021-08-24 15:26:09402 days 7 hrs ago0xe5f09b2fb16414519d90a650f87d0b3813996698 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.66 Ether0.0170918292.21280661
0xaa5720ab9ebe26911587692509cc507c10fe02fbf42f183f9fdc7b5fcbdbbf59Buy Code130888122021-08-24 15:20:15402 days 7 hrs ago0xe5f09b2fb16414519d90a650f87d0b3813996698 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.64 Ether0.0159940857.07710066
0xce4c40af4bbc5c8199c130ba680b461a5bd3c620893b163caab0a813043a4b2cSet Approval For...130878072021-08-24 11:36:14402 days 10 hrs ago0x22c8d09305d827f1cdf696d1b9ee309227938f95 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00204606 43.88528225
0xa6d8730edcdcac2df5a606fd99b39868910913ccfc18c86a0a9d482dc206f14fBuy Code130829222021-08-23 17:32:43403 days 5 hrs ago0x22c8d09305d827f1cdf696d1b9ee309227938f95 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.62 Ether0.01059162 52.3167138
0xa809cdb8370585ce31a54afa8dba39e03a944fb763ac59b742a7aa13bf384034Set Approval For...130632602021-08-20 16:39:58406 days 5 hrs ago0x7aa69b5ee49c4d3170e037960ca6c83f61241395 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.00199972 42.89130429
0xa20b23e634a9a8d8e2599def3b64a9e338be20ed8540705c7f8584f7aff9989dBuy Code130577482021-08-19 19:59:08407 days 2 hrs ago0xa205921cb6ffffe2c567804292406200bd0672b0 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.6 Ether0.01092908 39.01866462
0xe47fbb10800c0814ef225c98cdc2e93d42a5327e11ae91f5cbb27bf09aa15e7cBuy Code130573532021-08-19 18:28:42407 days 4 hrs ago0x8037d5658e6cb0d6ad9f17e3b32fc64bc5807d51 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.58 Ether0.008211840.56172014
0x775b5f49360596fef1c58c44801e16d7741331df974e5988e54bac0f88a75427Buy Code130573412021-08-19 18:25:21407 days 4 hrs ago0x7aa69b5ee49c4d3170e037960ca6c83f61241395 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.56 Ether0.01300995 64.26192885
0xba9b391cb27befe05e831485517d07c29bb48eb92f6f082046aca9a41cfcace6Buy Code130573362021-08-19 18:23:38407 days 4 hrs ago0x2993e1d02b11377f44455aedc618c705acbb0591 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.54 Ether0.00710208 35.08035464
0x18c5e74c0a0c5abc2824ce9e53bd51575915451990fcf40a4e3415bb3f2a4993Transfer From129614022021-08-04 22:46:34421 days 23 hrs ago0x919c3f8d181f44195627122be8b24196429f3bc9 IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40 Ether0.003842348
0x21c5944c6d36aa8bae55b9949afa847cb6ce4f0c1f6bf369b863226a16822b7cBuy Code129405772021-08-01 16:02:33425 days 6 hrs ago0xe22c1d3b82b028eb0ddf481f64df9a077c25278e IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.52 Ether0.0075994341
0x488e640ef2fb5b9a0a20ccf1ffd0382e8a7911691f29e2cc1ebf62ee833dabadBuy Code129405192021-08-01 15:52:31425 days 6 hrs ago0xe22c1d3b82b028eb0ddf481f64df9a077c25278e IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.5 Ether0.0091103445
0x9d65d5777f8ad204c905506c09a4a0a25f69311360835d30957081cd64355276Buy Code129404602021-08-01 15:39:30425 days 6 hrs ago0xaee2ae13ebf81d38df5a9ed7013e80ea3f72e39b IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf41.38 Ether0.0208957549
0xc8e0aa276ac447a39fbc184e8ed74d8935058623ceb6727e6b63517b662250e8Buy Code129385332021-08-01 8:24:28425 days 14 hrs agoENS Name garlicbread.eth IN  0x924bd347fcef81c695f9799cb11d46a2f94a7cf40.42 Ether0.0075595927
[ Download CSV Export 
Latest 1 internal transaction
Parent Txn Hash Block From To Value
0xb761ccf25c3242dcc45ac943505b266cfbdcbd227969ba7bb369bf907077c03e144850402022-03-30 2:59:58184 days 19 hrs ago 0x924bd347fcef81c695f9799cb11d46a2f94a7cf4CHROMA3: Deployer11.9 Ether
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
ChromaFour

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
No with 200 runs

Other Settings:
default evmVersion
File 1 of 17 : ChromaFour.sol
//
// CollectCode v1.0
// CHROMA Collection, 2021
// https://collect-code.com/
// https://twitter.com/CollectCoder
//

// SPDX-License-Identifier: MIT
// Same version as openzeppelin 3.4
pragma solidity >=0.6.0 <0.8.0;
pragma abicoder v2;

import "./CollectCode.sol";
import "./Utils.sol";

contract ChromaFour is CollectCode
{
    uint8 internal constant GRID_SIZE = 4;
    constructor() ERC721("CHROMA4", "CH4") CollectCode()
    {
        config_ = Config (
            "chroma4",  // (seriesCode)
            40,         // (initialSupply)
            80,         // (maxSupply)
            2,          // (initialPrice) ETH cents
            GRID_SIZE   // (gridSize)
        );
    }
}

File 2 of 17 : CollectCode.sol
//
// CollectCode v1.0
// CHROMA Collection, 2021
// https://collect-code.com/
// https://twitter.com/CollectCoder
//
// TOKEN PERSISTENCY
// Every artwork generated by this contract will live forever on the blockchain
// It will always be available for viewing at collect-code.com and marketplace websites
// In case of adversity, this is how you can see your token...
// 
// 1. Get the metadata url by executing this contract's tokenURI(tokenId) method
// 2. Open a p5js Editor, like this one here: https://editor.p5js.org/
//    If this editor vanishes, here's the source: https://github.com/processing-js/processing-js
// 3. Paste the script below in the editor
// 4. Copy the full metadata url to the script's metadataUrl
// 6. Uncomment the last line if you want to export as a PNG file
// 5. Run!
//
/*-----------------------------------------------
let metadataUrl = "paste_full_metadata_url_here";
let resolution = 600;
function setup()
{
  createCanvas(resolution, resolution);
  let pg = createGraphics(resolution, resolution);
  pg.background(0);
  pg.noStroke();
  const pixels = metadataUrl.split("pixels=")[1];
  const gridSize = sqrt(pixels.length / 6);
  const dx = width / gridSize;
  const dy = height / gridSize;
  for( let y = 0 ; y < gridSize ; y++) {
    const yp = y * gridSize * 6;
    for( let x = 0 ; x < gridSize ; x++) {
      const xp = x  * 6;
      const r = unhex(pixels.substr([yp+xp+0],2));
      const g = unhex(pixels.substr([yp+xp+2],2));
      const b = unhex(pixels.substr([yp+xp+4],2));
      const c = color(r,g,b);
      pg.fill(c);
      pg.rect(x*dx,y*dy,dx,dy);
    }
  }
  image(pg,0,0);
  //saveCanvas(pg, 'CollectCode', 'png');
}
-----------------------------------------------*/


// SPDX-License-Identifier: MIT
// Same version as openzeppelin 3.4
pragma solidity >=0.6.0 <0.8.0;
pragma abicoder v2;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "./Utils.sol";

abstract contract CollectCode is ERC721, Ownable
{
    using SafeMath for uint256;

    struct Config {
        string seriesCode;
        uint256 initialSupply;
        uint256 maxSupply;
        uint256 initialPrice;
        uint8 gridSize;
    }
    Config internal config_;

    struct State {
        bool isReleased;            // Token Zero was minted
        uint256 mintedCount;        // (ignores Token Zero)
        uint256 builtCount;         // (ignores Token Zero)
        uint256 notBuiltCount;      // (ignores Token Zero)
        uint256 currentSupply;      // permitted to mint
        uint256 availableSupply;    // not minted
        uint256 maxBuyout;          // not minted
        bool isAvailable;           // availableSupply > 0
    }
    State internal state_;

    struct TokenInfo {
        address owner;
        bool youOwnIt;
        bool isBuilt;
        address builder;
        uint256 sequenceNumber;
        uint256[] sequenceTokens;
    }

    mapping (uint256 => bytes) internal _colors;
    mapping (uint256 => uint256) internal _sequenceNumber;
    mapping (uint256 => address) internal _builder;

    constructor()
    {
        state_ = State(
            false,  // isReleased
            0,      // mintedCount
            0,      // builtCount
            0,      // notBuiltCount
            0,      // currentSupply
            0,      // availableSupply
            0,      // maxBuyout
            false   // isAvailable
        );
    }

    //
    // public actions
    function giftCode(address to) onlyOwner public returns (uint256)
    {
        require(!state_.isReleased, "CC:AlreadyIssued");
        require(to == owner(), "CC:NotOwner");
        //require(isOwner(), "CC:NotOwner"); // Ownable takes care
        return mintCode_( to, 1, true );
    }
    function buyCode(address to, uint256 quantity, bool build) public payable returns (uint256)
    {
        require(state_.isReleased, "CC: Unreleased");
        require(msg.value == calculatePriceForQuantity(quantity), "CC:BadValue");
        return mintCode_( to, quantity, build );
    }
    function buildCode(uint256 tokenId) public
    {
        require(_exists(tokenId), "CC:BadTokenId");
        require(_colors[tokenId].length == 0, "CC:AlreadyBuilt");
        require(msg.sender == ownerOf(tokenId), "CC:NotOwner");
        buildCode_( msg.sender, tokenId, 0 );
    }
    function withdraw() onlyOwner public {
        msg.sender.transfer(address(this).balance);
    }

    //
    // public getters
    function getConfig() public view returns (Config memory)
    {
        return config_;
    }
    function getState() public view returns (State memory)
    {
        return state_;
    }
    function getTokenInfo(address from, uint256 tokenId) public view returns (TokenInfo memory)
    {
        require(_exists(tokenId), "CC:BadTokenId");
        uint256[] memory sequenceTokens;
        if(_sequenceNumber[tokenId] > 0) {
            // find this token's complete sequence
            uint256 tokenCount = _sequenceNumber[tokenId];
            for(uint256 t = tokenId+1 ; _sequenceNumber[t] > 0 && _sequenceNumber[t] > _sequenceNumber[tokenId] ; ++t)
                tokenCount++;
            sequenceTokens = new uint256[](tokenCount);
            for(uint256 i = 0 ; i < tokenCount ; ++i)
                sequenceTokens[i] = tokenId-_sequenceNumber[tokenId]+1+i;
        }
        return TokenInfo(
            ownerOf(tokenId),               // owner address
            (from == ownerOf(tokenId)),     // sender owns it
            (_colors[tokenId].length > 0),  // is built
            _builder[tokenId],              // user who built the token
            _sequenceNumber[tokenId],       // build sequential number
            sequenceTokens                  // sequence of tokens
        );
    }
    function calculatePriceForQuantity(uint256 quantity) public view returns (uint256)
    {
        uint256 price = 0;
        for(uint256 i = 1 ; i <= quantity ; i++)
            price += state_.mintedCount.add(i) * config_.initialPrice * 10000000000000000; // 1 ETH=1000000000000000000
        return price;
    }
    function getPrices() public view returns (uint256[] memory)
    {
        uint256 quantity = 0;
        if(totalSupply() > 0 && totalSupply() < config_.maxSupply)
            quantity = Utils.max_uint256(state_.maxBuyout, 1);
        uint256[] memory prices = new uint[](quantity);
        for(uint256 i = 1 ; i <= quantity ; i++)
            prices[i-1] = calculatePriceForQuantity(i);
        return prices;
    }
    function getOwnedTokens(address from) public view returns (uint256[] memory)
    {
        uint256[] memory tokenIds = new uint[](balanceOf(from));
        for(uint256 i = 0 ; i < tokenIds.length ; i++)
            tokenIds[i] = tokenOfOwnerByIndex(from, i);
        return tokenIds;
    }

    //
    // Privates
    //

    function mintCode_(address to, uint256 quantity, bool build) internal returns (uint256)
    {
        require(quantity > 0, "CC:BadQuantity");

        if( state_.isReleased )
        {
            require(state_.mintedCount < config_.maxSupply, "CC:SoldOut");
            require(state_.mintedCount < state_.currentSupply, "CC:Unavailable");
            require(state_.mintedCount.add(quantity) <= state_.currentSupply, "CC:TooMany");
            require(quantity <= state_.maxBuyout, "CC:TooMany");
        }

        for(uint256 i = 0 ; i < quantity ; i++)
        {
            uint256 newTokenId = !state_.isReleased ? 0 : state_.mintedCount.add(1);
            _mint( to, newTokenId );

            // update contract state
            state_.isReleased = true;
            state_.mintedCount = newTokenId;
            if(newTokenId > 0) {
                state_.notBuiltCount++;
            }
            
            if( build ) {
                buildCode_(to, newTokenId, quantity == 1 ? 0 : (i+1));
            } else {
                calculateSupply_();
            }
        }

        return quantity;
    }

    function buildCode_(address to, uint256 tokenId, uint256 sequenceNumber) internal
    {
        _builder[tokenId] = to;
        _sequenceNumber[tokenId] = sequenceNumber;
        _colors[tokenId] = Utils.reduceColors(
            bytes20(address(this)),   // seed 1: contract address
            bytes20(to),              // seed 2: owner address
            Utils.getBlockSeed(),     // seed 3: block hash
            uint8(config_.gridSize*2), tokenId*config_.gridSize);

        // increase built count for supply (ignore Token Zero)
        if(tokenId > 0)
        {
            state_.notBuiltCount--;
            state_.builtCount++;
        }
        calculateSupply_();
    }

    function calculateSupply_() internal
    {
        if(state_.mintedCount < config_.initialSupply) {
            // Initial supply must go first
            state_.currentSupply = config_.initialSupply;
        }
        else {
            // Release 10% minus not build tokens
            uint256 surplus = Utils.percent_uint256(config_.maxSupply, 10);
            state_.currentSupply = state_.mintedCount   // minted
                + surplus                               // add 10%
                - Utils.clamp_uint256(state_.notBuiltCount, 0, surplus);    // minus not built
            if(state_.currentSupply > config_.maxSupply)
                state_.currentSupply = config_.maxSupply;
        }
        state_.availableSupply = state_.currentSupply - state_.mintedCount;
        state_.maxBuyout = Utils.min_uint256( state_.availableSupply, Utils.percent_uint256(config_.maxSupply, 5) );
        state_.isAvailable = (state_.availableSupply > 0);
    }

    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "CC:BadTokenId");
        return string(abi.encodePacked(
            "https://collect-code.com/api/token/", config_.seriesCode,
            "/", Utils.utoa(uint(tokenId)),
            "/metadata?v=1&pixels=", (_colors[tokenId].length > 0 ? Utils.convertToHexString(Utils.makePixels(config_.gridSize, _colors[tokenId])) : '') ));
    }
}

File 3 of 17 : Utils.sol
//
// CollectCode v1.0
// CHROMA Collection, 2021
// https://collect-code.com/
// https://twitter.com/CollectCoder
//

// SPDX-License-Identifier: MIT
// Same version as openzeppelin 3.4
pragma solidity >=0.6.0 <0.8.0;

library Utils
{
    //---------------------------
    // Convert
    //

    function convertBlockHashToAddress(uint256 blockNumber) public view returns (address)
    {
        // https://docs.soliditylang.org/en/v0.7.6/types.html#address
        return address(uint160(bytes20(blockhash(blockNumber))));
    }

    function getBlockSeed() public view returns (bytes20)
    {
        address s = convertBlockHashToAddress(block.number);
        if( s == address(0) && block.number > 0 )
            s = convertBlockHashToAddress(block.number-1);
        return bytes20(s);
    }

    function convertToHexString(uint8[] memory values) public pure returns (string memory)
    {
        bytes memory result = new bytes(values.length*2);
        for(uint8 i = 0; i < values.length; i++)
        {
            for(uint8 j = 0 ; j < 2; j++)
            {
                uint8 v = ( j == 0 ? (values[i]>>4) : (values[i] & 0x0f) );
                result[i*2+j] = v > 9 ? byte(55+v) : byte(48+v);
            }
        }
        return string(result);
    }

    //---------------------------
    // Math
    //

    function clamp_uint256(uint256 value, uint256 min, uint256 max) public pure returns (uint256)
    {
        return value < min ? min : value > max ? max : value;
    }

    function min_uint256(uint256 a, uint256 b) public pure returns (uint256) {
        return a < b ? a : b;
    }

    function max_uint256(uint256 a, uint256 b) public pure returns (uint256) {
        return a > b ? a : b;
    }

    function percent_uint256(uint256 value, uint256 percentage) public pure returns (uint256)
    {
        return value * percentage / 100;
    }

    //---------------------------
    // Pixels
    //
    function step_int(int min, int max, int stepCount, int stepIndex) public pure returns (int)
    {
        if( stepIndex <= 0 || stepCount <= 1 || min == max )
            return min;
        if( stepIndex >= stepCount - 1 )
            return max;
        return min + (((max - min) / (stepCount - 1)) * stepIndex);
    }
    function step_uint8(uint8 min, uint8 max, uint8 stepCount, uint8 stepIndex) public pure returns (uint8)
    {
        int result = step_int( min, max, stepCount, stepIndex );
        return result < 0 ? 0 : result > 255 ? 255 : uint8(result);
    }

    function map_uint256(uint256 value, uint256 min, uint256 max) public pure returns (uint256)
    {
        return min + ((value * (max - min)) / 255);
    }

    function map_uint8(uint8 value, uint8 min, uint8 max) public pure returns (uint8)
    {
        return uint8(int(min) + ((int(value) * int(max - min)) / 255));
    }

    // function rshift_bytes20(bytes20 buffer, uint256 bits) public pure returns (bytes20)
    // {
    //     return (buffer >> (bits%160)) | (buffer << (160-(bits%160)));
    // }

    function lshift_bytes20(bytes20 buffer, uint256 bits) public pure returns (bytes20)
    {
        return (buffer << (bits%160)) | (buffer >> (160-(bits%160)));
    }

    function sum_bytes20(bytes20 buffer) public pure returns (uint256)
    {
        uint256 sum = 0;
        for(uint8 i = 0 ; i < 20 ; ++i) {
            sum += uint8(buffer[i]);
        }
        return sum;
    }

    // HSV Conversion from
    // https://stackoverflow.com/a/14733008/360930
    function hsvToRgb(uint8 h, uint8 s, uint8 v) public pure returns (byte, byte, byte)
    {
        if (s == 0) {
            return (byte(v), byte(v), byte(v));
        }
        int region = h / 43;
        int remainder = (h - (region * 43)) * 6; 
        int p = (v * (255 - s)) >> 8;
        int q = (v * (255 - ((s * remainder) >> 8))) >> 8;
        int t = (v * (255 - ((s * (255 - remainder)) >> 8))) >> 8;
        if(region == 0) {
            return(byte(v), byte(uint8(t)), byte(uint8(p)));
        } else if (region == 1) {
            return(byte(uint8(q)), byte(v), byte(uint8(p)));
        } else if (region == 2) {
            return(byte(uint8(p)), byte(v), byte(uint8(t)));
        } else if (region == 3) {
            return(byte(uint8(p)), byte(uint8(q)), byte(v));
        } else if (region == 4) {
            return(byte(uint8(t)), byte(uint8(p)), byte(v));
        }
        return(byte(v), byte(uint8(p)), byte(uint8(q)));
    }

    function reduceColors(bytes20 s0, bytes20 s1, bytes20 s2, uint8 colorCount, uint256 offset) public pure returns (bytes memory)
    {
        bytes memory c3 = new bytes(colorCount*3);
        uint256 sum0 = sum_bytes20(s0) + sum_bytes20(s1);
        uint256 sum2 = sum_bytes20(s2);
        bytes20 hues = lshift_bytes20(s2, sum2 + (offset*8));
        for(uint8 c = 0 ; c < colorCount ; c++) {
            uint8 h = uint8(hues[c]);
            uint8 s = map_uint8(uint8((uint256(uint8(hues[c+10])) + sum0*3) % 256), (64+(5-(colorCount/2))*30), 255);
            uint8 v = map_uint8(h|uint8((uint256(uint8(hues[c+10])) + sum0) % 256), (127+(5-(colorCount/2))*30), 255);
            h = uint8(map_uint256(h, sum2, sum2+map_uint8(uint8((sum2+sum0)%256),100,240))%256);
            // h = uint8(map_uint256(h, lh, lh+192)%256);
            (c3[c*3+0], c3[c*3+1], c3[c*3+2]) = hsvToRgb(h,s,v);
        }
        return (c3);
    }

    function makePixels(uint8 gridSize, bytes memory c3) public pure returns (uint8[] memory)
    {
        uint8 i = 0;
        uint8[] memory pixels = new uint8[](gridSize*gridSize*3);
        for(uint8 y = 0 ; y < gridSize ; y++) {
            for(uint8 x = 0 ; x < gridSize ; x++) {
                pixels[i++] = step_uint8( uint8(c3[x*3+0]), uint8(c3[(x+gridSize)*3+0]), gridSize, y );
                pixels[i++] = step_uint8( uint8(c3[x*3+1]), uint8(c3[(x+gridSize)*3+1]), gridSize, y );
                pixels[i++] = step_uint8( uint8(c3[x*3+2]), uint8(c3[(x+gridSize)*3+2]), gridSize, y );
            }
        }
        return pixels;
    }

    //
    // From truffle/Assert.sol
    // MIT Licence
    //
    uint8 constant ZERO = uint8(bytes1('0'));
    uint8 constant A = uint8(bytes1('a'));
    bytes1 constant MINUS = bytes1('-');
    function utoa(uint n) public pure returns (string memory)
    {
        return utoa(n, 10);
    }
    function utoa(uint n, uint8 radix) public pure returns (string memory) {
        if (n == 0 || radix < 2 || radix > 16)
            return '0';
        bytes memory bts = new bytes(256);
        uint i;
        while (n > 0) {
            bts[i++] = _utoa(uint8(uint(n % radix))); // Turn it to ascii.
            n /= radix;
        }
        // Reverse
        bytes memory rev = new bytes(i);
        for (uint j = 0; j < i; j++)
            rev[j] = bts[i - j - 1];
        return string(rev);
    }
    function _utoa(uint8 u) public pure returns (bytes1) {
        if (u < 10)
            return bytes1(u + ZERO);
        else if (u < 16)
            return bytes1(u - 10 + A);
        else
            return 0;
    }
}

File 4 of 17 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

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

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

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

File 5 of 17 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts may inherit from this and call {_registerInterface} to declare
 * their support of an interface.
 */
abstract contract ERC165 is IERC165 {
    /*
     * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
     */
    bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;

    /**
     * @dev Mapping of interface ids to whether or not it's supported.
     */
    mapping(bytes4 => bool) private _supportedInterfaces;

    constructor () internal {
        // Derived contracts need only register support for their own interfaces,
        // we register support for ERC165 itself here
        _registerInterface(_INTERFACE_ID_ERC165);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     *
     * Time complexity O(1), guaranteed to always use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return _supportedInterfaces[interfaceId];
    }

    /**
     * @dev Registers the contract as an implementer of the interface defined by
     * `interfaceId`. Support of the actual ERC165 interface is automatic and
     * registering its interface id is not required.
     *
     * See {IERC165-supportsInterface}.
     *
     * Requirements:
     *
     * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
     */
    function _registerInterface(bytes4 interfaceId) internal virtual {
        require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
        _supportedInterfaces[interfaceId] = true;
    }
}

File 6 of 17 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 7 of 17 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 8 of 17 : ERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "../../utils/Context.sol";
import "./IERC721.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
import "./IERC721Receiver.sol";
import "../../introspection/ERC165.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
import "../../utils/EnumerableSet.sol";
import "../../utils/EnumerableMap.sol";
import "../../utils/Strings.sol";

/**
 * @title ERC721 Non-Fungible Token Standard basic implementation
 * @dev see https://eips.ethereum.org/EIPS/eip-721
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
    using SafeMath for uint256;
    using Address for address;
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableMap for EnumerableMap.UintToAddressMap;
    using Strings for uint256;

    // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
    // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
    bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;

    // Mapping from holder address to their (enumerable) set of owned tokens
    mapping (address => EnumerableSet.UintSet) private _holderTokens;

    // Enumerable mapping from token ids to their owners
    EnumerableMap.UintToAddressMap private _tokenOwners;

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Optional mapping for token URIs
    mapping (uint256 => string) private _tokenURIs;

    // Base URI
    string private _baseURI;

    /*
     *     bytes4(keccak256('balanceOf(address)')) == 0x70a08231
     *     bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
     *     bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
     *     bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
     *     bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
     *     bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
     *     bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
     *     bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
     *
     *     => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
     *        0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
     */
    bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;

    /*
     *     bytes4(keccak256('name()')) == 0x06fdde03
     *     bytes4(keccak256('symbol()')) == 0x95d89b41
     *     bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
     *
     *     => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
     */
    bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;

    /*
     *     bytes4(keccak256('totalSupply()')) == 0x18160ddd
     *     bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
     *     bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
     *
     *     => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
     */
    bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;

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

        // register the supported interfaces to conform to ERC721 via ERC165
        _registerInterface(_INTERFACE_ID_ERC721);
        _registerInterface(_INTERFACE_ID_ERC721_METADATA);
        _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
    }

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

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
    }

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

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

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

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        }
        // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
        return string(abi.encodePacked(base, tokenId.toString()));
    }

    /**
    * @dev Returns the base URI set via {_setBaseURI}. This will be
    * automatically added as a prefix in {tokenURI} to each token's URI, or
    * to the token ID if no specific URI is set for that token ID.
    */
    function baseURI() public view virtual returns (string memory) {
        return _baseURI;
    }

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        return _holderTokens[owner].at(index);
    }

    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
        return _tokenOwners.length();
    }

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        (uint256 tokenId, ) = _tokenOwners.at(index);
        return tokenId;
    }

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     d*
     * - `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);

        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

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

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

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

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

        // Clear metadata (if any)
        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }

        _holderTokens[owner].remove(tokenId);

        _tokenOwners.remove(tokenId);

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

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

        _holderTokens[from].remove(tokenId);
        _holderTokens[to].add(tokenId);

        _tokenOwners.set(tokenId, to);

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev Internal function to set the base URI for all token IDs. It is
     * automatically added as a prefix to the value returned in {tokenURI},
     * or to the token ID if {tokenURI} is empty.
     */
    function _setBaseURI(string memory baseURI_) internal virtual {
        _baseURI = baseURI_;
    }

    /**
     * @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()) {
            return true;
        }
        bytes memory returndata = to.functionCall(abi.encodeWithSelector(
            IERC721Receiver(to).onERC721Received.selector,
            _msgSender(),
            from,
            tokenId,
            _data
        ), "ERC721: transfer to non ERC721Receiver implementer");
        bytes4 retval = abi.decode(returndata, (bytes4));
        return (retval == _ERC721_RECEIVED);
    }

    function _approve(address to, uint256 tokenId) private {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner
    }

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

File 9 of 17 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 10 of 17 : IERC721Enumerable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

import "./IERC721.sol";

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

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

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

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

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

pragma solidity >=0.6.2 <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 17 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

File 13 of 17 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity >=0.6.0 <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 GSN 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 payable) {
        return msg.sender;
    }

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

File 15 of 17 : EnumerableMap.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing an enumerable variant of Solidity's
 * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
 * type.
 *
 * Maps have the following properties:
 *
 * - Entries are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Entries are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableMap for EnumerableMap.UintToAddressMap;
 *
 *     // Declare a set state variable
 *     EnumerableMap.UintToAddressMap private myMap;
 * }
 * ```
 *
 * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
 * supported.
 */
library EnumerableMap {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Map type with
    // bytes32 keys and values.
    // The Map implementation uses private functions, and user-facing
    // implementations (such as Uint256ToAddressMap) are just wrappers around
    // the underlying Map.
    // This means that we can only create new EnumerableMaps for types that fit
    // in bytes32.

    struct MapEntry {
        bytes32 _key;
        bytes32 _value;
    }

    struct Map {
        // Storage of map keys and values
        MapEntry[] _entries;

        // Position of the entry defined by a key in the `entries` array, plus 1
        // because index 0 means a key is not in the map.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
        // We read and store the key's index to prevent multiple reads from the same storage slot
        uint256 keyIndex = map._indexes[key];

        if (keyIndex == 0) { // Equivalent to !contains(map, key)
            map._entries.push(MapEntry({ _key: key, _value: value }));
            // The entry is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            map._indexes[key] = map._entries.length;
            return true;
        } else {
            map._entries[keyIndex - 1]._value = value;
            return false;
        }
    }

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

        if (keyIndex != 0) { // Equivalent to contains(map, key)
            // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
            // in the array, and then remove the last entry (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = keyIndex - 1;
            uint256 lastIndex = map._entries.length - 1;

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

            MapEntry storage lastEntry = map._entries[lastIndex];

            // Move the last entry to the index where the entry to delete is
            map._entries[toDeleteIndex] = lastEntry;
            // Update the index for the moved entry
            map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved entry was stored
            map._entries.pop();

            // Delete the index for the deleted slot
            delete map._indexes[key];

            return true;
        } else {
            return false;
        }
    }

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

    /**
     * @dev Returns the number of key-value pairs in the map. O(1).
     */
    function _length(Map storage map) private view returns (uint256) {
        return map._entries.length;
    }

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

        MapEntry storage entry = map._entries[index];
        return (entry._key, entry._value);
    }

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     */
    function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
        uint256 keyIndex = map._indexes[key];
        if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
        return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function _get(Map storage map, bytes32 key) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    /**
     * @dev Same as {_get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {_tryGet}.
     */
    function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
        uint256 keyIndex = map._indexes[key];
        require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
        return map._entries[keyIndex - 1]._value; // All indexes are 1-based
    }

    // UintToAddressMap

    struct UintToAddressMap {
        Map _inner;
    }

    /**
     * @dev Adds a key-value pair to a map, or updates the value for an existing
     * key. O(1).
     *
     * Returns true if the key was added to the map, that is if it was not
     * already present.
     */
    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
        return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
    }

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

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

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

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

    /**
     * @dev Tries to returns the value associated with `key`.  O(1).
     * Does not revert if `key` is not in the map.
     *
     * _Available since v3.4._
     */
    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
        (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
        return (success, address(uint160(uint256(value))));
    }

    /**
     * @dev Returns the value associated with `key`.  O(1).
     *
     * Requirements:
     *
     * - `key` must be in the map.
     */
    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key)))));
    }

    /**
     * @dev Same as {get}, with a custom error message when `key` is not in the map.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryGet}.
     */
    function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
        return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
    }
}

File 16 of 17 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

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

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

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

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

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

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

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

            bytes32 lastvalue = set._values[lastIndex];

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

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

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

            return true;
        } else {
            return false;
        }
    }

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

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

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

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

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

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

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

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

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

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

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

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

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

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

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


    // UintSet

    struct UintSet {
        Set _inner;
    }

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

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

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

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

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

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

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    /**
     * @dev Converts a `uint256` to its ASCII `string` 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);
        uint256 index = digits - 1;
        temp = value;
        while (temp != 0) {
            buffer[index--] = bytes1(uint8(48 + temp % 10));
            temp /= 10;
        }
        return string(buffer);
    }
}

Settings
{
  "remappings": [],
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "evmVersion": "istanbul",
  "libraries": {
    "/Users/roger/Dev/Blockchain/Truffle/code-collect/contracts/Utils.sol": {
      "Utils": "0x88a9EABC4CBb315B92C19521eF47FB987eDD630b"
    }
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"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":[{"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":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"buildCode","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"quantity","type":"uint256"},{"internalType":"bool","name":"build","type":"bool"}],"name":"buyCode","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"quantity","type":"uint256"}],"name":"calculatePriceForQuantity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getConfig","outputs":[{"components":[{"internalType":"string","name":"seriesCode","type":"string"},{"internalType":"uint256","name":"initialSupply","type":"uint256"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"initialPrice","type":"uint256"},{"internalType":"uint8","name":"gridSize","type":"uint8"}],"internalType":"struct CollectCode.Config","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"}],"name":"getOwnedTokens","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrices","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getState","outputs":[{"components":[{"internalType":"bool","name":"isReleased","type":"bool"},{"internalType":"uint256","name":"mintedCount","type":"uint256"},{"internalType":"uint256","name":"builtCount","type":"uint256"},{"internalType":"uint256","name":"notBuiltCount","type":"uint256"},{"internalType":"uint256","name":"currentSupply","type":"uint256"},{"internalType":"uint256","name":"availableSupply","type":"uint256"},{"internalType":"uint256","name":"maxBuyout","type":"uint256"},{"internalType":"bool","name":"isAvailable","type":"bool"}],"internalType":"struct CollectCode.State","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenInfo","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"bool","name":"youOwnIt","type":"bool"},{"internalType":"bool","name":"isBuilt","type":"bool"},{"internalType":"address","name":"builder","type":"address"},{"internalType":"uint256","name":"sequenceNumber","type":"uint256"},{"internalType":"uint256[]","name":"sequenceTokens","type":"uint256[]"}],"internalType":"struct CollectCode.TokenInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"giftCode","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","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":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"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":"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":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b506040518060400160405280600781526020017f4348524f4d4134000000000000000000000000000000000000000000000000008152506040518060400160405280600381526020017f4348340000000000000000000000000000000000000000000000000000000000815250620000966301ffc9a760e01b6200035660201b60201c565b8160069080519060200190620000ae92919062000467565b508060079080519060200190620000c792919062000467565b50620000e06380ac58cd60e01b6200035660201b60201c565b620000f8635b5e139f60e01b6200035660201b60201c565b6200011063780e9d6360e01b6200035660201b60201c565b50506000620001246200045f60201b60201c565b905080600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508073ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35060405180610100016040528060001515815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160001515815250601060008201518160000160006101000a81548160ff0219169083151502179055506020820151816001015560408201518160020155606082015181600301556080820151816004015560a0820151816005015560c0820151816006015560e08201518160070160006101000a81548160ff0219169083151502179055509050506040518060a001604052806040518060400160405280600781526020017f6368726f6d6134000000000000000000000000000000000000000000000000008152508152602001602881526020016050815260200160028152602001600460ff16815250600b60008201518160000190805190602001906200030d92919062000467565b5060208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a81548160ff021916908360ff1602179055509050506200051d565b63ffffffff60e01b817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19161415620003f3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433136353a20696e76616c696420696e746572666163652069640000000081525060200191505060405180910390fd5b6001600080837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060006101000a81548160ff02191690831515021790555050565b600033905090565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826200049f5760008555620004eb565b82601f10620004ba57805160ff1916838001178555620004eb565b82800160010185558215620004eb579182015b82811115620004ea578251825591602001919060010190620004cd565b5b509050620004fa9190620004fe565b5090565b5b8082111562000519576000816000905550600101620004ff565b5090565b6154d5806200052d6000396000f3fe6080604052600436106101cc5760003560e01c806370a08231116100f7578063bbd7d20911610095578063d9d6165511610064578063d9d61655146106a2578063e93f0689146106df578063e985e9c51461071c578063f2fde38b14610759576101cc565b8063bbd7d209146105d2578063bd9a548b1461060f578063c3f909d41461063a578063c87b56dd14610665576101cc565b80638da5cb5b116100d15780638da5cb5b1461052a57806395d89b4114610555578063a22cb46514610580578063b88d4fde146105a9576101cc565b806370a08231146104ad578063715018a6146104ea578063867a5b3714610501576101cc565b806323b872dd1161016f5780634f6ccce71161013e5780634f6ccce7146103cb57806356d6555c146104085780636352211e146104455780636c0360eb14610482576101cc565b806323b872dd146103255780632f745c591461034e5780633ccfd60b1461038b57806342842e0e146103a2576101cc565b8063081812fc116101ab578063081812fc14610269578063095ea7b3146102a657806318160ddd146102cf5780631865c57d146102fa576101cc565b80628bdca9146101d157806301ffc9a71461020157806306fdde031461023e575b600080fd5b6101eb60048036038101906101e6919061400a565b610782565b6040516101f89190614dae565b60405180910390f35b34801561020d57600080fd5b50610228600480360381019061022391906140c3565b610834565b6040516102359190614b63565b60405180910390f35b34801561024a57600080fd5b5061025361089b565b6040516102609190614bd1565b60405180910390f35b34801561027557600080fd5b50610290600480360381019061028b919061416e565b61093d565b60405161029d9190614b04565b60405180910390f35b3480156102b257600080fd5b506102cd60048036038101906102c89190613fce565b6109d8565b005b3480156102db57600080fd5b506102e4610b1c565b6040516102f19190614dae565b60405180910390f35b34801561030657600080fd5b5061030f610b2d565b60405161031c9190614d55565b60405180910390f35b34801561033157600080fd5b5061034c60048036038101906103479190613ec8565b610bba565b005b34801561035a57600080fd5b5061037560048036038101906103709190613fce565b610c30565b6040516103829190614dae565b60405180910390f35b34801561039757600080fd5b506103a0610c8b565b005b3480156103ae57600080fd5b506103c960048036038101906103c49190613ec8565b610d83565b005b3480156103d757600080fd5b506103f260048036038101906103ed919061416e565b610da3565b6040516103ff9190614dae565b60405180910390f35b34801561041457600080fd5b5061042f600480360381019061042a9190613e63565b610dc6565b60405161043c9190614dae565b60405180910390f35b34801561045157600080fd5b5061046c6004803603810190610467919061416e565b610f52565b6040516104799190614b04565b60405180910390f35b34801561048e57600080fd5b50610497610f89565b6040516104a49190614bd1565b60405180910390f35b3480156104b957600080fd5b506104d460048036038101906104cf9190613e63565b61102b565b6040516104e19190614dae565b60405180910390f35b3480156104f657600080fd5b506104ff611100565b005b34801561050d57600080fd5b506105286004803603810190610523919061416e565b611270565b005b34801561053657600080fd5b5061053f6113a7565b60405161054c9190614b04565b60405180910390f35b34801561056157600080fd5b5061056a6113d1565b6040516105779190614bd1565b60405180910390f35b34801561058c57600080fd5b506105a760048036038101906105a29190613f92565b611473565b005b3480156105b557600080fd5b506105d060048036038101906105cb9190613f17565b611629565b005b3480156105de57600080fd5b506105f960048036038101906105f49190613fce565b6116a1565b6040516106069190614d71565b60405180910390f35b34801561061b57600080fd5b5061062461193a565b6040516106319190614b1f565b60405180910390f35b34801561064657600080fd5b5061064f611a89565b60405161065c9190614d33565b60405180910390f35b34801561067157600080fd5b5061068c6004803603810190610687919061416e565b611b80565b6040516106999190614bd1565b60405180910390f35b3480156106ae57600080fd5b506106c960048036038101906106c49190613e63565b611e05565b6040516106d69190614b1f565b60405180910390f35b3480156106eb57600080fd5b506107066004803603810190610701919061416e565b611e9f565b6040516107139190614dae565b60405180910390f35b34801561072857600080fd5b50610743600480360381019061073e9190613e8c565b611ef7565b6040516107509190614b63565b60405180910390f35b34801561076557600080fd5b50610780600480360381019061077b9190613e63565b611f8b565b005b6000601060000160009054906101000a900460ff166107d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107cd90614c13565b60405180910390fd5b6107df83611e9f565b3414610820576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081790614c33565b60405180910390fd5b61082b848484612180565b90509392505050565b6000806000837bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916815260200190815260200160002060009054906101000a900460ff169050919050565b606060068054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156109335780601f1061090857610100808354040283529160200191610933565b820191906000526020600020905b81548152906001019060200180831161091657829003601f168201915b5050505050905090565b600061094882612400565b61099d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c8152602001806153f9602c913960400191505060405180910390fd5b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006109e382610f52565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a6a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602181526020018061544e6021913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610a8961241d565b73ffffffffffffffffffffffffffffffffffffffff161480610ab85750610ab781610ab261241d565b611ef7565b5b610b0d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603881526020018061534c6038913960400191505060405180910390fd5b610b178383612425565b505050565b6000610b2860026124de565b905090565b610b35613a76565b6010604051806101000160405290816000820160009054906101000a900460ff161515151581526020016001820154815260200160028201548152602001600382015481526020016004820154815260200160058201548152602001600682015481526020016007820160009054906101000a900460ff161515151581525050905090565b610bcb610bc561241d565b826124f3565b610c20576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603181526020018061546f6031913960400191505060405180910390fd5b610c2b8383836125e7565b505050565b6000610c8382600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061282a90919063ffffffff16565b905092915050565b610c9361241d565b73ffffffffffffffffffffffffffffffffffffffff16610cb16113a7565b73ffffffffffffffffffffffffffffffffffffffff1614610d3a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610d80573d6000803e3d6000fd5b50565b610d9e83838360405180602001604052806000815250611629565b505050565b600080610dba83600261284490919063ffffffff16565b50905080915050919050565b6000610dd061241d565b73ffffffffffffffffffffffffffffffffffffffff16610dee6113a7565b73ffffffffffffffffffffffffffffffffffffffff1614610e77576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b601060000160009054906101000a900460ff1615610eca576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ec190614c53565b60405180910390fd5b610ed26113a7565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614610f3f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f3690614cb3565b60405180910390fd5b610f4b82600180612180565b9050919050565b6000610f82826040518060600160405280602981526020016153ae6029913960026128709092919063ffffffff16565b9050919050565b606060098054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156110215780601f10610ff657610100808354040283529160200191611021565b820191906000526020600020905b81548152906001019060200180831161100457829003601f168201915b5050505050905090565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156110b2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180615384602a913960400191505060405180910390fd5b6110f9600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061288f565b9050919050565b61110861241d565b73ffffffffffffffffffffffffffffffffffffffff166111266113a7565b73ffffffffffffffffffffffffffffffffffffffff16146111af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a36000600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550565b61127981612400565b6112b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112af90614c93565b60405180910390fd5b60006018600083815260200190815260200160002080546001816001161561010002031660029004905014611322576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131990614d13565b60405180910390fd5b61132b81610f52565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611398576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161138f90614cb3565b60405180910390fd5b6113a4338260006128a4565b50565b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060078054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114695780601f1061143e57610100808354040283529160200191611469565b820191906000526020600020905b81548152906001019060200180831161144c57829003601f168201915b5050505050905090565b61147b61241d565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561151c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f4552433732313a20617070726f766520746f2063616c6c65720000000000000081525060200191505060405180910390fd5b806005600061152961241d565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff166115d661241d565b73ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c318360405180821515815260200191505060405180910390a35050565b61163a61163461241d565b836124f3565b61168f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603181526020018061546f6031913960400191505060405180910390fd5b61169b84848484612ab8565b50505050565b6116a9613abf565b6116b282612400565b6116f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116e890614c93565b60405180910390fd5b60606000601960008581526020019081526020016000205411156118265760006019600085815260200190815260200160002054905060006001850190505b60006019600083815260200190815260200160002054118015611778575060196000868152602001908152602001600020546019600083815260200190815260200160002054115b15611790578180600101925050806001019050611730565b508067ffffffffffffffff811180156117a857600080fd5b506040519080825280602002602001820160405280156117d75781602001602082028036833780820191505090505b50915060005b818110156118235780600160196000888152602001908152602001600020548703010183828151811061180c57fe5b6020026020010181815250508060010190506117dd565b50505b6040518060c0016040528061183a85610f52565b73ffffffffffffffffffffffffffffffffffffffff16815260200161185e85610f52565b73ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1614151581526020016000601860008781526020019081526020016000208054600181600116156101000203166002900490501115158152602001601a600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001601960008681526020019081526020016000205481526020018281525091505092915050565b6060600080611947610b1c565b11801561195f5750600b6002015461195d610b1c565b105b156119f6577388a9eabc4cbb315b92c19521ef47fb987edd630b63dee392f360106006015460016040518363ffffffff1660e01b81526004016119a3929190614e29565b60206040518083038186803b1580156119bb57600080fd5b505af41580156119cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119f39190614197565b90505b60008167ffffffffffffffff81118015611a0f57600080fd5b50604051908082528060200260200182016040528015611a3e5781602001602082028036833780820191505090505b5090506000600190505b828111611a8057611a5881611e9f565b826001830381518110611a6757fe5b6020026020010181815250508080600101915050611a48565b50809250505090565b611a91613b25565b600b6040518060a0016040529081600082018054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015611b375780601f10611b0c57610100808354040283529160200191611b37565b820191906000526020600020905b815481529060010190602001808311611b1a57829003601f168201915b505050505081526020016001820154815260200160028201548152602001600382015481526020016004820160009054906101000a900460ff1660ff1660ff1681525050905090565b6060611b8b82612400565b611bca576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bc190614c93565b60405180910390fd5b600b6000017388a9eabc4cbb315b92c19521ef47fb987edd630b63385fe678846040518263ffffffff1660e01b8152600401611c069190614d93565b60006040518083038186803b158015611c1e57600080fd5b505af4158015611c32573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611c5b919061412d565b60006018600086815260200190815260200160002080546001816001161561010002031660029004905011611c9f5760405180602001604052806000815250611ddd565b7388a9eabc4cbb315b92c19521ef47fb987edd630b638d0a9bd47388a9eabc4cbb315b92c19521ef47fb987edd630b631e1a5fb8600b60040160009054906101000a900460ff16601860008a81526020019081526020016000206040518363ffffffff1660e01b8152600401611d16929190614ea4565b60006040518083038186803b158015611d2e57600080fd5b505af4158015611d42573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611d6b9190614059565b6040518263ffffffff1660e01b8152600401611d879190614b41565b60006040518083038186803b158015611d9f57600080fd5b505af4158015611db3573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190611ddc919061412d565b5b604051602001611def93929190614ab2565b6040516020818303038152906040529050919050565b60606000611e128361102b565b67ffffffffffffffff81118015611e2857600080fd5b50604051908082528060200260200182016040528015611e575781602001602082028036833780820191505090505b50905060005b8151811015611e9557611e708482610c30565b828281518110611e7c57fe5b6020026020010181815250508080600101915050611e5d565b5080915050919050565b600080600090506000600190505b838111611eed57662386f26fc10000600b60030154611eda83601060010154612b2a90919063ffffffff16565b0202820191508080600101915050611ead565b5080915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611f9361241d565b73ffffffffffffffffffffffffffffffffffffffff16611fb16113a7565b73ffffffffffffffffffffffffffffffffffffffff161461203a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657281525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156120c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806152b06026913960400191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a380600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008083116121c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121bb90614bf3565b60405180910390fd5b601060000160009054906101000a900460ff161561231c57600b6002015460106001015410612228576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161221f90614cf3565b60405180910390fd5b60106004015460106001015410612274576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161226b90614cd3565b60405180910390fd5b60106004015461229284601060010154612b2a90919063ffffffff16565b11156122d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122ca90614c73565b60405180910390fd5b60106006015483111561231b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161231290614c73565b60405180910390fd5b5b60005b838110156123f5576000601060000160009054906101000a900460ff161561235f5761235a6001601060010154612b2a90919063ffffffff16565b612362565b60005b905061236e8682612bb2565b6001601060000160006101000a81548160ff0219169083151502179055508060106001018190555060008111156123b5576010600301600081548092919060010191905055505b83156123de576123d98682600188146123d157600185016123d4565b60005b6128a4565b6123e7565b6123e6612da6565b5b50808060010191505061231f565b508290509392505050565b600061241682600261308890919063ffffffff16565b9050919050565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff1661249883610f52565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60006124ec826000016130a2565b9050919050565b60006124fe82612400565b612553576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602c815260200180615320602c913960400191505060405180910390fd5b600061255e83610f52565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806125cd57508373ffffffffffffffffffffffffffffffffffffffff166125b58461093d565b73ffffffffffffffffffffffffffffffffffffffff16145b806125de57506125dd8185611ef7565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff1661260782610f52565b73ffffffffffffffffffffffffffffffffffffffff1614612673576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806154256029913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614156126f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806152d66024913960400191505060405180910390fd5b6127048383836130b3565b61270f600082612425565b61276081600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206130b890919063ffffffff16565b506127b281600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206130d290919063ffffffff16565b506127c9818360026130ec9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b60006128398360000183613121565b60001c905092915050565b60008060008061285786600001866131a4565b915091508160001c8160001c9350935050509250929050565b6000612883846000018460001b8461323d565b60001c90509392505050565b600061289d82600001613333565b9050919050565b82601a600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060196000848152602001908152602001600020819055507388a9eabc4cbb315b92c19521ef47fb987edd630b639f7311e03060601b8560601b7388a9eabc4cbb315b92c19521ef47fb987edd630b6306e952f36040518163ffffffff1660e01b815260040160206040518083038186803b15801561297457600080fd5b505af4158015612988573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129ac919061409a565b6002600b60040160009054906101000a900460ff1602600b60040160009054906101000a900460ff1660ff1688026040518663ffffffff1660e01b81526004016129fa959493929190614b7e565b60006040518083038186803b158015612a1257600080fd5b505af4158015612a26573d6000803e3d6000fd5b505050506040513d6000823e3d601f19601f82011682018060405250810190612a4f91906140ec565b601860008481526020019081526020016000209080519060200190612a75929190613b57565b506000821115612aab57601060030160008154809291906001900391905055506010600201600081548092919060010191905055505b612ab3612da6565b505050565b612ac38484846125e7565b612acf84848484613344565b612b24576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603281526020018061527e6032913960400191505060405180910390fd5b50505050565b600080828401905083811015612ba8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415612c55576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f4552433732313a206d696e7420746f20746865207a65726f206164647265737381525060200191505060405180910390fd5b612c5e81612400565b15612cd1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601c8152602001807f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000081525060200191505060405180910390fd5b612cdd600083836130b3565b612d2e81600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206130d290919063ffffffff16565b50612d45818360026130ec9092919063ffffffff16565b50808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600b600101546010600101541015612dcc57600b60010154601060040181905550612f26565b60007388a9eabc4cbb315b92c19521ef47fb987edd630b63eaa041fe600b60020154600a6040518363ffffffff1660e01b8152600401612e0d929190614e00565b60206040518083038186803b158015612e2557600080fd5b505af4158015612e39573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e5d9190614197565b90507388a9eabc4cbb315b92c19521ef47fb987edd630b63058afb766010600301546000846040518463ffffffff1660e01b8152600401612ea093929190614dc9565b60206040518083038186803b158015612eb857600080fd5b505af4158015612ecc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ef09190614197565b816010600101540103601060040181905550600b600201546010600401541115612f2457600b600201546010600401819055505b505b601060010154601060040154036010600501819055507388a9eabc4cbb315b92c19521ef47fb987edd630b6352fec20d6010600501547388a9eabc4cbb315b92c19521ef47fb987edd630b63eaa041fe600b6002015460056040518363ffffffff1660e01b8152600401612f9b929190614e52565b60206040518083038186803b158015612fb357600080fd5b505af4158015612fc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612feb9190614197565b6040518363ffffffff1660e01b8152600401613008929190614e7b565b60206040518083038186803b15801561302057600080fd5b505af4158015613034573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130589190614197565b601060060181905550600060106005015411601060070160006101000a81548160ff021916908315150217905550565b600061309a836000018360001b61355d565b905092915050565b600081600001805490509050919050565b505050565b60006130ca836000018360001b613580565b905092915050565b60006130e4836000018360001b613668565b905092915050565b6000613118846000018460001b8473ffffffffffffffffffffffffffffffffffffffff1660001b6136d8565b90509392505050565b600081836000018054905011613182576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061525c6022913960400191505060405180910390fd5b82600001828154811061319157fe5b9060005260206000200154905092915050565b60008082846000018054905011613206576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806153d76022913960400191505060405180910390fd5b600084600001848154811061321757fe5b906000526020600020906002020190508060000154816001015492509250509250929050565b60008084600101600085815260200190815260200160002054905060008114158390613304576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b838110156132c95780820151818401526020810190506132ae565b50505050905090810190601f1680156132f65780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5084600001600182038154811061331757fe5b9060005260206000209060020201600101549150509392505050565b600081600001805490509050919050565b60006133658473ffffffffffffffffffffffffffffffffffffffff166137b4565b6133725760019050613555565b60006134dc63150b7a0260e01b61338761241d565b888787604051602401808573ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561340b5780820151818401526020810190506133f0565b50505050905090810190601f1680156134385780820380516001836020036101000a031916815260200191505b5095505050505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405180606001604052806032815260200161527e603291398773ffffffffffffffffffffffffffffffffffffffff166137c79092919063ffffffff16565b905060008180602001905160208110156134f557600080fd5b8101908080519060200190929190505050905063150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b6000808360010160008481526020019081526020016000205490506000811461365c57600060018203905060006001866000018054905003905060008660000182815481106135cb57fe5b90600052602060002001549050808760000184815481106135e857fe5b906000526020600020018190555060018301876001016000838152602001908152602001600020819055508660000180548061362057fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050613662565b60009150505b92915050565b600061367483836137df565b6136cd5782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506136d2565b600090505b92915050565b600080846001016000858152602001908152602001600020549050600081141561377f578460000160405180604001604052808681526020018581525090806001815401808255809150506001900390600052602060002090600202016000909190919091506000820151816000015560208201518160010155505084600001805490508560010160008681526020019081526020016000208190555060019150506137ad565b8285600001600183038154811061379257fe5b90600052602060002090600202016001018190555060009150505b9392505050565b600080823b905060008111915050919050565b60606137d68484600085613802565b90509392505050565b600080836001016000848152602001908152602001600020541415905092915050565b60608247101561385d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806152fa6026913960400191505060405180910390fd5b613866856137b4565b6138d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601d8152602001807f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000081525060200191505060405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106139275780518252602082019150602081019050602083039250613904565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613989576040519150601f19603f3d011682016040523d82523d6000602084013e61398e565b606091505b509150915061399e8282866139aa565b92505050949350505050565b606083156139ba57829050613a6f565b6000835111156139cd5782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015613a34578082015181840152602081019050613a19565b50505050905090810190601f168015613a615780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b9392505050565b6040518061010001604052806000151581526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b6040518060c00160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600015158152602001600015158152602001600073ffffffffffffffffffffffffffffffffffffffff16815260200160008152602001606081525090565b6040518060a0016040528060608152602001600081526020016000815260200160008152602001600060ff1681525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282613b8d5760008555613bd4565b82601f10613ba657805160ff1916838001178555613bd4565b82800160010185558215613bd4579182015b82811115613bd3578251825591602001919060010190613bb8565b5b509050613be19190613be5565b5090565b5b80821115613bfe576000816000905550600101613be6565b5090565b6000613c15613c1084614f05565b614ed4565b90508083825260208201905082856020860282011115613c3457600080fd5b60005b85811015613c645781613c4a8882613e4e565b845260208401935060208301925050600181019050613c37565b5050509392505050565b6000613c81613c7c84614f31565b614ed4565b905082815260208101848484011115613c9957600080fd5b613ca484828561517c565b509392505050565b6000613cbf613cba84614f31565b614ed4565b905082815260208101848484011115613cd757600080fd5b613ce284828561518b565b509392505050565b6000613cfd613cf884614f61565b614ed4565b905082815260208101848484011115613d1557600080fd5b613d2084828561518b565b509392505050565b600081359050613d37816151d1565b92915050565b600082601f830112613d4e57600080fd5b8151613d5e848260208601613c02565b91505092915050565b600081359050613d76816151e8565b92915050565b600081519050613d8b816151ff565b92915050565b600081359050613da081615216565b92915050565b600082601f830112613db757600080fd5b8135613dc7848260208601613c6e565b91505092915050565b600082601f830112613de157600080fd5b8151613df1848260208601613cac565b91505092915050565b600082601f830112613e0b57600080fd5b8151613e1b848260208601613cea565b91505092915050565b600081359050613e338161522d565b92915050565b600081519050613e488161522d565b92915050565b600081519050613e5d81615244565b92915050565b600060208284031215613e7557600080fd5b6000613e8384828501613d28565b91505092915050565b60008060408385031215613e9f57600080fd5b6000613ead85828601613d28565b9250506020613ebe85828601613d28565b9150509250929050565b600080600060608486031215613edd57600080fd5b6000613eeb86828701613d28565b9350506020613efc86828701613d28565b9250506040613f0d86828701613e24565b9150509250925092565b60008060008060808587031215613f2d57600080fd5b6000613f3b87828801613d28565b9450506020613f4c87828801613d28565b9350506040613f5d87828801613e24565b925050606085013567ffffffffffffffff811115613f7a57600080fd5b613f8687828801613da6565b91505092959194509250565b60008060408385031215613fa557600080fd5b6000613fb385828601613d28565b9250506020613fc485828601613d67565b9150509250929050565b60008060408385031215613fe157600080fd5b6000613fef85828601613d28565b925050602061400085828601613e24565b9150509250929050565b60008060006060848603121561401f57600080fd5b600061402d86828701613d28565b935050602061403e86828701613e24565b925050604061404f86828701613d67565b9150509250925092565b60006020828403121561406b57600080fd5b600082015167ffffffffffffffff81111561408557600080fd5b61409184828501613d3d565b91505092915050565b6000602082840312156140ac57600080fd5b60006140ba84828501613d7c565b91505092915050565b6000602082840312156140d557600080fd5b60006140e384828501613d91565b91505092915050565b6000602082840312156140fe57600080fd5b600082015167ffffffffffffffff81111561411857600080fd5b61412484828501613dd0565b91505092915050565b60006020828403121561413f57600080fd5b600082015167ffffffffffffffff81111561415957600080fd5b61416584828501613dfa565b91505092915050565b60006020828403121561418057600080fd5b600061418e84828501613e24565b91505092915050565b6000602082840312156141a957600080fd5b60006141b784828501613e39565b91505092915050565b60006141cc8383614a58565b60208301905092915050565b60006141e48383614aa3565b60208301905092915050565b6141f981615087565b82525050565b61420881615087565b82525050565b600061421982614fdb565b6142238185615016565b935061422e83614f91565b8060005b8381101561425f57815161424688826141c0565b975061425183614ffc565b925050600181019050614232565b5085935050505092915050565b600061427782614fdb565b6142818185615027565b935061428c83614f91565b8060005b838110156142bd5781516142a488826141c0565b97506142af83614ffc565b925050600181019050614290565b5085935050505092915050565b60006142d582614fe6565b6142df8185615038565b93506142ea83614fa1565b8060005b8381101561431b57815161430288826141d8565b975061430d83615009565b9250506001810190506142ee565b5085935050505092915050565b61433181615099565b82525050565b61434081615099565b82525050565b61434f816150a5565b82525050565b6000815460018116600081146143725760018114614398576143dc565b607f60028304166143838187615049565b955060ff1983168652602086019350506143dc565b600282046143a68187615049565b95506143b185614fb1565b60005b828110156143d3578154818901526001820191506020810190506143b4565b80880195505050505b505092915050565b6143ed81615134565b82525050565b6143fc81615146565b82525050565b61440b81615158565b82525050565b61441a8161516a565b82525050565b600061442b82614ff1565b614435818561505a565b935061444581856020860161518b565b61444e816151c0565b840191505092915050565b600061446482614ff1565b61446e818561506b565b935061447e81856020860161518b565b614487816151c0565b840191505092915050565b600061449d82614ff1565b6144a7818561507c565b93506144b781856020860161518b565b80840191505092915050565b6000815460018116600081146144e0576001811461450557614549565b607f60028304166144f1818761507c565b955060ff1983168652808601935050614549565b60028204614513818761507c565b955061451e85614fc6565b60005b8281101561454057815481890152600182019150602081019050614521565b82880195505050505b505092915050565b600061455e60238361507c565b91507f68747470733a2f2f636f6c6c6563742d636f64652e636f6d2f6170692f746f6b60008301527f656e2f00000000000000000000000000000000000000000000000000000000006020830152602382019050919050565b60006145c4600e8361506b565b91507f43433a4261645175616e746974790000000000000000000000000000000000006000830152602082019050919050565b6000614604600e8361506b565b91507f43433a20556e72656c65617365640000000000000000000000000000000000006000830152602082019050919050565b6000614644600b8361506b565b91507f43433a42616456616c75650000000000000000000000000000000000000000006000830152602082019050919050565b600061468460108361506b565b91507f43433a416c7265616479497373756564000000000000000000000000000000006000830152602082019050919050565b60006146c4600a8361506b565b91507f43433a546f6f4d616e79000000000000000000000000000000000000000000006000830152602082019050919050565b6000614704600d8361506b565b91507f43433a426164546f6b656e4964000000000000000000000000000000000000006000830152602082019050919050565b6000614744600b8361506b565b91507f43433a4e6f744f776e65720000000000000000000000000000000000000000006000830152602082019050919050565b6000614784600e8361506b565b91507f43433a556e617661696c61626c650000000000000000000000000000000000006000830152602082019050919050565b60006147c460158361507c565b91507f2f6d657461646174613f763d3126706978656c733d00000000000000000000006000830152601582019050919050565b6000614804600a8361506b565b91507f43433a536f6c644f7574000000000000000000000000000000000000000000006000830152602082019050919050565b6000614844600f8361506b565b91507f43433a416c72656164794275696c7400000000000000000000000000000000006000830152602082019050919050565b600061488460018361507c565b91507f2f000000000000000000000000000000000000000000000000000000000000006000830152600182019050919050565b600060a08301600083015184820360008601526148d48282614420565b91505060208301516148e96020860182614a58565b5060408301516148fc6040860182614a58565b50606083015161490f6060860182614a58565b5060808301516149226080860182614a85565b508091505092915050565b610100820160008201516149446000850182614328565b5060208201516149576020850182614a58565b50604082015161496a6040850182614a58565b50606082015161497d6060850182614a58565b5060808201516149906080850182614a58565b5060a08201516149a360a0850182614a58565b5060c08201516149b660c0850182614a58565b5060e08201516149c960e0850182614328565b50505050565b600060c0830160008301516149e760008601826141f0565b5060208301516149fa6020860182614328565b506040830151614a0d6040860182614328565b506060830151614a2060608601826141f0565b506080830151614a336080860182614a58565b5060a083015184820360a0860152614a4b828261420e565b9150508091505092915050565b614a618161511d565b82525050565b614a708161511d565b82525050565b614a7f8161511d565b82525050565b614a8e81615127565b82525050565b614a9d81615127565b82525050565b614aac81615127565b82525050565b6000614abd82614551565b9150614ac982866144c3565b9150614ad482614877565b9150614ae08285614492565b9150614aeb826147b7565b9150614af78284614492565b9150819050949350505050565b6000602082019050614b1960008301846141ff565b92915050565b60006020820190508181036000830152614b39818461426c565b905092915050565b60006020820190508181036000830152614b5b81846142ca565b905092915050565b6000602082019050614b786000830184614337565b92915050565b600060a082019050614b936000830188614346565b614ba06020830187614346565b614bad6040830186614346565b614bba6060830185614a94565b614bc76080830184614a76565b9695505050505050565b60006020820190508181036000830152614beb8184614459565b905092915050565b60006020820190508181036000830152614c0c816145b7565b9050919050565b60006020820190508181036000830152614c2c816145f7565b9050919050565b60006020820190508181036000830152614c4c81614637565b9050919050565b60006020820190508181036000830152614c6c81614677565b9050919050565b60006020820190508181036000830152614c8c816146b7565b9050919050565b60006020820190508181036000830152614cac816146f7565b9050919050565b60006020820190508181036000830152614ccc81614737565b9050919050565b60006020820190508181036000830152614cec81614777565b9050919050565b60006020820190508181036000830152614d0c816147f7565b9050919050565b60006020820190508181036000830152614d2c81614837565b9050919050565b60006020820190508181036000830152614d4d81846148b7565b905092915050565b600061010082019050614d6b600083018461492d565b92915050565b60006020820190508181036000830152614d8b81846149cf565b905092915050565b6000602082019050614da86000830184614a76565b92915050565b6000602082019050614dc36000830184614a67565b92915050565b6000606082019050614dde6000830186614a76565b614deb60208301856143e4565b614df86040830184614a76565b949350505050565b6000604082019050614e156000830185614a76565b614e2260208301846143f3565b9392505050565b6000604082019050614e3e6000830185614a76565b614e4b6020830184614402565b9392505050565b6000604082019050614e676000830185614a76565b614e746020830184614411565b9392505050565b6000604082019050614e906000830185614a76565b614e9d6020830184614a76565b9392505050565b6000604082019050614eb96000830185614a94565b8181036020830152614ecb8184614355565b90509392505050565b6000604051905081810181811067ffffffffffffffff82111715614efb57614efa6151be565b5b8060405250919050565b600067ffffffffffffffff821115614f2057614f1f6151be565b5b602082029050602081019050919050565b600067ffffffffffffffff821115614f4c57614f4b6151be565b5b601f19601f8301169050602081019050919050565b600067ffffffffffffffff821115614f7c57614f7b6151be565b5b601f19601f8301169050602081019050919050565b6000819050602082019050919050565b6000819050602082019050919050565b60008190508160005260206000209050919050565b60008190508160005260206000209050919050565b600081519050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b6000615092826150fd565b9050919050565b60008115159050919050565b60007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600060ff82169050919050565b600061513f8261511d565b9050919050565b60006151518261511d565b9050919050565b60006151638261511d565b9050919050565b60006151758261511d565b9050919050565b82818337600083830152505050565b60005b838110156151a957808201518184015260208101905061518e565b838111156151b8576000848401525b50505050565bfe5b6000601f19601f8301169050919050565b6151da81615087565b81146151e557600080fd5b50565b6151f181615099565b81146151fc57600080fd5b50565b615208816150a5565b811461521357600080fd5b50565b61521f816150d1565b811461522a57600080fd5b50565b6152368161511d565b811461524157600080fd5b50565b61524d81615127565b811461525857600080fd5b5056fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e64734552433732313a207472616e7366657220746f206e6f6e20455243373231526563656976657220696d706c656d656e7465724f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573734552433732313a207472616e7366657220746f20746865207a65726f2061646472657373416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c4552433732313a206f70657261746f7220717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a20617070726f76652063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f76656420666f7220616c6c4552433732313a2062616c616e636520717565727920666f7220746865207a65726f20616464726573734552433732313a206f776e657220717565727920666f72206e6f6e6578697374656e7420746f6b656e456e756d657261626c654d61703a20696e646578206f7574206f6620626f756e64734552433732313a20617070726f76656420717565727920666f72206e6f6e6578697374656e7420746f6b656e4552433732313a207472616e73666572206f6620746f6b656e2074686174206973206e6f74206f776e4552433732313a20617070726f76616c20746f2063757272656e74206f776e65724552433732313a207472616e736665722063616c6c6572206973206e6f74206f776e6572206e6f7220617070726f766564a2646970667358221220612dd5f0e528ad818ba56cdaf95d3aa68cd4c4e77293f2a6bc9b91177706d20f64736f6c63430007060033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.