ETH Price: $2,903.50 (+2.89%)
 

Overview

Max Total Supply

591 TB3

Holders

293

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Balance
1 TB3
0x3972c906cdd1ab81e536f74823ca226aa4ee0c11
Loading...
Loading
Loading...
Loading
Loading...
Loading

OVERVIEW

Breed or Adopt two Generation 2 Bears at the dedicated Cloud Server to claim a Generation 3 Bear. This is the third generation of four, each created from its parent's DNA, and becoming exponentially more hyper-realistic.

# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
TwoBitBears3

Compiler Version
v0.8.11+commit.d7f03943

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
File 1 of 31 : TwoBitBears3.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "@theappstudio/solidity/contracts/utils/OnChain.sol";
import "@theappstudio/solidity/contracts/utils/Randomization.sol";
import "../interfaces/IBear3TraitProvider.sol";
import "../interfaces/ICubTraitProvider.sol";
import "../utils/BearRenderTech.sol";
import "../utils/TwoBitBears3Errors.sol";
import "./TwoBitCubs.sol";

/// @title TwoBitBears3
contract TwoBitBears3 is ERC721, IBear3TraitProvider, IERC721Enumerable, Ownable {

    /// @dev Reference to the BearRenderTech contract
    IBearRenderTech private immutable _bearRenderTech;

    /// @dev Stores the cubs Adult Age so that it doesn't need to be queried for every mint
    uint256 private immutable _cubAdultAge;

    /// @dev Precalculated eligibility for cubs
    uint256[] private _cubEligibility;

    /// @dev Stores bear token ids that have already minted gen 4
    mapping(uint256 => bool) private _generation4Claims;

    /// @dev The contract for Gen 4
    address private _gen4Contract;

    /// @dev Stores cub token ids that have already mated
    mapping(uint256 => bool) private _matedCubs;

    /// @dev Seed for randomness
    uint256 private _seed;

    /// @dev Array of TokenIds to DNA
    uint256[] private _tokenIdsToDNA;

    /// @dev Reference to the TwoBitCubs contract
    TwoBitCubs private immutable _twoBitCubs;

    /// Look...at these...Bears
    constructor(uint256 seed, address renderTech, address twoBitCubs) ERC721("TwoBitBears3", "TB3") {
        _seed = seed;
        _bearRenderTech = IBearRenderTech(renderTech);
        _twoBitCubs = TwoBitCubs(twoBitCubs);
        _cubAdultAge = _twoBitCubs.ADULT_AGE();
    }

    /// Applies calculated slots of gen 2 eligibility to reduce gas
    function applySlots(uint256[] calldata slotIndices, uint256[] calldata slotValues) external onlyOwner {
        for (uint i = 0; i < slotIndices.length; i++) {
            uint slotIndex = slotIndices[i];
            uint slotValue = slotValues[i];
            if (slotIndex >= _cubEligibility.length) {
                while (slotIndex > _cubEligibility.length) {
                    _cubEligibility.push(0);
                }
                _cubEligibility.push(slotValue);
            } else if (_cubEligibility[slotIndex] != slotValue) {
                _cubEligibility[slotIndex] = slotValue;
            }
        }
    }

    /// Assigns the Gen 4 contract address for message caller verification
    function assignGen4(address gen4Contract) external onlyOwner {
        if (gen4Contract == address(0)) revert InvalidAddress();
        _gen4Contract = gen4Contract;
    }

    /// @inheritdoc IBear3TraitProvider
    function bearTraits(uint256 tokenId) external view onlyWhenExists(tokenId) returns (IBear3Traits.Traits memory) {
        return _traitsForToken(tokenId);
    }

    /// Calculates the current values for a slot
    function calculateSlot(uint256 slotIndex, uint256 totalTokens) external view onlyOwner returns (uint256 slotValue) {
        uint tokenStart = slotIndex * 32;
        uint tokenId = tokenStart + 32;
        if (tokenId > totalTokens) {
            tokenId = totalTokens;
        }
        uint adults = 0;
        do {
            tokenId -= 1;
            slotValue = (slotValue << 8) | _getEligibility(tokenId);
            if (slotValue >= 0x80) {
                adults++;
            }
        } while (tokenId > tokenStart);
        if (adults == 0 || (slotIndex < _cubEligibility.length && slotValue == _cubEligibility[slotIndex])) {
            slotValue = 0; // Reset because there's nothing worth writing
        }
    }

    /// Marks the Gen 3 Bear as having minted a Gen 4 Bear
    function claimGen4(uint256 tokenId) external onlyWhenExists(tokenId) {
        if (_gen4Contract == address(0) || _msgSender() != _gen4Contract) revert InvalidCaller();
        _generation4Claims[tokenId] = true;
    }

    /// @notice For easy import into MetaMask
    function decimals() external pure returns (uint256) {
        return 0;
    }

    /// @inheritdoc IBear3TraitProvider
    function hasGen2Mated(uint256 tokenId) external view returns (bool) {
        return _matedCubs[tokenId];
    }

    /// @inheritdoc IBear3TraitProvider
    function generation4Claimed(uint256 tokenId) external view onlyWhenExists(tokenId) returns (bool) {
        return _generation4Claims[tokenId];
    }

    function slotParameters() external view onlyOwner returns (uint256 totalSlots, uint256 totalTokens) {
        totalTokens = _twoBitCubs.totalSupply();
        totalSlots = 1 + totalTokens / 32;
    }

    /// Exposes the raw image SVG to the world, for any applications that can take advantage
    function imageSVG(uint256 tokenId) external view returns (string memory) {
        return string(_imageBytes(tokenId));
    }

    /// Exposes the image URI to the world, for any applications that can take advantage
    function imageURI(uint256 tokenId) external view returns (string memory) {
        return string(OnChain.svgImageURI(_imageBytes(tokenId)));
    }

    /// Mints the provided quantity of TwoBitBear3 tokens
    /// @param parentOne The first gen 2 bear parent, which also determines the mood
    /// @param parentTwo The second gen 2 bear parent
    function mateBears(uint256 parentOne, uint256 parentTwo) external {
        // Check eligibility
        if (_matedCubs[parentOne]) revert ParentAlreadyMated(parentOne);
        if (_matedCubs[parentTwo]) revert ParentAlreadyMated(parentTwo);
        if (_twoBitCubs.ownerOf(parentOne) != _msgSender()) revert ParentNotOwned(parentOne);
        if (_twoBitCubs.ownerOf(parentTwo) != _msgSender()) revert ParentNotOwned(parentTwo);
        uint parentOneInfo = _getEligibility(parentOne);
        uint parentTwoInfo = _getEligibility(parentTwo);
        uint parentOneSpecies = parentOneInfo & 0x03;
        if (parentOne == parentTwo || parentOneSpecies != (parentTwoInfo & 0x03)) revert InvalidParentCombination();
        if (parentOneInfo < 0x80) revert ParentTooYoung(parentOne);
        if (parentTwoInfo < 0x80) revert ParentTooYoung(parentTwo);
        // Prepare mint
        _matedCubs[parentOne] = true;
        _matedCubs[parentTwo] = true;
        uint seed = Randomization.randomSeed(_seed);
        // seed (208) | parent one (16) | parent two (16) | species (8) | mood (8)
        uint rawDna = (seed << 48) | (parentOne << 32) | (parentTwo << 16) | (parentOneSpecies << 8) | ((parentOneInfo & 0x7F) >> 2);
        uint tokenId = _tokenIdsToDNA.length;
        _tokenIdsToDNA.push(rawDna);
        _seed = seed;
        _safeMint(_msgSender(), tokenId, ""); // Reentrancy is possible here
    }

    /// @notice Returns expected gas usage based on selected parents, with a small buffer for safety
    /// @dev Does not check for ownership or whether parents have already mated
    function matingGas(address minter, uint256 parentOne, uint256 parentTwo) external view returns (uint256 result) {
        result = 146000; // Lowest gas cost to mint
        if (_tokenIdsToDNA.length == 0) {
            result += 16500;
        }
        if (balanceOf(minter) == 0) {
            result += 17500;
        }
        // Fetching eligibility of parents will cost additional gas
        uint fetchCount = 0;
        if (_eligibility(parentOne) < 0x80) {
            result += 47000;
            if (uint(_twoBitCubs.traitsV1(parentOne).mood) >= 4) {
                result += 33500;
            }
            fetchCount += 1;
        }
        if (_eligibility(parentTwo) < 0x80) {
            result += 47000;
            if (uint(_twoBitCubs.traitsV1(parentTwo).mood) >= 4) {
                result += 33500;
            }
            fetchCount += 1;
        }
        // There's some overhead for a single fetch
        if (fetchCount == 1) {
            result += 10000;
        }
    }

    /// Prevents a function from executing if the tokenId does not exist
    modifier onlyWhenExists(uint256 tokenId) {
        if (!_exists(tokenId)) revert InvalidTokenId();
        _;
    }

    /// @inheritdoc IBear3TraitProvider
    function scarColors(uint256 tokenId) external view onlyWhenExists(tokenId) returns (IBear3Traits.ScarColor[] memory) {
        IBear3Traits.Traits memory traits = _traitsForToken(tokenId);
        return _bearRenderTech.scarsForTraits(traits);
    }

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

    /// @inheritdoc IERC721Enumerable
    function tokenByIndex(uint256 index) external view returns (uint256) {
        require(index < this.totalSupply(), "global index out of bounds");
        return index; // Burning is not exposed by this contract so we can simply return the index
    }

    /// @inheritdoc IERC721Enumerable
    /// @dev This implementation is for the benefit of web3 sites -- it is extremely expensive for contracts to call on-chain
    function tokenOfOwnerByIndex(address owner_, uint256 index) external view returns (uint256 tokenId) {
        require(index < ERC721.balanceOf(owner_), "owner index out of bounds");
        for (uint tokenIndex = 0; tokenIndex < _tokenIdsToDNA.length; tokenIndex++) {
            // Use _exists() to avoid a possible revert when accessing OpenZeppelin's ownerOf(), despite not exposing _burn()
            if (_exists(tokenIndex) && ownerOf(tokenIndex) == owner_) {
                if (index == 0) {
                    tokenId = tokenIndex;
                    break;
                }
                index--;
            }
        }
    }

    /// @inheritdoc IERC721Metadata
    function tokenURI(uint256 tokenId) public view override onlyWhenExists(tokenId) returns (string memory) {
        IBear3Traits.Traits memory traits = _traitsForToken(tokenId);
        return string(OnChain.tokenURI(_bearRenderTech.metadata(traits, tokenId)));
    }

    /// @inheritdoc IERC721Enumerable
    function totalSupply() external view returns (uint256) {
        return _tokenIdsToDNA.length; // We don't expose _burn() so the .length suffices
    }

    function _eligibility(uint256 parent) private view returns (uint8 result) {
        uint slotIndex = parent / 32;
        if (slotIndex < _cubEligibility.length) {
            result = uint8(_cubEligibility[slotIndex] >> ((parent % 32) * 8));
        }
    }

    function _getEligibility(uint256 parent) private view returns (uint8 result) {
        // Check the precalculated eligibility
        result = _eligibility(parent);
        if (result < 0x80) {
            // We need to go get the latest information from the Cubs contract
            result = _packedInfo(_twoBitCubs.traitsV1(parent));
        }
    }

    function _imageBytes(uint256 tokenId) private view onlyWhenExists(tokenId) returns (bytes memory) {
        IBear3Traits.Traits memory traits = _traitsForToken(tokenId);
        return _bearRenderTech.createSvg(traits, tokenId);
    }

    function _traitsForToken(uint256 tokenId) private view returns (IBear3Traits.Traits memory traits) {
        uint dna = _tokenIdsToDNA[tokenId];
        traits.mood = IBear3Traits.MoodType(dna & 0xFF);
        traits.species = IBear3Traits.SpeciesType((dna >> 8) & 0xFF);
        traits.firstParentTokenId = uint16(dna >> 16) & 0xFFFF;
        traits.secondParentTokenId = uint16(dna >> 32) & 0xFFFF;
        traits.nameIndex = uint8((dna >> 48) & 0xFF);
        traits.familyIndex = uint8((dna >> 56) & 0xFF);
        traits.background = IBear3Traits.BackgroundType(((dna >> 64) & 0xFF) % 3);
        traits.gen4Claimed = _generation4Claims[tokenId];
        traits.genes = uint176(dna >> 80);
    }

    function _packedInfo(ICubTraits.TraitsV1 memory traits) private view returns (uint8 info) {
        info |= uint8(traits.species);
        info |= uint8(traits.mood) << 2;
        if (traits.age >= _cubAdultAge) {
            info |= 0x80;
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _beforeTokenTransfer(from, to, tokenId);

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

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

        emit Transfer(from, to, tokenId);
    }

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 5 of 31 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

File 13 of 31 : ISVGTypes.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title ISVG image library types interface
/// @dev Allows Solidity files to reference the library's input and return types without referencing the library itself
interface ISVGTypes {

    /// Represents a color in RGB format with alpha
    struct Color {
        uint8 red;
        uint8 green;
        uint8 blue;
        uint8 alpha;
    }

    /// Represents a color attribute in an SVG image file
    enum ColorAttribute {
        Fill, Stroke, Stop
    }

    /// Represents the kind of color attribute in an SVG image file
    enum ColorAttributeKind {
        RGB, URL
    }
}

File 14 of 31 : DecimalStrings.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @dev String operations with decimals
library DecimalStrings {

    /// @dev Converts a `uint256` to its ASCII `string` representation with decimal places.
    function toDecimalString(uint256 value, uint256 decimals, bool isNegative) internal pure returns (bytes memory) {
        // Inspired by OpenZeppelin's implementation - MIT licence
        // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Strings.sol

        uint256 temp = value;
        uint256 characters;
        do {
            characters++;
            temp /= 10;
        } while (temp != 0);
        if (characters <= decimals) {
            characters += 2 + (decimals - characters);
        } else if (decimals > 0) {
            characters += 1;
        }
        temp = isNegative ? 1 : 0; // reuse 'temp' as a sign symbol offset
        characters += temp;
        bytes memory buffer = new bytes(characters);
        while (characters > temp) {
            characters -= 1;
            if (decimals > 0 && (buffer.length - characters - 1) == decimals) {
                buffer[characters] = bytes1(uint8(46));
                decimals = 0; // Cut off any further checks for the decimal place
            } else if (value != 0) {
                buffer[characters] = bytes1(uint8(48 + uint256(value % 10)));
                value /= 10;
            } else {
                buffer[characters] = bytes1(uint8(48));
            }
        }
        if (isNegative) {
            buffer[0] = bytes1(uint8(45));
        }
        return buffer;
    }
}

File 15 of 31 : OnChain.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "base64-sol/base64.sol";

/// @title OnChain metadata support library
/**
 * @dev These methods are best suited towards view/pure only function calls (ALL the way through the call stack).
 * Do not waste gas using these methods in functions that also update state, unless your need requires it.
 */
library OnChain {

    /// Returns the prefix needed for a base64-encoded on chain svg image
    function baseSvgImageURI() internal pure returns (bytes memory) {
        return "data:image/svg+xml;base64,";
    }

    /// Returns the prefix needed for a base64-encoded on chain nft metadata
    function baseURI() internal pure returns (bytes memory) {
        return "data:application/json;base64,";
    }

    /// Returns the contents joined with a comma between them
    /// @param contents1 The first content to join
    /// @param contents2 The second content to join
    /// @return A collection of bytes that represent all contents joined with a comma
    function commaSeparated(bytes memory contents1, bytes memory contents2) internal pure returns (bytes memory) {
        return abi.encodePacked(contents1, continuesWith(contents2));
    }

    /// Returns the contents joined with commas between them
    /// @param contents1 The first content to join
    /// @param contents2 The second content to join
    /// @param contents3 The third content to join
    /// @return A collection of bytes that represent all contents joined with commas
    function commaSeparated(bytes memory contents1, bytes memory contents2, bytes memory contents3) internal pure returns (bytes memory) {
        return abi.encodePacked(commaSeparated(contents1, contents2), continuesWith(contents3));
    }

    /// Returns the contents joined with commas between them
    /// @param contents1 The first content to join
    /// @param contents2 The second content to join
    /// @param contents3 The third content to join
    /// @param contents4 The fourth content to join
    /// @return A collection of bytes that represent all contents joined with commas
    function commaSeparated(bytes memory contents1, bytes memory contents2, bytes memory contents3, bytes memory contents4) internal pure returns (bytes memory) {
        return abi.encodePacked(commaSeparated(contents1, contents2, contents3), continuesWith(contents4));
    }

    /// Returns the contents joined with commas between them
    /// @param contents1 The first content to join
    /// @param contents2 The second content to join
    /// @param contents3 The third content to join
    /// @param contents4 The fourth content to join
    /// @param contents5 The fifth content to join
    /// @return A collection of bytes that represent all contents joined with commas
    function commaSeparated(bytes memory contents1, bytes memory contents2, bytes memory contents3, bytes memory contents4, bytes memory contents5) internal pure returns (bytes memory) {
        return abi.encodePacked(commaSeparated(contents1, contents2, contents3, contents4), continuesWith(contents5));
    }

    /// Returns the contents joined with commas between them
    /// @param contents1 The first content to join
    /// @param contents2 The second content to join
    /// @param contents3 The third content to join
    /// @param contents4 The fourth content to join
    /// @param contents5 The fifth content to join
    /// @param contents6 The sixth content to join
    /// @return A collection of bytes that represent all contents joined with commas
    function commaSeparated(bytes memory contents1, bytes memory contents2, bytes memory contents3, bytes memory contents4, bytes memory contents5, bytes memory contents6) internal pure returns (bytes memory) {
        return abi.encodePacked(commaSeparated(contents1, contents2, contents3, contents4, contents5), continuesWith(contents6));
    }

    /// Returns the contents prefixed by a comma
    /// @dev This is used to append multiple attributes into the json
    /// @param contents The contents with which to prefix
    /// @return A bytes collection of the contents prefixed with a comma
    function continuesWith(bytes memory contents) internal pure returns (bytes memory) {
        return abi.encodePacked(",", contents);
    }

    /// Returns the contents wrapped in a json dictionary
    /// @param contents The contents with which to wrap
    /// @return A bytes collection of the contents wrapped as a json dictionary
    function dictionary(bytes memory contents) internal pure returns (bytes memory) {
        return abi.encodePacked("{", contents, "}");
    }

    /// Returns an unwrapped key/value pair where the value is an array
    /// @param key The name of the key used in the pair
    /// @param value The value of pair, as an array
    /// @return A bytes collection that is suitable for inclusion in a larger dictionary
    function keyValueArray(string memory key, bytes memory value) internal pure returns (bytes memory) {
        return abi.encodePacked("\"", key, "\":[", value, "]");
    }

    /// Returns an unwrapped key/value pair where the value is a string
    /// @param key The name of the key used in the pair
    /// @param value The value of pair, as a string
    /// @return A bytes collection that is suitable for inclusion in a larger dictionary
    function keyValueString(string memory key, bytes memory value) internal pure returns (bytes memory) {
        return abi.encodePacked("\"", key, "\":\"", value, "\"");
    }

    /// Encodes an SVG as base64 and prefixes it with a URI scheme suitable for on-chain data
    /// @param svg The contents of the svg
    /// @return A bytes collection that may be added to the "image" key/value pair in ERC-721 or ERC-1155 metadata
    function svgImageURI(bytes memory svg) internal pure returns (bytes memory) {
        return abi.encodePacked(baseSvgImageURI(), Base64.encode(svg));
    }

    /// Encodes json as base64 and prefixes it with a URI scheme suitable for on-chain data
    /// @param metadata The contents of the metadata
    /// @return A bytes collection that may be returned as the tokenURI in a ERC-721 or ERC-1155 contract
    function tokenURI(bytes memory metadata) internal pure returns (bytes memory) {
        return abi.encodePacked(baseURI(), Base64.encode(metadata));
    }

    /// Returns the json dictionary of a single trait attribute for an ERC-721 or ERC-1155 NFT
    /// @param name The name of the trait
    /// @param value The value of the trait
    /// @return A collection of bytes that can be embedded within a larger array of attributes
    function traitAttribute(string memory name, bytes memory value) internal pure returns (bytes memory) {
        return dictionary(commaSeparated(
            keyValueString("trait_type", bytes(name)),
            keyValueString("value", value)
        ));
    }
}

File 16 of 31 : Randomization.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "./RandomizationErrors.sol";

/// @title Randomization library
/// @dev Lightweight library used for basic randomization capabilities for ERC-721 tokens when an Oracle is not available
library Randomization {

    /// Returns a value based on the spread of a random uint8 seed and provided percentages
    /// @dev The last percentage is assumed if the sum of all elements do not add up to 100, in which case the length of the array is returned
    /// @param random A uint8 random value
    /// @param percentages An array of percentages
    /// @return The index in which the random seed falls, which can be the length of the input array if the values do not add up to 100
    function randomIndex(uint8 random, uint8[] memory percentages) internal pure returns (uint256) {
        uint256 spread = (3921 * uint256(random) / 10000) % 100; // 0-255 needs to be balanced to evenly spread with % 100
        uint256 remainingPercent = 100;
        for (uint256 i = 0; i < percentages.length; i++) {
            uint256 nextPercentage = percentages[i];
            if (remainingPercent < nextPercentage) revert PercentagesGreaterThan100();
            remainingPercent -= nextPercentage;
            if (spread >= remainingPercent) {
                return i;
            }
        }
        return percentages.length;
    }

    /// Returns a random seed suitable for ERC-721 attribute generation when an Oracle such as Chainlink VRF is not available to a contract
    /// @dev Not suitable for mission-critical code. Always be sure to perform an analysis of your randomization before deploying to production
    /// @param initialSeed A uint256 that seeds the randomization function
    /// @return A seed that can be used for attribute generation, which may also be used as the `initialSeed` for a future call
    function randomSeed(uint256 initialSeed) internal view returns (uint256) {
        // Unit tests should confirm that this provides a more-or-less even spread of randomness
        return uint256(keccak256(abi.encodePacked(blockhash(block.number - 1), msg.sender, initialSeed >> 1)));
    }
}

File 17 of 31 : RandomizationErrors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @dev When the percentages array sum up to more than 100
error PercentagesGreaterThan100();

File 18 of 31 : SVG.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/Strings.sol";
import "../interfaces/ISVGTypes.sol";
import "./OnChain.sol";
import "./SVGErrors.sol";

/// @title SVG image library
/**
 * @dev These methods are best suited towards view/pure only function calls (ALL the way through the call stack).
 * Do not waste gas using these methods in functions that also update state, unless your need requires it.
 */
library SVG {

    using Strings for uint256;

    /// Returns a named element based on the supplied attributes and contents
    /// @dev attributes and contents is usually generated from abi.encodePacked, attributes is expecting a leading space
    /// @param name The name of the element
    /// @param attributes The attributes of the element, as bytes, with a leading space
    /// @param contents The contents of the element, as bytes
    /// @return a bytes collection representing the whole element
    function createElement(string memory name, bytes memory attributes, bytes memory contents) internal pure returns (bytes memory) {
        return abi.encodePacked(
            "<", attributes.length == 0 ? bytes(name) : abi.encodePacked(name, attributes),
            contents.length == 0 ? bytes("/>") : abi.encodePacked(">", contents, "</", name, ">")
        );
    }

    /// Returns the root SVG attributes based on the supplied width and height
    /// @dev includes necessary leading space for createElement's `attributes` parameter
    /// @param width The width of the SVG view box
    /// @param height The height of the SVG view box
    /// @return a bytes collection representing the root SVG attributes, including a leading space
    function svgAttributes(uint256 width, uint256 height) internal pure returns (bytes memory) {
        return abi.encodePacked(" viewBox='0 0 ", width.toString(), " ", height.toString(), "' xmlns='http://www.w3.org/2000/svg'");
    }

    /// Returns an RGB bytes collection suitable as an attribute for SVG elements based on the supplied Color and ColorType
    /// @dev includes necessary leading space for all types _except_ None
    /// @param attribute The `ISVGTypes.ColorAttribute` of the desired attribute
    /// @param value The converted color value as bytes
    /// @return a bytes collection representing a color attribute in an SVG element
    function colorAttribute(ISVGTypes.ColorAttribute attribute, bytes memory value) internal pure returns (bytes memory) {
        if (attribute == ISVGTypes.ColorAttribute.Fill) return _attribute("fill", value);
        if (attribute == ISVGTypes.ColorAttribute.Stop) return _attribute("stop-color", value);
        return  _attribute("stroke", value); // Fallback to Stroke
    }

    /// Returns an RGB color attribute value
    /// @param color The `ISVGTypes.Color` of the color
    /// @return a bytes collection representing the url attribute value
    function colorAttributeRGBValue(ISVGTypes.Color memory color) internal pure returns (bytes memory) {
        return _colorValue(ISVGTypes.ColorAttributeKind.RGB, OnChain.commaSeparated(
            bytes(uint256(color.red).toString()),
            bytes(uint256(color.green).toString()),
            bytes(uint256(color.blue).toString())
        ));
    }

    /// Returns a URL color attribute value
    /// @param url The url to the color
    /// @return a bytes collection representing the url attribute value
    function colorAttributeURLValue(bytes memory url) internal pure returns (bytes memory) {
        return _colorValue(ISVGTypes.ColorAttributeKind.URL, url);
    }

    /// Returns an `ISVGTypes.Color` that is brightened by the provided percentage
    /// @param source The `ISVGTypes.Color` to brighten
    /// @param percentage The percentage of brightness to apply
    /// @param minimumBump A minimum increase for each channel to ensure dark Colors also brighten
    /// @return color the brightened `ISVGTypes.Color`
    function brightenColor(ISVGTypes.Color memory source, uint32 percentage, uint8 minimumBump) internal pure returns (ISVGTypes.Color memory color) {
        color.red = _brightenComponent(source.red, percentage, minimumBump);
        color.green = _brightenComponent(source.green, percentage, minimumBump);
        color.blue = _brightenComponent(source.blue, percentage, minimumBump);
        color.alpha = source.alpha;
    }

    /// Returns an `ISVGTypes.Color` based on a packed representation of r, g, and b
    /// @notice Useful for code where you want to utilize rgb hex values provided by a designer (e.g. #835525)
    /// @dev Alpha will be hard-coded to 100% opacity
    /// @param packedColor The `ISVGTypes.Color` to convert, e.g. 0x835525
    /// @return color representing the packed input
    function fromPackedColor(uint24 packedColor) internal pure returns (ISVGTypes.Color memory color) {
        color.red = uint8(packedColor >> 16);
        color.green = uint8(packedColor >> 8);
        color.blue = uint8(packedColor);
        color.alpha = 0xFF;
    }

    /// Returns a mixed Color by balancing the ratio of `color1` over `color2`, with a total percentage (for overmixing and undermixing outside the source bounds)
    /// @dev Reverts with `RatioInvalid()` if `ratioPercentage` is > 100
    /// @param color1 The first `ISVGTypes.Color` to mix
    /// @param color2 The second `ISVGTypes.Color` to mix
    /// @param ratioPercentage The percentage ratio of `color1` over `color2` (e.g. 60 = 60% first, 40% second)
    /// @param totalPercentage The total percentage after mixing (for overmixing and undermixing outside the input colors)
    /// @return color representing the result of the mixture
    function mixColors(ISVGTypes.Color memory color1, ISVGTypes.Color memory color2, uint32 ratioPercentage, uint32 totalPercentage) internal pure returns (ISVGTypes.Color memory color) {
        if (ratioPercentage > 100) revert RatioInvalid();
        color.red = _mixComponents(color1.red, color2.red, ratioPercentage, totalPercentage);
        color.green = _mixComponents(color1.green, color2.green, ratioPercentage, totalPercentage);
        color.blue = _mixComponents(color1.blue, color2.blue, ratioPercentage, totalPercentage);
        color.alpha = _mixComponents(color1.alpha, color2.alpha, ratioPercentage, totalPercentage);
    }

    /// Returns a proportionally-randomized Color between the start and stop colors using a random Color seed
    /// @dev Each component (r,g,b) will move proportionally together in the direction from start to stop
    /// @param start The starting bound of the `ISVGTypes.Color` to randomize
    /// @param stop The stopping bound of the `ISVGTypes.Color` to randomize
    /// @param random An `ISVGTypes.Color` to use as a seed for randomization
    /// @return color representing the result of the randomization
    function randomizeColors(ISVGTypes.Color memory start, ISVGTypes.Color memory stop, ISVGTypes.Color memory random) internal pure returns (ISVGTypes.Color memory color) {
        uint16 percent = uint16((1320 * (uint(random.red) + uint(random.green) + uint(random.blue)) / 10000) % 101); // Range is from 0-100
        color.red = _randomizeComponent(start.red, stop.red, random.red, percent);
        color.green = _randomizeComponent(start.green, stop.green, random.green, percent);
        color.blue = _randomizeComponent(start.blue, stop.blue, random.blue, percent);
        color.alpha = 0xFF;
    }

    function _attribute(bytes memory name, bytes memory contents) private pure returns (bytes memory) {
        return abi.encodePacked(" ", name, "='", contents, "'");
    }

    function _brightenComponent(uint8 component, uint32 percentage, uint8 minimumBump) private pure returns (uint8 result) {
        uint32 wideComponent = uint32(component);
        uint32 brightenedComponent = wideComponent * (percentage + 100) / 100;
        uint32 wideMinimumBump = uint32(minimumBump);
        if (brightenedComponent - wideComponent < wideMinimumBump) {
            brightenedComponent = wideComponent + wideMinimumBump;
        }
        if (brightenedComponent > 0xFF) {
            result = 0xFF; // Clamp to 8 bits
        } else {
            result = uint8(brightenedComponent);
        }
    }

    function _colorValue(ISVGTypes.ColorAttributeKind attributeKind, bytes memory contents) private pure returns (bytes memory) {
        return abi.encodePacked(attributeKind == ISVGTypes.ColorAttributeKind.RGB ? "rgb(" : "url(#", contents, ")");
    }

    function _mixComponents(uint8 component1, uint8 component2, uint32 ratioPercentage, uint32 totalPercentage) private pure returns (uint8 component) {
        uint32 mixedComponent = (uint32(component1) * ratioPercentage + uint32(component2) * (100 - ratioPercentage)) * totalPercentage / 10000;
        if (mixedComponent > 0xFF) {
            component = 0xFF; // Clamp to 8 bits
        } else {
            component = uint8(mixedComponent);
        }
    }

    function _randomizeComponent(uint8 start, uint8 stop, uint8 random, uint16 percent) private pure returns (uint8 component) {
        if (start == stop) {
            component = start;
        } else { // This is the standard case
            (uint8 floor, uint8 ceiling) = start < stop ? (start, stop) : (stop, start);
            component = floor + uint8(uint16(ceiling - (random & 0x01) - floor) * percent / uint16(100));
        }
    }
}

File 19 of 31 : SVGErrors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @dev When the ratio percentage provided to a function is > 100
error RatioInvalid();

File 20 of 31 : base64.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0;

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

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

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

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

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

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

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

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

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

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

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

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

        return result;
    }

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

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

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

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

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

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

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

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

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

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

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

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

        return result;
    }
}

File 21 of 31 : IBear3TraitProvider.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IBear3Traits.sol";

/// @title Gen 3 TwoBitBear traits provider
/// @notice Provides IBear3Traits to the blockchain
interface IBear3TraitProvider{

    /// Returns the traits associated with a given token ID
    /// @dev Throws if the token ID is not valid
    /// @param tokenId The ID of the token that represents the Bear
    /// @return traits memory
    function bearTraits(uint256 tokenId) external view returns (IBear3Traits.Traits memory);

    /// Returns whether a Gen 2 Bear (TwoBitCubs) has breeded a Gen 3 TwoBitBear
    /// @dev Does not throw if the tokenId is not valid
    /// @param tokenId The token ID of the Gen 2 bear
    /// @return Returns whether the Gen 2 Bear has mated
    function hasGen2Mated(uint256 tokenId) external view returns (bool);

    /// Returns whether a Gen 3 Bear has produced a Gen 4 TwoBitBear
    /// @dev Throws if the token ID is not valid
    /// @param tokenId The token ID of the Gen 3 bear
    /// @return Returns whether the Gen 3 Bear has been used for Gen 4 minting
    function generation4Claimed(uint256 tokenId) external view returns (bool);

    /// Returns the scar colors of a given token Id
    /// @dev Throws if the token ID is not valid or if not revealed
    /// @param tokenId The token ID of the Gen 3 bear
    /// @return Returns the scar colors
    function scarColors(uint256 tokenId) external view returns (IBear3Traits.ScarColor[] memory);
}

File 22 of 31 : IBear3Traits.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Gen 3 TwoBitBear traits
/// @notice Describes the traits of a Gen 3 TwoBitBear
interface IBear3Traits {

    /// Represents the backgrounds of a Gen 3 TwoBitBear
    enum BackgroundType {
        White, Green, Blue
    }

    /// Represents the scars of a Gen 3 TwoBitBear
    enum ScarColor {
        None, Blue, Magenta, Gold
    }

    /// Represents the species of a Gen 3 TwoBitBear
    enum SpeciesType {
        Brown, Black, Polar, Panda
    }

    /// Represents the mood of a Gen 3 TwoBitBear
    enum MoodType {
        Happy, Hungry, Sleepy, Grumpy, Cheerful, Excited, Snuggly, Confused, Ravenous, Ferocious, Hangry, Drowsy, Cranky, Furious
    }

    /// Represents the traits of a Gen 3 TwoBitBear
    struct Traits {
        BackgroundType background;
        MoodType mood;
        SpeciesType species;
        bool gen4Claimed;
        uint8 nameIndex;
        uint8 familyIndex;
        uint16 firstParentTokenId;
        uint16 secondParentTokenId;
        uint176 genes;
    }
}

File 23 of 31 : IBearRenderTech.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IBear3Traits.sol";

/// @title Main Tech for Gen 3 TwoBitBear rendering
/// @dev Supports the ERC-721 contract
interface IBearRenderTech {

    /// Returns the text of a background based on the supplied type
    /// @param background The BackgroundType
    /// @return The background text
    function backgroundForType(IBear3Traits.BackgroundType background) external pure returns (string memory);

    /// Creates the SVG for a Gen 3 TwoBitBear given its IBear3Traits.Traits and Token Id
    /// @dev Passes rendering on to a specific species' IBearRenderer
    /// @param traits The Bear's traits structure
    /// @param tokenId The Bear's Token Id
    /// @return The raw xml as bytes
    function createSvg(IBear3Traits.Traits memory traits, uint256 tokenId) external view returns (bytes memory);

    /// Returns the family of a Gen 3 TwoBitBear as a string
    /// @param traits The Bear's traits structure
    /// @return The family text
    function familyForTraits(IBear3Traits.Traits memory traits) external view returns (string memory);

    /// @dev Returns the ERC-721 for a Gen 3 TwoBitBear given its IBear3Traits.Traits and Token Id
    /// @param traits The Bear's traits structure
    /// @param tokenId The Bear's Token Id
    /// @return The raw json as bytes
    function metadata(IBear3Traits.Traits memory traits, uint256 tokenId) external view returns (bytes memory);

    /// Returns the text of a mood based on the supplied type
    /// @param mood The MoodType
    /// @return The mood text
    function moodForType(IBear3Traits.MoodType mood) external pure returns (string memory);

    /// Returns the name of a Gen 3 TwoBitBear as a string
    /// @param traits The Bear's traits structure
    /// @return The name text
    function nameForTraits(IBear3Traits.Traits memory traits) external view returns (string memory);

    /// Returns the scar colors of a bear with the provided traits
    /// @param traits The Bear's traits structure
    /// @return The array of scar colors
    function scarsForTraits(IBear3Traits.Traits memory traits) external view returns (IBear3Traits.ScarColor[] memory);

    /// Returns the text of a scar based on the supplied color
    /// @param scarColor The ScarColor
    /// @return The scar color text
    function scarForType(IBear3Traits.ScarColor scarColor) external pure returns (string memory);

    /// Returns the text of a species based on the supplied type
    /// @param species The SpeciesType
    /// @return The species text
    function speciesForType(IBear3Traits.SpeciesType species) external pure returns (string memory);
}

File 24 of 31 : IBearRenderTechProvider.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IBear3Traits.sol";

/// @title Bear RenderTech provider
/// @dev Provides IBearRenderTech to an IBearRenderer
interface IBearRenderTechProvider {

    /// Represents a point substitution
    struct Substitution {
        uint matchingX;
        uint matchingY;
        uint replacementX;
        uint replacementY;
    }

    /// Generates an SVG <polygon> element based on a points array and fill color
    /// @param points The encoded points array
    /// @param fill The fill attribute
    /// @param substitutions An array of point substitutions
    /// @return A <polygon> element as bytes
    function dynamicPolygonElement(bytes memory points, bytes memory fill, Substitution[] memory substitutions) external view returns (bytes memory);

    /// Generates an SVG <linearGradient> element based on a points array and stop colors
    /// @param id The id of the linear gradient
    /// @param points The encoded points array
    /// @param stop1 The first stop attribute
    /// @param stop2 The second stop attribute
    /// @return A <linearGradient> element as bytes
    function linearGradient(bytes memory id, bytes memory points, bytes memory stop1, bytes memory stop2) external view returns (bytes memory);

    /// Generates an SVG <path> element based on a points array and fill color
    /// @param path The encoded path array
    /// @param fill The fill attribute
    /// @return A <path> segment as bytes
    function pathElement(bytes memory path, bytes memory fill) external view returns (bytes memory);

    /// Generates an SVG <polygon> segment based on a points array and fill colors
    /// @param points The encoded points array
    /// @param fill The fill attribute
    /// @return A <polygon> segment as bytes
    function polygonElement(bytes memory points, bytes memory fill) external view returns (bytes memory);

    /// Generates an SVG <rect> element based on a points array and fill color
    /// @param widthPercentage The width expressed as a percentage of its container
    /// @param heightPercentage The height expressed as a percentage of its container
    /// @param attributes Additional attributes for the <rect> element
    /// @return A <rect> element as bytes
    function rectElement(uint256 widthPercentage, uint256 heightPercentage, bytes memory attributes) external view returns (bytes memory);
}

File 25 of 31 : IBearRenderer.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@theappstudio/solidity/contracts/interfaces/ISVGTypes.sol";
import "./IBear3Traits.sol";
import "./ICubTraits.sol";

/// @title Gen 3 TwoBitBear Renderer
/// @dev Renders a specific species of a Gen 3 TwoBitBear
interface IBearRenderer {

    /// The eye ratio to apply based on the genes and token id
    /// @param genes The Bear's genes
    /// @param eyeColor The Bear's eye color
    /// @param scars Zero, One, or Two ScarColors
    /// @param tokenId The Bear's Token Id
    /// @return The eye ratio as a uint8
    function customDefs(uint176 genes, ISVGTypes.Color memory eyeColor, IBear3Traits.ScarColor[] memory scars, uint256 tokenId) external view returns (bytes memory);

    /// Influences the eye color given the dominant parent
    /// @param dominantParent The Dominant parent bear
    /// @return The eye color
    function customEyeColor(ICubTraits.TraitsV1 memory dominantParent) external view returns (ISVGTypes.Color memory);

    /// The eye ratio to apply based on the genes and token id
    /// @param genes The Bear's genes
    /// @param eyeColor The Bear's eye color
    /// @param tokenId The Bear's Token Id
    /// @return The eye ratio as a uint8
    function customSurfaces(uint176 genes, ISVGTypes.Color memory eyeColor, uint256 tokenId) external view returns (bytes memory);
}

File 26 of 31 : ICubTraitProvider.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./ICubTraits.sol";

/// @title TwoBitCubs NFT Interface for provided ICubTraits
interface ICubTraitProvider{

    /// Returns the family of a TwoBitCub as a string
    /// @param traits The traits of the Cub
    /// @return The family text
    function familyForTraits(ICubTraits.TraitsV1 memory traits) external pure returns (string memory);

    /// Returns the text of a mood based on the supplied type
    /// @param moodType The CubMoodType
    /// @return The mood text
    function moodForType(ICubTraits.CubMoodType moodType) external pure returns (string memory);

    /// Returns the mood of a TwoBitCub based on its TwoBitBear parents
    /// @param firstParentTokenId The ID of the token that represents the first parent
    /// @param secondParentTokenId The ID of the token that represents the second parent
    /// @return The mood type
    function moodFromParents(uint256 firstParentTokenId, uint256 secondParentTokenId) external view returns (ICubTraits.CubMoodType);

    /// Returns the name of a TwoBitCub as a string
    /// @param traits The traits of the Cub
    /// @return The name text
    function nameForTraits(ICubTraits.TraitsV1 memory traits) external pure returns (string memory);

    /// Returns the text of a species based on the supplied type
    /// @param speciesType The CubSpeciesType
    /// @return The species text
    function speciesForType(ICubTraits.CubSpeciesType speciesType) external pure returns (string memory);

    /// Returns the v1 traits associated with a given token ID.
    /// @dev Throws if the token ID is not valid.
    /// @param tokenId The ID of the token that represents the Cub
    /// @return traits memory
    function traitsV1(uint256 tokenId) external view returns (ICubTraits.TraitsV1 memory traits);
}

File 27 of 31 : ICubTraits.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@theappstudio/solidity/contracts/interfaces/ISVGTypes.sol";

/// @title ICubTraits interface
interface ICubTraits {

    /// Represents the species of a TwoBitCub
    enum CubSpeciesType {
        Brown, Black, Polar, Panda
    }

    /// Represents the mood of a TwoBitCub
    enum CubMoodType {
        Happy, Hungry, Sleepy, Grumpy, Cheerful, Excited, Snuggly, Confused, Ravenous, Ferocious, Hangry, Drowsy, Cranky, Furious
    }

    /// Represents the DNA for a TwoBitCub
    /// @dev organized to fit within 256 bits and consume the least amount of resources
    struct DNA {
        uint16 firstParentTokenId;
        uint16 secondParentTokenId;
        uint224 genes;
    }

    /// Represents the v1 traits of a TwoBitCub
    struct TraitsV1 {
        uint256 age;
        ISVGTypes.Color topColor;
        ISVGTypes.Color bottomColor;
        uint8 nameIndex;
        uint8 familyIndex;
        CubMoodType mood;
        CubSpeciesType species;
    }
}

File 28 of 31 : TwoBitCubs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol";
import "../interfaces/ICubTraitProvider.sol";

/// @title TwoBitCubs
abstract contract TwoBitCubs is IERC721Enumerable, ICubTraitProvider {

    /// @dev The number of blocks until a growing cub becomes an adult (roughly 1 week)
    uint256 public constant ADULT_AGE = 44000;
}

File 29 of 31 : BearRenderTech.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@theappstudio/solidity/contracts/utils/DecimalStrings.sol";
import "@theappstudio/solidity/contracts/utils/OnChain.sol";
import "@theappstudio/solidity/contracts/utils/Randomization.sol";
import "@theappstudio/solidity/contracts/utils/SVG.sol";
import "./BearRenderTechErrors.sol";
import "../interfaces/ICubTraits.sol";
import "../interfaces/IBear3Traits.sol";
import "../interfaces/IBearRenderer.sol";
import "../interfaces/IBearRenderTech.sol";
import "../interfaces/IBearRenderTechProvider.sol";
import "../tokens/TwoBitCubs.sol";

/// @title BearRendering3
contract BearRenderTech is Ownable, IBearRenderTech, IBearRenderTechProvider {

    using Strings for uint256;
    using DecimalStrings for uint256;

    /// Represents an encoding of a number
    struct NumberEncoding {
        uint8 bytesPerPoint;
        uint8 decimals;
        bool signed;
    }

    /// @dev The Black Bear SVG renderer
    IBearRenderer private _blackBearRenderer;

    /// @dev The Brown Bear SVG renderer
    IBearRenderer private _brownBearRenderer;

    /// @dev The Panda Bear SVG renderer
    IBearRenderer private _pandaBearRenderer;

    /// @dev The Polar Bear SVG renderer
    IBearRenderer private _polarBearRenderer;

    /// @dev Reference to the TwoBitCubs contract
    TwoBitCubs private immutable _twoBitCubs;

    /// @dev Controls the reveal
    bool private _wenReveal;

    /// Look...at these...Bears
    constructor(address twoBitCubs) {
        _twoBitCubs = TwoBitCubs(twoBitCubs);
    }

    /// Applies the four IBearRenderers
    /// @param blackRenderer The Black Bear renderer
    /// @param brownRenderer The Brown Bear renderer
    /// @param pandaRenderer The Panda Bear renderer
    /// @param polarRenderer The Polar Bear renderer
    function applyRenderers(address blackRenderer, address brownRenderer, address pandaRenderer, address polarRenderer) external onlyOwner {
        if (address(_blackBearRenderer) != address(0) ||
            address(_brownBearRenderer) != address(0) ||
            address(_pandaBearRenderer) != address(0) ||
            address(_polarBearRenderer) != address(0)) revert AlreadyConfigured();
        _blackBearRenderer = IBearRenderer(blackRenderer);
        _brownBearRenderer = IBearRenderer(brownRenderer);
        _pandaBearRenderer = IBearRenderer(pandaRenderer);
        _polarBearRenderer = IBearRenderer(polarRenderer);
    }

    function backgroundForType(IBear3Traits.BackgroundType background) public pure returns (string memory) {
        string[3] memory backgrounds = ["White Tundra", "Green Forest", "Blue Shore"];
        return backgrounds[uint(background)];
    }

    /// @inheritdoc IBearRenderTech
    function createSvg(IBear3Traits.Traits memory traits, uint256 tokenId) public view onlyWenRevealed returns (bytes memory) {
        IBearRenderer renderer = _rendererForTraits(traits);
        ISVGTypes.Color memory eyeColor = renderer.customEyeColor(_twoBitCubs.traitsV1(traits.firstParentTokenId));
        return SVG.createElement("svg", SVG.svgAttributes(447, 447), abi.encodePacked(
            _defs(renderer, traits, eyeColor, tokenId),
            this.rectElement(100, 100, " fill='url(#background)'"),
            this.pathElement(hex'224d76126b084c81747bfb4381f57cdd821c7de981df7ee74381a37fe5810880c2802f81514c5b3b99a8435a359a5459049aaf57cc9ab0569ab04356939ab055619a55545b99a94c2f678151432e8e80c22df37fe52db77ee7432d7b7de92da17cdd2e227bfb4c39846b0a4c57ca6b0a566b084c76126b085a', "url(#chest)"),
            this.polygonElement(hex'1207160d0408bc0da20a620d040c0a0a9b08bc0a9b056e0a9b', "url(#neck)"),
            renderer.customSurfaces(traits.genes, eyeColor, tokenId)
        ));
    }

    /// @inheritdoc IBearRenderTechProvider
    function dynamicPolygonElement(bytes memory points, bytes memory fill, Substitution[] memory substitutions) external view onlyRenderer returns (bytes memory) {
        return SVG.createElement("polygon", abi.encodePacked(" points='", _polygonPoints(points, substitutions), "' fill='", fill, "'"), "");
    }

    /// @inheritdoc IBearRenderTech
    function familyForTraits(IBear3Traits.Traits memory traits) public view override onlyWenRevealed returns (string memory) {
        string[18] memory families = ["Hirst", "Stark", "xCopy", "Watkinson", "Davis", "Evan Dennis", "Anderson", "Pak", "Greenawalt", "Capacity", "Hobbs", "Deafbeef", "Rainaud", "Snowfro", "Winkelmann", "Fairey", "Nines", "Maeda"];
        return families[(uint(uint8(bytes22(traits.genes)[1])) + uint(traits.familyIndex)) % 18];
    }

    /// @inheritdoc IBearRenderTechProvider
    function linearGradient(bytes memory id, bytes memory points, bytes memory stop1, bytes memory stop2) external view onlyRenderer returns (bytes memory) {
        string memory stop = "stop";
        NumberEncoding memory encoding = _readEncoding(points);
        bytes memory attributes = abi.encodePacked(
            " id='", id,
            "' x1='", _decimalStringFromBytes(points, 1, encoding),
            "' x2='", _decimalStringFromBytes(points, 1 + encoding.bytesPerPoint, encoding),
            "' y1='", _decimalStringFromBytes(points, 1 + 2 * encoding.bytesPerPoint, encoding),
            "' y2='", _decimalStringFromBytes(points, 1 + 3 * encoding.bytesPerPoint, encoding), "'"
        );
        return SVG.createElement("linearGradient", attributes, abi.encodePacked(
            SVG.createElement(stop, stop1, ""), SVG.createElement(stop, stop2, "")
        ));
    }

    /// @inheritdoc IBearRenderTech
    function metadata(IBear3Traits.Traits memory traits, uint256 tokenId) external view returns (bytes memory) {
        string memory token = tokenId.toString();
        if (_wenReveal) {
            return OnChain.dictionary(OnChain.commaSeparated(
                OnChain.keyValueString("name", abi.encodePacked(nameForTraits(traits), " ", familyForTraits(traits), " the ", moodForType(traits.mood), " ", speciesForType(traits.species), " Bear ", token)),
                OnChain.keyValueArray("attributes", _attributesFromTraits(traits)),
                OnChain.keyValueString("image", OnChain.svgImageURI(bytes(createSvg(traits, tokenId))))
            ));
        }
        return OnChain.dictionary(OnChain.commaSeparated(
            OnChain.keyValueString("name", abi.encodePacked("Rendering Bear ", token)),
            OnChain.keyValueString("image", "ipfs://QmUZ3ojSLv3rbu8egkS5brb4ETkNXXmcgCFG66HeFBXn54")
        ));
    }

    /// @inheritdoc IBearRenderTech
    function moodForType(IBear3Traits.MoodType mood) public pure override returns (string memory) {
        string[14] memory moods = ["Happy", "Hungry", "Sleepy", "Grumpy", "Cheerful", "Excited", "Snuggly", "Confused", "Ravenous", "Ferocious", "Hangry", "Drowsy", "Cranky", "Furious"];
        return moods[uint256(mood)];
    }

    /// @inheritdoc IBearRenderTech
    function nameForTraits(IBear3Traits.Traits memory traits) public view override onlyWenRevealed returns (string memory) {
        string[50] memory names = ["Cophi", "Trace", "Abel", "Ekko", "Goomba", "Milk", "Arth", "Roeleman", "Adjudicator", "Kelly", "Tropo", "Type3", "Jak", "Srsly", "Triggity", "SNR", "Drogate", "Scott", "Timm", "Nutsaw", "Rugged", "Vaypor", "XeR0", "Toasty", "BN3", "Dunks", "JFH", "Eallen", "Aspen", "Krueger", "Nouside", "Fonky", "Ian", "Metal", "Bones", "Cruz", "Daniel", "Buz", "Bliargh", "Strada", "Lanky", "Westwood", "Rie", "Moon", "Mango", "Hammer", "Pizza", "Java", "Gremlin", "Hash"];
        return names[(uint(uint8(bytes22(traits.genes)[0])) + uint(traits.nameIndex)) % 50];
    }

    /// Prevents a function from executing if not called by an authorized party
    modifier onlyRenderer() {
        if (_msgSender() != address(_blackBearRenderer) &&
            _msgSender() != address(_brownBearRenderer) &&
            _msgSender() != address(_pandaBearRenderer) &&
            _msgSender() != address(_polarBearRenderer) &&
            _msgSender() != address(this)) revert OnlyRenderer();
        _;
    }

    /// Prevents a function from executing until wenReveal is set
    modifier onlyWenRevealed() {
        if (!_wenReveal) revert NotYetRevealed();
        _;
    }

    /// @inheritdoc IBearRenderTechProvider
    function pathElement(bytes memory path, bytes memory fill) external view onlyRenderer returns (bytes memory result) {
        NumberEncoding memory encoding = _readEncoding(path);
        bytes memory attributes = " d='";
        uint index = 1;
        while (index < path.length) {
            bytes1 control = path[index++];
            attributes = abi.encodePacked(attributes, control);
            if (control == "C") {
                attributes = abi.encodePacked(attributes, _readNext(path, encoding, 6, index));
                index += 6 * encoding.bytesPerPoint;
            } else if (control == "H") { // Not used by any IBearRenderers anymore
                attributes = abi.encodePacked(attributes, _readNext(path, encoding, 1, index));
                index += encoding.bytesPerPoint;
            } else if (control == "L") {
                attributes = abi.encodePacked(attributes, _readNext(path, encoding, 2, index));
                index += 2 * encoding.bytesPerPoint;
            } else if (control == "M") {
                attributes = abi.encodePacked(attributes, _readNext(path, encoding, 2, index));
                index += 2 * encoding.bytesPerPoint;
            } else if (control == "V") {
                attributes = abi.encodePacked(attributes, _readNext(path, encoding, 1, index));
                index += encoding.bytesPerPoint;
            }
        }
        return SVG.createElement("path", abi.encodePacked(attributes, "' fill='", fill, "'"), "");
    }

    /// @inheritdoc IBearRenderTechProvider
    function polygonElement(bytes memory points, bytes memory fill) external view onlyRenderer returns (bytes memory) {
        return SVG.createElement("polygon", abi.encodePacked(" points='", _polygonPoints(points, new Substitution[](0)), "' fill='", fill, "'"), "");
    }

    /// @inheritdoc IBearRenderTechProvider
    function rectElement(uint256 widthPercentage, uint256 heightPercentage, bytes memory attributes) external view onlyRenderer returns (bytes memory) {
        return abi.encodePacked("<rect width='", widthPercentage.toString(), "%' height='", heightPercentage.toString(), "%'", attributes, "/>");
    }

    /// Wen the world is ready
    /// @dev Only the contract owner can invoke this
    function revealBears() external onlyOwner {
        _wenReveal = true;
    }

    /// @inheritdoc IBearRenderTech
    function scarsForTraits(IBear3Traits.Traits memory traits) public view onlyWenRevealed returns (IBear3Traits.ScarColor[] memory) {
        bytes22 geneBytes = bytes22(traits.genes);
        uint8 scarCountProvider = uint8(geneBytes[18]);
        uint scarCount = Randomization.randomIndex(scarCountProvider, _scarCountPercentages());
        IBear3Traits.ScarColor[] memory scars = new IBear3Traits.ScarColor[](scarCount == 0 ? 1 : scarCount);
        if (scarCount == 0) {
            scars[0] = IBear3Traits.ScarColor.None;
        } else {
            uint8 scarColorProvider = uint8(geneBytes[17]);
            uint scarColor = Randomization.randomIndex(scarColorProvider, _scarColorPercentages());
            for (uint scar = 0; scar < scarCount; scar++) {
                scars[scar] = IBear3Traits.ScarColor(scarColor+1);
            }
        }
        return scars;
    }

    /// @inheritdoc IBearRenderTech
    function scarForType(IBear3Traits.ScarColor scarColor) public pure override returns (string memory) {
        string[4] memory scarColors = ["None", "Blue", "Magenta", "Gold"];
        return scarColors[uint256(scarColor)];
    }

    /// @inheritdoc IBearRenderTech
    function speciesForType(IBear3Traits.SpeciesType species) public pure override returns (string memory) {
        string[4] memory specieses = ["Brown", "Black", "Polar", "Panda"];
        return specieses[uint256(species)];
    }

    function _attributesFromTraits(IBear3Traits.Traits memory traits) private view returns (bytes memory) {
        bytes memory attributes = OnChain.commaSeparated(
            OnChain.traitAttribute("Species", bytes(speciesForType(traits.species))),
            OnChain.traitAttribute("Mood", bytes(moodForType(traits.mood))),
            OnChain.traitAttribute("Background", bytes(backgroundForType(traits.background))),
            OnChain.traitAttribute("First Name", bytes(nameForTraits(traits))),
            OnChain.traitAttribute("Last Name (Gen 4 Scene)", bytes(familyForTraits(traits))),
            OnChain.traitAttribute("Parents", abi.encodePacked("#", uint(traits.firstParentTokenId).toString(), " & #", uint(traits.secondParentTokenId).toString()))
        );
        bytes memory scarAttributes = OnChain.traitAttribute("Scars", _scarDescription(scarsForTraits(traits)));
        attributes = abi.encodePacked(attributes, OnChain.continuesWith(scarAttributes));
        bytes memory gen4Attributes = OnChain.traitAttribute("Gen 4 Claim Status", bytes(traits.gen4Claimed ? "Claimed" : "Unclaimed"));
        return abi.encodePacked(attributes, OnChain.continuesWith(gen4Attributes));
    }

    function _decimalStringFromBytes(bytes memory encoded, uint startIndex, NumberEncoding memory encoding) private pure returns (bytes memory) {
        (uint value, bool isNegative) = _uintFromBytes(encoded, startIndex, encoding);
        return value.toDecimalString(encoding.decimals, isNegative);
    }

    function _defs(IBearRenderer renderer, IBear3Traits.Traits memory traits, ISVGTypes.Color memory eyeColor, uint256 tokenId) private view returns (bytes memory) {
        string[3] memory firstStop = ["#fff", "#F3FCEE", "#EAF4F9"];
        string[3] memory lastStop = ["#9C9C9C", "#A6B39E", "#98ADB5"];
        return SVG.createElement("defs", "", abi.encodePacked(
            this.linearGradient("background", hex'32000003ea000003e6',
                abi.encodePacked(" offset='0.44521' stop-color='", firstStop[uint(traits.background)], "'"),
                abi.encodePacked(" offset='0.986697' stop-color='", lastStop[uint(traits.background)], "'")
            ),
            renderer.customDefs(traits.genes, eyeColor, scarsForTraits(traits), tokenId)
        ));
    }

    function _polygonCoordinateFromBytes(bytes memory encoded, uint startIndex, NumberEncoding memory encoding, Substitution[] memory substitutions) private pure returns (bytes memory) {
        (uint x, bool xIsNegative) = _uintFromBytes(encoded, startIndex, encoding);
        (uint y, bool yIsNegative) = _uintFromBytes(encoded, startIndex + encoding.bytesPerPoint, encoding);
        for (uint index = 0; index < substitutions.length; index++) {
            if (x == substitutions[index].matchingX && y == substitutions[index].matchingY) {
                x = substitutions[index].replacementX;
                y = substitutions[index].replacementY;
                break;
            }
        }
        return OnChain.commaSeparated(x.toDecimalString(encoding.decimals, xIsNegative), y.toDecimalString(encoding.decimals, yIsNegative));
    }

    function _polygonPoints(bytes memory points, Substitution[] memory substitutions) private pure returns (bytes memory pointsValue) {
        NumberEncoding memory encoding = _readEncoding(points);

        pointsValue = abi.encodePacked(_polygonCoordinateFromBytes(points, 1, encoding, substitutions));
        uint bytesPerIteration = encoding.bytesPerPoint << 1; // Double because this method processes 2 points at a time
        for (uint byteIndex = 1 + bytesPerIteration; byteIndex < points.length; byteIndex += bytesPerIteration) {
            pointsValue = abi.encodePacked(pointsValue, " ", _polygonCoordinateFromBytes(points, byteIndex, encoding, substitutions));
        }
    }

    function _readEncoding(bytes memory encoded) private pure returns (NumberEncoding memory encoding) {
        encoding.decimals = uint8(encoded[0] >> 4) & 0xF;
        encoding.bytesPerPoint = uint8(encoded[0]) & 0x7;
        encoding.signed = uint8(encoded[0]) & 0x8 == 0x8;
    }

    function _readNext(bytes memory encoded, NumberEncoding memory encoding, uint numbers, uint startIndex) private pure returns (bytes memory result) {
        result = _decimalStringFromBytes(encoded, startIndex, encoding);
        for (uint index = startIndex + encoding.bytesPerPoint; index < startIndex + (numbers * encoding.bytesPerPoint); index += encoding.bytesPerPoint) {
            result = abi.encodePacked(result, " ", _decimalStringFromBytes(encoded, index, encoding));
        }
    }

    function _rendererForTraits(IBear3Traits.Traits memory traits) private view returns (IBearRenderer) {
        if (traits.species == IBear3Traits.SpeciesType.Black) {
            return _blackBearRenderer;
        } else if (traits.species == IBear3Traits.SpeciesType.Brown) {
            return _brownBearRenderer;
        } else if (traits.species == IBear3Traits.SpeciesType.Panda) {
            return _pandaBearRenderer;
        } else /* if (traits.species == IBear3Traits.SpeciesType.Polar) */ {
            return _polarBearRenderer;
        }
    }

    function _scarColorPercentages() private pure returns (uint8[] memory percentages) {
        uint8[] memory array = new uint8[](2);
        array[0] = 60; // 60% Blue
        array[1] = 30; // 30% Magenta
        return array; // 10% Gold
    }

    function _scarCountPercentages() private pure returns (uint8[] memory percentages) {
        uint8[] memory array = new uint8[](2);
        array[0] = 70; // 70% None
        array[1] = 20; // 20% One
        return array; // 10% Two
    }

    function _scarDescription(IBear3Traits.ScarColor[] memory scarColors) private pure returns (bytes memory) {
        if (scarColors.length == 0 || scarColors[0] == IBear3Traits.ScarColor.None) {
            return bytes(scarForType(IBear3Traits.ScarColor.None));
        } else {
            return abi.encodePacked(scarColors.length.toString(), " ", scarForType(scarColors[0]));
        }
    }

    function _uintFromBytes(bytes memory encoded, uint startIndex, NumberEncoding memory encoding) private pure returns (uint result, bool isNegative) {
        result = uint8(encoded[startIndex]);
        if (encoding.signed) {
            isNegative = result & 0x80 == 0x80;
            result &= 0x7F;
        }
        uint stopIndex = startIndex + encoding.bytesPerPoint;
        for (uint index = startIndex + 1; index < stopIndex; index++) {
            result = (result << 8) + uint(uint8(encoded[index]));
        }
    }
}

File 30 of 31 : BearRenderTechErrors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @dev When the renderers are already configured
error AlreadyConfigured();

/// @dev When Reveal is false
error NotYetRevealed();

/// @dev Only the Renderer can make these calls
error OnlyRenderer();

File 31 of 31 : TwoBitBears3Errors.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

/// @dev The address passed in is not allowed
error InvalidAddress();

/// @dev The caller of the method is not allowed
error InvalidCaller();

/// @dev When the parent identifiers are not unique or not of the same species
error InvalidParentCombination();

/// @dev When the TwoBitBear3 tokenId does not exist
error InvalidTokenId();

/// @dev When the parent has already mated
error ParentAlreadyMated(uint256 tokenId);

/// @dev When the parent is not owned by the caller
error ParentNotOwned(uint256 tokenId);

/// @dev When the parent is not yet an adult
error ParentTooYoung(uint256 tokenId);

Settings
{
  "evmVersion": "london",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"seed","type":"uint256"},{"internalType":"address","name":"renderTech","type":"address"},{"internalType":"address","name":"twoBitCubs","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidCaller","type":"error"},{"inputs":[],"name":"InvalidParentCombination","type":"error"},{"inputs":[],"name":"InvalidTokenId","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ParentAlreadyMated","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ParentNotOwned","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ParentTooYoung","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"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":"uint256[]","name":"slotIndices","type":"uint256[]"},{"internalType":"uint256[]","name":"slotValues","type":"uint256[]"}],"name":"applySlots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gen4Contract","type":"address"}],"name":"assignGen4","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"bearTraits","outputs":[{"components":[{"internalType":"enum IBear3Traits.BackgroundType","name":"background","type":"uint8"},{"internalType":"enum IBear3Traits.MoodType","name":"mood","type":"uint8"},{"internalType":"enum IBear3Traits.SpeciesType","name":"species","type":"uint8"},{"internalType":"bool","name":"gen4Claimed","type":"bool"},{"internalType":"uint8","name":"nameIndex","type":"uint8"},{"internalType":"uint8","name":"familyIndex","type":"uint8"},{"internalType":"uint16","name":"firstParentTokenId","type":"uint16"},{"internalType":"uint16","name":"secondParentTokenId","type":"uint16"},{"internalType":"uint176","name":"genes","type":"uint176"}],"internalType":"struct IBear3Traits.Traits","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"slotIndex","type":"uint256"},{"internalType":"uint256","name":"totalTokens","type":"uint256"}],"name":"calculateSlot","outputs":[{"internalType":"uint256","name":"slotValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimGen4","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"generation4Claimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"hasGen2Mated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"imageSVG","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"imageURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"parentOne","type":"uint256"},{"internalType":"uint256","name":"parentTwo","type":"uint256"}],"name":"mateBears","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"minter","type":"address"},{"internalType":"uint256","name":"parentOne","type":"uint256"},{"internalType":"uint256","name":"parentTwo","type":"uint256"}],"name":"matingGas","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"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":"uint256","name":"tokenId","type":"uint256"}],"name":"scarColors","outputs":[{"internalType":"enum IBear3Traits.ScarColor[]","name":"","type":"uint8[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slotParameters","outputs":[{"internalType":"uint256","name":"totalSlots","type":"uint256"},{"internalType":"uint256","name":"totalTokens","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"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":"tokenId","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"}]

60e06040523480156200001157600080fd5b50604051620032aa380380620032aa833981016040819052620000349162000258565b604080518082018252600c81526b54776f42697442656172733360a01b60208083019182528351808501909452600384526254423360e81b908401528151919291620000839160009162000195565b5080516200009990600190602084019062000195565b505050620000b6620000b06200013f60201b60201c565b62000143565b600b8390556001600160a01b03808316608052811660c08190526040805163cd93f59b60e01b8152905163cd93f59b916004808201926020929091908290030181865afa1580156200010c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000132919062000299565b60a05250620002f0915050565b3390565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b828054620001a390620002b3565b90600052602060002090601f016020900481019282620001c7576000855562000212565b82601f10620001e257805160ff191683800117855562000212565b8280016001018555821562000212579182015b8281111562000212578251825591602001919060010190620001f5565b506200022092915062000224565b5090565b5b8082111562000220576000815560010162000225565b80516001600160a01b03811681146200025357600080fd5b919050565b6000806000606084860312156200026e57600080fd5b8351925062000280602085016200023b565b915062000290604085016200023b565b90509250925092565b600060208284031215620002ac57600080fd5b5051919050565b600181811c90821680620002c857607f821691505b60208210811415620002ea57634e487b7160e01b600052602260045260246000fd5b50919050565b60805160a05160c051612f59620003516000396000818161096901528181610a2101528181610e9f01528181610f84015281816112c50152611baa015260006120130152600081816114720152818161155e0152611d030152612f596000f3fe608060405234801561001057600080fd5b50600436106101fb5760003560e01c80636716d0e51161011a578063a1fc3b8d116100ad578063c87b56dd1161007c578063c87b56dd14610447578063d22414dd1461045a578063e91e5d0c1461047a578063e985e9c51461048d578063f2fde38b146104a057600080fd5b8063a1fc3b8d146103eb578063a22cb465146103fe578063b88d4fde14610411578063c4b0f3b41461042457600080fd5b80638da5cb5b116100e95780638da5cb5b146103a25780638f742d16146103b357806395d89b41146103c65780639c1cdb9d146103ce57600080fd5b80636716d0e51461036157806370a0823114610374578063715018a614610387578063795516eb1461038f57600080fd5b80632f745c59116101925780634f6ccce7116101615780634f6ccce71461031557806358517671146103285780635ad21b2c1461033b5780636352211e1461034e57600080fd5b80632f745c59146102d5578063313ce567146102e857806342842e0e146102ef5780634aa5524b1461030257600080fd5b8063095ea7b3116101ce578063095ea7b3146102885780630feea7051461029d57806318160ddd146102b057806323b872dd146102c257600080fd5b806301ffc9a71461020057806306d5fa651461022857806306fdde0314610248578063081812fc1461025d575b600080fd5b61021361020e36600461243e565b6104b3565b60405190151581526020015b60405180910390f35b61023b610236366004612462565b6104de565b60405161021f919061257e565b61025061051f565b60405161021f91906125e5565b61027061026b366004612462565b6105b1565b6040516001600160a01b03909116815260200161021f565b61029b61029636600461260d565b61063e565b005b61029b6102ab366004612639565b610754565b600c545b60405190815260200161021f565b61029b6102d0366004612656565b6107c7565b6102b46102e336600461260d565b6107f8565b60006102b4565b61029b6102fd366004612656565b6108c5565b61029b610310366004612697565b6108e0565b6102b4610323366004612462565b610c0d565b6102b4610336366004612697565b610cc3565b610250610349366004612462565b610da2565b61027061035c366004612462565b610dad565b6102b461036f3660046126b9565b610e24565b6102b4610382366004612639565b611047565b61029b6110ce565b61029b61039d36600461273a565b611104565b6006546001600160a01b0316610270565b6102506103c1366004612462565b61125c565b61025061126f565b6103d661127e565b6040805192835260208301919091520161021f565b61029b6103f9366004612462565b611363565b61029b61040c3660046127a6565b6113f0565b61029b61041f36600461287c565b6113ff565b610213610432366004612462565b6000908152600a602052604090205460ff1690565b610250610455366004612462565b611437565b61046d610468366004612462565b611510565b60405161021f919061292b565b610213610488366004612462565b6115d8565b61021361049b366004612978565b611618565b61029b6104ae366004612639565b611646565b60006001600160e01b0319821663780e9d6360e01b14806104d857506104d8826116e1565b92915050565b6104e66123db565b816104f081611731565b61050d576040516307ed98ed60e31b815260040160405180910390fd5b6105168361174e565b91505b50919050565b60606000805461052e906129a6565b80601f016020809104026020016040519081016040528092919081815260200182805461055a906129a6565b80156105a75780601f1061057c576101008083540402835291602001916105a7565b820191906000526020600020905b81548152906001019060200180831161058a57829003601f168201915b5050505050905090565b60006105bc82611731565b6106225760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061064982610dad565b9050806001600160a01b0316836001600160a01b031614156106b75760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610619565b336001600160a01b03821614806106d357506106d38133611618565b6107455760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610619565b61074f83836118a7565b505050565b6006546001600160a01b0316331461077e5760405162461bcd60e51b8152600401610619906129db565b6001600160a01b0381166107a55760405163e6c4247b60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6107d13382611915565b6107ed5760405162461bcd60e51b815260040161061990612a10565b61074f8383836119d7565b600061080383611047565b82106108515760405162461bcd60e51b815260206004820152601960248201527f6f776e657220696e646578206f7574206f6620626f756e6473000000000000006044820152606401610619565b60005b600c548110156108be5761086781611731565b801561088c5750836001600160a01b031661088182610dad565b6001600160a01b0316145b156108ac578261089e578091506108be565b826108a881612a77565b9350505b806108b681612a8e565b915050610854565b5092915050565b61074f838383604051806020016040528060008152506113ff565b6000828152600a602052604090205460ff161561091357604051634a83659160e01b815260048101839052602401610619565b6000818152600a602052604090205460ff161561094657604051634a83659160e01b815260048101829052602401610619565b336040516331a9108f60e11b8152600481018490526001600160a01b03918216917f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190612aa9565b6001600160a01b0316146109fe5760405163254f743960e11b815260048101839052602401610619565b336040516331a9108f60e11b8152600481018390526001600160a01b03918216917f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa158015610a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8c9190612aa9565b6001600160a01b031614610ab65760405163254f743960e11b815260048101829052602401610619565b6000610ac183611b77565b60ff1690506000610ad183611b77565b60ff1690506003821684841480610aeb5750816003168114155b15610b0957604051631120139160e31b815260040160405180910390fd5b6080831015610b2e57604051630f29b20960e21b815260048101869052602401610619565b6080821015610b5357604051630f29b20960e21b815260048101859052602401610619565b6000858152600a60205260408082208054600160ff1991821681179092558784529183208054909216179055600b54610b8b90611c28565b600c8054600181018255600091909152600286901c601f16600885901b601089901b60208b901b603086901b171717177fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c78201819055600b839055919250610c03338260405180602001604052806000815250611c82565b5050505050505050565b6000306001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c719190612ac6565b8210610cbf5760405162461bcd60e51b815260206004820152601a60248201527f676c6f62616c20696e646578206f7574206f6620626f756e64730000000000006044820152606401610619565b5090565b6006546000906001600160a01b03163314610cf05760405162461bcd60e51b8152600401610619906129db565b6000610cfd846020612adf565b90506000610d0c826020612afe565b905083811115610d195750825b60005b610d27600183612b16565b9150610d3282611b77565b60ff16600885901b17935060808410610d535780610d4f81612a8e565b9150505b828211610d1c57801580610d8f575060075486108015610d8f575060078681548110610d8157610d81612b2d565b906000526020600020015484145b15610d9957600093505b50505092915050565b60606104d882611cb5565b6000818152600260205260408120546001600160a01b0316806104d85760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610619565b600c5462023a5090610e3f57610e3c61407482612afe565b90505b610e4884611047565b610e5b57610e5861445c82612afe565b90505b60006080610e6885611d7f565b60ff161015610f4257610e7d61b79883612afe565b60405163051008a960e41b815260048181018790529193506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906351008a90906024016101a060405180830381865afa158015610ee7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0b9190612bec565b60a00151600d811115610f2057610f2061247b565b10610f3457610f316182dc83612afe565b91505b610f3f600182612afe565b90505b6080610f4d84611d7f565b60ff16101561102757610f6261b79883612afe565b60405163051008a960e41b815260048181018690529193506001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906351008a90906024016101a060405180830381865afa158015610fcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff09190612bec565b60a00151600d8111156110055761100561247b565b10611019576110166182dc83612afe565b91505b611024600182612afe565b90505b806001141561103f5761103c61271083612afe565b91505b509392505050565b60006001600160a01b0382166110b25760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610619565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146110f85760405162461bcd60e51b8152600401610619906129db565b6111026000611dd8565b565b6006546001600160a01b0316331461112e5760405162461bcd60e51b8152600401610619906129db565b60005b8381101561125557600085858381811061114d5761114d612b2d565b905060200201359050600084848481811061116a5761116a612b2d565b90506020020135905060078054905082106111fb575b6007548211156111c1576007805460018101825560009182527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880155611180565b600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68801819055611240565b806007838154811061120f5761120f612b2d565b90600052602060002001541461124057806007838154811061123357611233612b2d565b6000918252602090912001555b5050808061124d90612a8e565b915050611131565b5050505050565b60606104d861126a83611cb5565b611e2a565b60606001805461052e906129a6565b600080336001600160a01b031661129d6006546001600160a01b031690565b6001600160a01b0316146112c35760405162461bcd60e51b8152600401610619906129db565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611321573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113459190612ac6565b9050611352602082612c9a565b61135d906001612afe565b91509091565b8061136d81611731565b61138a576040516307ed98ed60e31b815260040160405180910390fd5b6009546001600160a01b031615806113b657506009546001600160a01b0316336001600160a01b031614155b156113d4576040516348f5c3ed60e01b815260040160405180910390fd5b506000908152600860205260409020805460ff19166001179055565b6113fb338383611e96565b5050565b6114093383611915565b6114255760405162461bcd60e51b815260040161061990612a10565b61143184848484611f65565b50505050565b60608161144381611731565b611460576040516307ed98ed60e31b815260040160405180910390fd5b600061146b8461174e565b90506115087f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ae3c334783876040518363ffffffff1660e01b81526004016114be929190612cae565b600060405180830381865afa1580156114db573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115039190810190612ccb565b611f98565b949350505050565b60608161151c81611731565b611539576040516307ed98ed60e31b815260040160405180910390fd5b60006115448461174e565b604051635c82fb2760e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690635c82fb279061159390849060040161257e565b600060405180830381865afa1580156115b0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115089190810190612d42565b6000816115e481611731565b611601576040516307ed98ed60e31b815260040160405180910390fd5b505060009081526008602052604090205460ff1690565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6006546001600160a01b031633146116705760405162461bcd60e51b8152600401610619906129db565b6001600160a01b0381166116d55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610619565b6116de81611dd8565b50565b60006001600160e01b031982166380ac58cd60e01b148061171257506001600160e01b03198216635b5e139f60e01b145b806104d857506301ffc9a760e01b6001600160e01b03198316146104d8565b6000908152600260205260409020546001600160a01b0316151590565b6117566123db565b6000600c838154811061176b5761176b612b2d565b906000526020600020015490508060ff16600d81111561178d5761178d61247b565b8260200190600d8111156117a3576117a361247b565b9081600d8111156117b6576117b661247b565b90525060ff600882901c1660038111156117d2576117d261247b565b826040019060038111156117e8576117e861247b565b908160038111156117fb576117fb61247b565b90525061ffff601082901c811660c0840152602082901c1660e083015260ff603082901c81166080840152603882901c811660a084015261184490600390604084901c16612df4565b60028111156118555761185561247b565b829060028111156118685761186861247b565b9081600281111561187b5761187b61247b565b9052506000928352600860205260409092205460ff161515606082015260509190911c61010082015290565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906118dc82610dad565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061192082611731565b6119815760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610619565b600061198c83610dad565b9050806001600160a01b0316846001600160a01b031614806119c75750836001600160a01b03166119bc846105b1565b6001600160a01b0316145b8061150857506115088185611618565b826001600160a01b03166119ea82610dad565b6001600160a01b031614611a525760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610619565b6001600160a01b038216611ab45760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610619565b611abf6000826118a7565b6001600160a01b0383166000908152600360205260408120805460019290611ae8908490612b16565b90915550506001600160a01b0382166000908152600360205260408120805460019290611b16908490612afe565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611b8282611d7f565b905060808160ff161015611c235760405163051008a960e41b8152600481018390526104d8907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906351008a90906024016101a060405180830381865afa158015611bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1e9190612bec565b611fd4565b919050565b6000611c35600143612b16565b60408051914060208301526bffffffffffffffffffffffff193360601b1690820152600183901c605482015260740160408051601f19818403018152919052805160209091012092915050565b611c8c8383612044565b611c996000848484612177565b61074f5760405162461bcd60e51b815260040161061990612e08565b606081611cc181611731565b611cde576040516307ed98ed60e31b815260040160405180910390fd5b6000611ce98461174e565b604051636935873360e01b81529091506001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636935873390611d3a9084908890600401612cae565b600060405180830381865afa158015611d57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115089190810190612ccb565b600080611d8d602084612c9a565b60075490915081101561051957611da5602084612df4565b611db0906008612adf565b60078281548110611dc357611dc3612b2d565b9060005260206000200154901c915050919050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6060611e6660408051808201909152601a81527f646174613a696d6167652f7376672b786d6c3b6261736536342c000000000000602082015290565b611e6f83612275565b604051602001611e80929190612e5a565b6040516020818303038152906040529050919050565b816001600160a01b0316836001600160a01b03161415611ef85760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610619565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611f708484846119d7565b611f7c84848484612177565b6114315760405162461bcd60e51b815260040161061990612e08565b6060611e6660408051808201909152601d81527f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000602082015290565b60008160c001516003811115611fec57611fec61247b565b8117905060028260a00151600d8111156120085761200861247b565b60ff16901b811790507f0000000000000000000000000000000000000000000000000000000000000000826000015110611c2357608017919050565b6001600160a01b03821661209a5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610619565b6120a381611731565b156120f05760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610619565b6001600160a01b0382166000908152600360205260408120805460019290612119908490612afe565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001600160a01b0384163b1561226a57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906121bb903390899088908890600401612e89565b6020604051808303816000875af19250505080156121f6575060408051601f3d908101601f191682019092526121f391810190612ec6565b60015b612250573d808015612224576040519150601f19603f3d011682016040523d82523d6000602084013e612229565b606091505b5080516122485760405162461bcd60e51b815260040161061990612e08565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611508565b506001949350505050565b606081516000141561229557505060408051602081019091526000815290565b6000604051806060016040528060408152602001612ee460409139905060006003845160026122c49190612afe565b6122ce9190612c9a565b6122d9906004612adf565b905060006122e8826020612afe565b67ffffffffffffffff811115612300576123006127e4565b6040519080825280601f01601f19166020018201604052801561232a576020820181803683370190505b509050818152600183018586518101602084015b81831015612396576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f811685015182535060010161233e565b6003895106600181146123b057600281146123c1576123cd565b613d3d60f01b6001198301526123cd565b603d60f81b6000198301525b509398975050505050505050565b6040805161012081019091528060008152602001600081526020016000815260006020820181905260408201819052606082018190526080820181905260a0820181905260c09091015290565b6001600160e01b0319811681146116de57600080fd5b60006020828403121561245057600080fd5b813561245b81612428565b9392505050565b60006020828403121561247457600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600e81106124a1576124a161247b565b9052565b600481106116de576116de61247b565b6124a1816124a5565b8051600381106124d0576124d061247b565b8083525060208101516124e66020840182612491565b5060408101516124f960408401826124b5565b50606081015161250d606084018215159052565b506080810151612522608084018260ff169052565b5060a081015161253760a084018260ff169052565b5060c081015161254d60c084018261ffff169052565b5060e081015161256360e084018261ffff169052565b50610100818101516001600160b01b03811684830152611431565b61012081016104d882846124be565b60005b838110156125a8578181015183820152602001612590565b838111156114315750506000910152565b600081518084526125d181602086016020860161258d565b601f01601f19169290920160200192915050565b60208152600061245b60208301846125b9565b6001600160a01b03811681146116de57600080fd5b6000806040838503121561262057600080fd5b823561262b816125f8565b946020939093013593505050565b60006020828403121561264b57600080fd5b813561245b816125f8565b60008060006060848603121561266b57600080fd5b8335612676816125f8565b92506020840135612686816125f8565b929592945050506040919091013590565b600080604083850312156126aa57600080fd5b50508035926020909101359150565b6000806000606084860312156126ce57600080fd5b83356126d9816125f8565b95602085013595506040909401359392505050565b60008083601f84011261270057600080fd5b50813567ffffffffffffffff81111561271857600080fd5b6020830191508360208260051b850101111561273357600080fd5b9250929050565b6000806000806040858703121561275057600080fd5b843567ffffffffffffffff8082111561276857600080fd5b612774888389016126ee565b9096509450602087013591508082111561278d57600080fd5b5061279a878288016126ee565b95989497509550505050565b600080604083850312156127b957600080fd5b82356127c4816125f8565b9150602083013580151581146127d957600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60405160e0810167ffffffffffffffff8111828210171561281d5761281d6127e4565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561284c5761284c6127e4565b604052919050565b600067ffffffffffffffff82111561286e5761286e6127e4565b50601f01601f191660200190565b6000806000806080858703121561289257600080fd5b843561289d816125f8565b935060208501356128ad816125f8565b925060408501359150606085013567ffffffffffffffff8111156128d057600080fd5b8501601f810187136128e157600080fd5b80356128f46128ef82612854565b612823565b81815288602083850101111561290957600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6020808252825182820181905260009190848201906040850190845b8181101561296c57835161295a816124a5565b83529284019291840191600101612947565b50909695505050505050565b6000806040838503121561298b57600080fd5b8235612996816125f8565b915060208301356127d9816125f8565b600181811c908216806129ba57607f821691505b6020821081141561051957634e487b7160e01b600052602260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600081612a8657612a86612a61565b506000190190565b6000600019821415612aa257612aa2612a61565b5060010190565b600060208284031215612abb57600080fd5b815161245b816125f8565b600060208284031215612ad857600080fd5b5051919050565b6000816000190483118215151615612af957612af9612a61565b500290565b60008219821115612b1157612b11612a61565b500190565b600082821015612b2857612b28612a61565b500390565b634e487b7160e01b600052603260045260246000fd5b805160ff81168114611c2357600080fd5b600060808284031215612b6657600080fd5b6040516080810181811067ffffffffffffffff82111715612b8957612b896127e4565b604052905080612b9883612b43565b8152612ba660208401612b43565b6020820152612bb760408401612b43565b6040820152612bc860608401612b43565b60608201525092915050565b600481106116de57600080fd5b8051611c2381612bd4565b60006101a08284031215612bff57600080fd5b612c076127fa565b82518152612c188460208501612b54565b6020820152612c2a8460a08501612b54565b6040820152612c3c6101208401612b43565b6060820152612c4e6101408401612b43565b6080820152610160830151600e8110612c6657600080fd5b60a0820152612c786101808401612be1565b60c08201529392505050565b634e487b7160e01b600052601260045260246000fd5b600082612ca957612ca9612c84565b500490565b6101408101612cbd82856124be565b826101208301529392505050565b600060208284031215612cdd57600080fd5b815167ffffffffffffffff811115612cf457600080fd5b8201601f81018413612d0557600080fd5b8051612d136128ef82612854565b818152856020838501011115612d2857600080fd5b612d3982602083016020860161258d565b95945050505050565b60006020808385031215612d5557600080fd5b825167ffffffffffffffff80821115612d6d57600080fd5b818501915085601f830112612d8157600080fd5b815181811115612d9357612d936127e4565b8060051b9150612da4848301612823565b8181529183018401918481019088841115612dbe57600080fd5b938501935b83851015612de85784519250612dd883612bd4565b8282529385019390850190612dc3565b98975050505050505050565b600082612e0357612e03612c84565b500690565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351612e6c81846020880161258d565b835190830190612e8081836020880161258d565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612ebc908301846125b9565b9695505050505050565b600060208284031215612ed857600080fd5b815161245b8161242856fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa264697066735822122021f4ec0cd3dbd0c13e301a8c2d9a83105a310340c325995d44a32b4fcf7d5e0d64736f6c634300080b00330aedacdcb3f4e5faf3e40675921071ee34dd501f361bcdce3dafbef4b53cf9b000000000000000000000000012bf69431c647eda31b1c5e8f9efa3aa03bfa401000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c80636716d0e51161011a578063a1fc3b8d116100ad578063c87b56dd1161007c578063c87b56dd14610447578063d22414dd1461045a578063e91e5d0c1461047a578063e985e9c51461048d578063f2fde38b146104a057600080fd5b8063a1fc3b8d146103eb578063a22cb465146103fe578063b88d4fde14610411578063c4b0f3b41461042457600080fd5b80638da5cb5b116100e95780638da5cb5b146103a25780638f742d16146103b357806395d89b41146103c65780639c1cdb9d146103ce57600080fd5b80636716d0e51461036157806370a0823114610374578063715018a614610387578063795516eb1461038f57600080fd5b80632f745c59116101925780634f6ccce7116101615780634f6ccce71461031557806358517671146103285780635ad21b2c1461033b5780636352211e1461034e57600080fd5b80632f745c59146102d5578063313ce567146102e857806342842e0e146102ef5780634aa5524b1461030257600080fd5b8063095ea7b3116101ce578063095ea7b3146102885780630feea7051461029d57806318160ddd146102b057806323b872dd146102c257600080fd5b806301ffc9a71461020057806306d5fa651461022857806306fdde0314610248578063081812fc1461025d575b600080fd5b61021361020e36600461243e565b6104b3565b60405190151581526020015b60405180910390f35b61023b610236366004612462565b6104de565b60405161021f919061257e565b61025061051f565b60405161021f91906125e5565b61027061026b366004612462565b6105b1565b6040516001600160a01b03909116815260200161021f565b61029b61029636600461260d565b61063e565b005b61029b6102ab366004612639565b610754565b600c545b60405190815260200161021f565b61029b6102d0366004612656565b6107c7565b6102b46102e336600461260d565b6107f8565b60006102b4565b61029b6102fd366004612656565b6108c5565b61029b610310366004612697565b6108e0565b6102b4610323366004612462565b610c0d565b6102b4610336366004612697565b610cc3565b610250610349366004612462565b610da2565b61027061035c366004612462565b610dad565b6102b461036f3660046126b9565b610e24565b6102b4610382366004612639565b611047565b61029b6110ce565b61029b61039d36600461273a565b611104565b6006546001600160a01b0316610270565b6102506103c1366004612462565b61125c565b61025061126f565b6103d661127e565b6040805192835260208301919091520161021f565b61029b6103f9366004612462565b611363565b61029b61040c3660046127a6565b6113f0565b61029b61041f36600461287c565b6113ff565b610213610432366004612462565b6000908152600a602052604090205460ff1690565b610250610455366004612462565b611437565b61046d610468366004612462565b611510565b60405161021f919061292b565b610213610488366004612462565b6115d8565b61021361049b366004612978565b611618565b61029b6104ae366004612639565b611646565b60006001600160e01b0319821663780e9d6360e01b14806104d857506104d8826116e1565b92915050565b6104e66123db565b816104f081611731565b61050d576040516307ed98ed60e31b815260040160405180910390fd5b6105168361174e565b91505b50919050565b60606000805461052e906129a6565b80601f016020809104026020016040519081016040528092919081815260200182805461055a906129a6565b80156105a75780601f1061057c576101008083540402835291602001916105a7565b820191906000526020600020905b81548152906001019060200180831161058a57829003601f168201915b5050505050905090565b60006105bc82611731565b6106225760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061064982610dad565b9050806001600160a01b0316836001600160a01b031614156106b75760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610619565b336001600160a01b03821614806106d357506106d38133611618565b6107455760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610619565b61074f83836118a7565b505050565b6006546001600160a01b0316331461077e5760405162461bcd60e51b8152600401610619906129db565b6001600160a01b0381166107a55760405163e6c4247b60e01b815260040160405180910390fd5b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6107d13382611915565b6107ed5760405162461bcd60e51b815260040161061990612a10565b61074f8383836119d7565b600061080383611047565b82106108515760405162461bcd60e51b815260206004820152601960248201527f6f776e657220696e646578206f7574206f6620626f756e6473000000000000006044820152606401610619565b60005b600c548110156108be5761086781611731565b801561088c5750836001600160a01b031661088182610dad565b6001600160a01b0316145b156108ac578261089e578091506108be565b826108a881612a77565b9350505b806108b681612a8e565b915050610854565b5092915050565b61074f838383604051806020016040528060008152506113ff565b6000828152600a602052604090205460ff161561091357604051634a83659160e01b815260048101839052602401610619565b6000818152600a602052604090205460ff161561094657604051634a83659160e01b815260048101829052602401610619565b336040516331a9108f60e11b8152600481018490526001600160a01b03918216917f000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb1690636352211e90602401602060405180830381865afa1580156109b0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109d49190612aa9565b6001600160a01b0316146109fe5760405163254f743960e11b815260048101839052602401610619565b336040516331a9108f60e11b8152600481018390526001600160a01b03918216917f000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb1690636352211e90602401602060405180830381865afa158015610a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8c9190612aa9565b6001600160a01b031614610ab65760405163254f743960e11b815260048101829052602401610619565b6000610ac183611b77565b60ff1690506000610ad183611b77565b60ff1690506003821684841480610aeb5750816003168114155b15610b0957604051631120139160e31b815260040160405180910390fd5b6080831015610b2e57604051630f29b20960e21b815260048101869052602401610619565b6080821015610b5357604051630f29b20960e21b815260048101859052602401610619565b6000858152600a60205260408082208054600160ff1991821681179092558784529183208054909216179055600b54610b8b90611c28565b600c8054600181018255600091909152600286901c601f16600885901b601089901b60208b901b603086901b171717177fdf6966c971051c3d54ec59162606531493a51404a002842f56009d7e5cf4a8c78201819055600b839055919250610c03338260405180602001604052806000815250611c82565b5050505050505050565b6000306001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c4d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c719190612ac6565b8210610cbf5760405162461bcd60e51b815260206004820152601a60248201527f676c6f62616c20696e646578206f7574206f6620626f756e64730000000000006044820152606401610619565b5090565b6006546000906001600160a01b03163314610cf05760405162461bcd60e51b8152600401610619906129db565b6000610cfd846020612adf565b90506000610d0c826020612afe565b905083811115610d195750825b60005b610d27600183612b16565b9150610d3282611b77565b60ff16600885901b17935060808410610d535780610d4f81612a8e565b9150505b828211610d1c57801580610d8f575060075486108015610d8f575060078681548110610d8157610d81612b2d565b906000526020600020015484145b15610d9957600093505b50505092915050565b60606104d882611cb5565b6000818152600260205260408120546001600160a01b0316806104d85760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610619565b600c5462023a5090610e3f57610e3c61407482612afe565b90505b610e4884611047565b610e5b57610e5861445c82612afe565b90505b60006080610e6885611d7f565b60ff161015610f4257610e7d61b79883612afe565b60405163051008a960e41b815260048181018790529193506001600160a01b037f000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb16906351008a90906024016101a060405180830381865afa158015610ee7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0b9190612bec565b60a00151600d811115610f2057610f2061247b565b10610f3457610f316182dc83612afe565b91505b610f3f600182612afe565b90505b6080610f4d84611d7f565b60ff16101561102757610f6261b79883612afe565b60405163051008a960e41b815260048181018690529193506001600160a01b037f000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb16906351008a90906024016101a060405180830381865afa158015610fcc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ff09190612bec565b60a00151600d8111156110055761100561247b565b10611019576110166182dc83612afe565b91505b611024600182612afe565b90505b806001141561103f5761103c61271083612afe565b91505b509392505050565b60006001600160a01b0382166110b25760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610619565b506001600160a01b031660009081526003602052604090205490565b6006546001600160a01b031633146110f85760405162461bcd60e51b8152600401610619906129db565b6111026000611dd8565b565b6006546001600160a01b0316331461112e5760405162461bcd60e51b8152600401610619906129db565b60005b8381101561125557600085858381811061114d5761114d612b2d565b905060200201359050600084848481811061116a5761116a612b2d565b90506020020135905060078054905082106111fb575b6007548211156111c1576007805460018101825560009182527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c6880155611180565b600780546001810182556000919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c68801819055611240565b806007838154811061120f5761120f612b2d565b90600052602060002001541461124057806007838154811061123357611233612b2d565b6000918252602090912001555b5050808061124d90612a8e565b915050611131565b5050505050565b60606104d861126a83611cb5565b611e2a565b60606001805461052e906129a6565b600080336001600160a01b031661129d6006546001600160a01b031690565b6001600160a01b0316146112c35760405162461bcd60e51b8152600401610619906129db565b7f000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611321573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113459190612ac6565b9050611352602082612c9a565b61135d906001612afe565b91509091565b8061136d81611731565b61138a576040516307ed98ed60e31b815260040160405180910390fd5b6009546001600160a01b031615806113b657506009546001600160a01b0316336001600160a01b031614155b156113d4576040516348f5c3ed60e01b815260040160405180910390fd5b506000908152600860205260409020805460ff19166001179055565b6113fb338383611e96565b5050565b6114093383611915565b6114255760405162461bcd60e51b815260040161061990612a10565b61143184848484611f65565b50505050565b60608161144381611731565b611460576040516307ed98ed60e31b815260040160405180910390fd5b600061146b8461174e565b90506115087f00000000000000000000000012bf69431c647eda31b1c5e8f9efa3aa03bfa4016001600160a01b031663ae3c334783876040518363ffffffff1660e01b81526004016114be929190612cae565b600060405180830381865afa1580156114db573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115039190810190612ccb565b611f98565b949350505050565b60608161151c81611731565b611539576040516307ed98ed60e31b815260040160405180910390fd5b60006115448461174e565b604051635c82fb2760e01b81529091506001600160a01b037f00000000000000000000000012bf69431c647eda31b1c5e8f9efa3aa03bfa4011690635c82fb279061159390849060040161257e565b600060405180830381865afa1580156115b0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115089190810190612d42565b6000816115e481611731565b611601576040516307ed98ed60e31b815260040160405180910390fd5b505060009081526008602052604090205460ff1690565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b6006546001600160a01b031633146116705760405162461bcd60e51b8152600401610619906129db565b6001600160a01b0381166116d55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610619565b6116de81611dd8565b50565b60006001600160e01b031982166380ac58cd60e01b148061171257506001600160e01b03198216635b5e139f60e01b145b806104d857506301ffc9a760e01b6001600160e01b03198316146104d8565b6000908152600260205260409020546001600160a01b0316151590565b6117566123db565b6000600c838154811061176b5761176b612b2d565b906000526020600020015490508060ff16600d81111561178d5761178d61247b565b8260200190600d8111156117a3576117a361247b565b9081600d8111156117b6576117b661247b565b90525060ff600882901c1660038111156117d2576117d261247b565b826040019060038111156117e8576117e861247b565b908160038111156117fb576117fb61247b565b90525061ffff601082901c811660c0840152602082901c1660e083015260ff603082901c81166080840152603882901c811660a084015261184490600390604084901c16612df4565b60028111156118555761185561247b565b829060028111156118685761186861247b565b9081600281111561187b5761187b61247b565b9052506000928352600860205260409092205460ff161515606082015260509190911c61010082015290565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906118dc82610dad565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600061192082611731565b6119815760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610619565b600061198c83610dad565b9050806001600160a01b0316846001600160a01b031614806119c75750836001600160a01b03166119bc846105b1565b6001600160a01b0316145b8061150857506115088185611618565b826001600160a01b03166119ea82610dad565b6001600160a01b031614611a525760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610619565b6001600160a01b038216611ab45760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610619565b611abf6000826118a7565b6001600160a01b0383166000908152600360205260408120805460019290611ae8908490612b16565b90915550506001600160a01b0382166000908152600360205260408120805460019290611b16908490612afe565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611b8282611d7f565b905060808160ff161015611c235760405163051008a960e41b8152600481018390526104d8907f000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb6001600160a01b0316906351008a90906024016101a060405180830381865afa158015611bfa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c1e9190612bec565b611fd4565b919050565b6000611c35600143612b16565b60408051914060208301526bffffffffffffffffffffffff193360601b1690820152600183901c605482015260740160408051601f19818403018152919052805160209091012092915050565b611c8c8383612044565b611c996000848484612177565b61074f5760405162461bcd60e51b815260040161061990612e08565b606081611cc181611731565b611cde576040516307ed98ed60e31b815260040160405180910390fd5b6000611ce98461174e565b604051636935873360e01b81529091506001600160a01b037f00000000000000000000000012bf69431c647eda31b1c5e8f9efa3aa03bfa4011690636935873390611d3a9084908890600401612cae565b600060405180830381865afa158015611d57573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526115089190810190612ccb565b600080611d8d602084612c9a565b60075490915081101561051957611da5602084612df4565b611db0906008612adf565b60078281548110611dc357611dc3612b2d565b9060005260206000200154901c915050919050565b600680546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6060611e6660408051808201909152601a81527f646174613a696d6167652f7376672b786d6c3b6261736536342c000000000000602082015290565b611e6f83612275565b604051602001611e80929190612e5a565b6040516020818303038152906040529050919050565b816001600160a01b0316836001600160a01b03161415611ef85760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610619565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611f708484846119d7565b611f7c84848484612177565b6114315760405162461bcd60e51b815260040161061990612e08565b6060611e6660408051808201909152601d81527f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000602082015290565b60008160c001516003811115611fec57611fec61247b565b8117905060028260a00151600d8111156120085761200861247b565b60ff16901b811790507f000000000000000000000000000000000000000000000000000000000000abe0826000015110611c2357608017919050565b6001600160a01b03821661209a5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610619565b6120a381611731565b156120f05760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610619565b6001600160a01b0382166000908152600360205260408120805460019290612119908490612afe565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60006001600160a01b0384163b1561226a57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906121bb903390899088908890600401612e89565b6020604051808303816000875af19250505080156121f6575060408051601f3d908101601f191682019092526121f391810190612ec6565b60015b612250573d808015612224576040519150601f19603f3d011682016040523d82523d6000602084013e612229565b606091505b5080516122485760405162461bcd60e51b815260040161061990612e08565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611508565b506001949350505050565b606081516000141561229557505060408051602081019091526000815290565b6000604051806060016040528060408152602001612ee460409139905060006003845160026122c49190612afe565b6122ce9190612c9a565b6122d9906004612adf565b905060006122e8826020612afe565b67ffffffffffffffff811115612300576123006127e4565b6040519080825280601f01601f19166020018201604052801561232a576020820181803683370190505b509050818152600183018586518101602084015b81831015612396576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f811685015182535060010161233e565b6003895106600181146123b057600281146123c1576123cd565b613d3d60f01b6001198301526123cd565b603d60f81b6000198301525b509398975050505050505050565b6040805161012081019091528060008152602001600081526020016000815260006020820181905260408201819052606082018190526080820181905260a0820181905260c09091015290565b6001600160e01b0319811681146116de57600080fd5b60006020828403121561245057600080fd5b813561245b81612428565b9392505050565b60006020828403121561247457600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600e81106124a1576124a161247b565b9052565b600481106116de576116de61247b565b6124a1816124a5565b8051600381106124d0576124d061247b565b8083525060208101516124e66020840182612491565b5060408101516124f960408401826124b5565b50606081015161250d606084018215159052565b506080810151612522608084018260ff169052565b5060a081015161253760a084018260ff169052565b5060c081015161254d60c084018261ffff169052565b5060e081015161256360e084018261ffff169052565b50610100818101516001600160b01b03811684830152611431565b61012081016104d882846124be565b60005b838110156125a8578181015183820152602001612590565b838111156114315750506000910152565b600081518084526125d181602086016020860161258d565b601f01601f19169290920160200192915050565b60208152600061245b60208301846125b9565b6001600160a01b03811681146116de57600080fd5b6000806040838503121561262057600080fd5b823561262b816125f8565b946020939093013593505050565b60006020828403121561264b57600080fd5b813561245b816125f8565b60008060006060848603121561266b57600080fd5b8335612676816125f8565b92506020840135612686816125f8565b929592945050506040919091013590565b600080604083850312156126aa57600080fd5b50508035926020909101359150565b6000806000606084860312156126ce57600080fd5b83356126d9816125f8565b95602085013595506040909401359392505050565b60008083601f84011261270057600080fd5b50813567ffffffffffffffff81111561271857600080fd5b6020830191508360208260051b850101111561273357600080fd5b9250929050565b6000806000806040858703121561275057600080fd5b843567ffffffffffffffff8082111561276857600080fd5b612774888389016126ee565b9096509450602087013591508082111561278d57600080fd5b5061279a878288016126ee565b95989497509550505050565b600080604083850312156127b957600080fd5b82356127c4816125f8565b9150602083013580151581146127d957600080fd5b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60405160e0810167ffffffffffffffff8111828210171561281d5761281d6127e4565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561284c5761284c6127e4565b604052919050565b600067ffffffffffffffff82111561286e5761286e6127e4565b50601f01601f191660200190565b6000806000806080858703121561289257600080fd5b843561289d816125f8565b935060208501356128ad816125f8565b925060408501359150606085013567ffffffffffffffff8111156128d057600080fd5b8501601f810187136128e157600080fd5b80356128f46128ef82612854565b612823565b81815288602083850101111561290957600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b6020808252825182820181905260009190848201906040850190845b8181101561296c57835161295a816124a5565b83529284019291840191600101612947565b50909695505050505050565b6000806040838503121561298b57600080fd5b8235612996816125f8565b915060208301356127d9816125f8565b600181811c908216806129ba57607f821691505b6020821081141561051957634e487b7160e01b600052602260045260246000fd5b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b600081612a8657612a86612a61565b506000190190565b6000600019821415612aa257612aa2612a61565b5060010190565b600060208284031215612abb57600080fd5b815161245b816125f8565b600060208284031215612ad857600080fd5b5051919050565b6000816000190483118215151615612af957612af9612a61565b500290565b60008219821115612b1157612b11612a61565b500190565b600082821015612b2857612b28612a61565b500390565b634e487b7160e01b600052603260045260246000fd5b805160ff81168114611c2357600080fd5b600060808284031215612b6657600080fd5b6040516080810181811067ffffffffffffffff82111715612b8957612b896127e4565b604052905080612b9883612b43565b8152612ba660208401612b43565b6020820152612bb760408401612b43565b6040820152612bc860608401612b43565b60608201525092915050565b600481106116de57600080fd5b8051611c2381612bd4565b60006101a08284031215612bff57600080fd5b612c076127fa565b82518152612c188460208501612b54565b6020820152612c2a8460a08501612b54565b6040820152612c3c6101208401612b43565b6060820152612c4e6101408401612b43565b6080820152610160830151600e8110612c6657600080fd5b60a0820152612c786101808401612be1565b60c08201529392505050565b634e487b7160e01b600052601260045260246000fd5b600082612ca957612ca9612c84565b500490565b6101408101612cbd82856124be565b826101208301529392505050565b600060208284031215612cdd57600080fd5b815167ffffffffffffffff811115612cf457600080fd5b8201601f81018413612d0557600080fd5b8051612d136128ef82612854565b818152856020838501011115612d2857600080fd5b612d3982602083016020860161258d565b95945050505050565b60006020808385031215612d5557600080fd5b825167ffffffffffffffff80821115612d6d57600080fd5b818501915085601f830112612d8157600080fd5b815181811115612d9357612d936127e4565b8060051b9150612da4848301612823565b8181529183018401918481019088841115612dbe57600080fd5b938501935b83851015612de85784519250612dd883612bd4565b8282529385019390850190612dc3565b98975050505050505050565b600082612e0357612e03612c84565b500690565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351612e6c81846020880161258d565b835190830190612e8081836020880161258d565b01949350505050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612ebc908301846125b9565b9695505050505050565b600060208284031215612ed857600080fd5b815161245b8161242856fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa264697066735822122021f4ec0cd3dbd0c13e301a8c2d9a83105a310340c325995d44a32b4fcf7d5e0d64736f6c634300080b0033

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

0aedacdcb3f4e5faf3e40675921071ee34dd501f361bcdce3dafbef4b53cf9b000000000000000000000000012bf69431c647eda31b1c5e8f9efa3aa03bfa401000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb

-----Decoded View---------------
Arg [0] : seed (uint256): 4943064290696701270692758998311644719966173076954833463872484188389830883760
Arg [1] : renderTech (address): 0x12BF69431C647EDA31b1C5E8F9EfA3aA03BFa401
Arg [2] : twoBitCubs (address): 0x488C057CF3deE9Ee2E386112e08F2c6d8e58cdFB

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0aedacdcb3f4e5faf3e40675921071ee34dd501f361bcdce3dafbef4b53cf9b0
Arg [1] : 00000000000000000000000012bf69431c647eda31b1c5e8f9efa3aa03bfa401
Arg [2] : 000000000000000000000000488c057cf3dee9ee2e386112e08f2c6d8e58cdfb


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.