ETH Price: $2,529.32 (+0.95%)

Contract

0x6417Bb5ea597948ec4082D21a489e3e11f1860Ad
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Reroll176437092023-07-07 18:29:35419 days ago1688754575IN
0x6417Bb5e...11f1860Ad
0 ETH0.0038784147.0686624
Reroll176437062023-07-07 18:28:59419 days ago1688754539IN
0x6417Bb5e...11f1860Ad
0 ETH0.0038730747.05698793
Reroll176437052023-07-07 18:28:47419 days ago1688754527IN
0x6417Bb5e...11f1860Ad
0 ETH0.0041543850.41792581
Reroll176437012023-07-07 18:27:59419 days ago1688754479IN
0x6417Bb5e...11f1860Ad
0 ETH0.0038130146.32732057
Reroll176436962023-07-07 18:26:59419 days ago1688754419IN
0x6417Bb5e...11f1860Ad
0 ETH0.0040845649.57056198
Reroll176436942023-07-07 18:26:35419 days ago1688754395IN
0x6417Bb5e...11f1860Ad
0 ETH0.0041426950.33288315
Reroll176436912023-07-07 18:25:59419 days ago1688754359IN
0x6417Bb5e...11f1860Ad
0 ETH0.0039841248.351591
Reroll176436882023-07-07 18:25:23419 days ago1688754323IN
0x6417Bb5e...11f1860Ad
0 ETH0.004052949.24187365
Reroll176436842023-07-07 18:24:35419 days ago1688754275IN
0x6417Bb5e...11f1860Ad
0 ETH0.0043882253.31599148
Reroll176436802023-07-07 18:23:47419 days ago1688754227IN
0x6417Bb5e...11f1860Ad
0 ETH0.0053535753.85561324
Boost176436762023-07-07 18:22:59419 days ago1688754179IN
0x6417Bb5e...11f1860Ad
0 ETH0.0020593849.43076536
Reroll176436732023-07-07 18:22:23419 days ago1688754143IN
0x6417Bb5e...11f1860Ad
0 ETH0.0044279653.79101568
Reroll176436722023-07-07 18:22:11419 days ago1688754131IN
0x6417Bb5e...11f1860Ad
0 ETH0.0046102855.95077427
Reroll176436692023-07-07 18:21:35419 days ago1688754095IN
0x6417Bb5e...11f1860Ad
0 ETH0.005081651.11353773
Reroll176436682023-07-07 18:21:23419 days ago1688754083IN
0x6417Bb5e...11f1860Ad
0 ETH0.0046053455.89082643
Boost176436652023-07-07 18:20:47419 days ago1688754047IN
0x6417Bb5e...11f1860Ad
0 ETH0.0023527356.3623162
Reroll176436622023-07-07 18:20:11419 days ago1688754011IN
0x6417Bb5e...11f1860Ad
0 ETH0.0042778351.91608348
Reroll176436612023-07-07 18:19:59419 days ago1688753999IN
0x6417Bb5e...11f1860Ad
0 ETH0.0043667552.99520683
Reroll176436552023-07-07 18:18:47419 days ago1688753927IN
0x6417Bb5e...11f1860Ad
0 ETH0.0050098350.35059132
Boost176436512023-07-07 18:17:59419 days ago1688753879IN
0x6417Bb5e...11f1860Ad
0 ETH0.0022581254.2010771
Reroll176436472023-07-07 18:17:11419 days ago1688753831IN
0x6417Bb5e...11f1860Ad
0 ETH0.0044780754.39976077
Reroll176436432023-07-07 18:16:23419 days ago1688753783IN
0x6417Bb5e...11f1860Ad
0 ETH0.0043255252.54658059
Reroll176436222023-07-07 18:12:11419 days ago1688753531IN
0x6417Bb5e...11f1860Ad
0 ETH0.0033928641.21652072
Reroll176436162023-07-07 18:10:47419 days ago1688753447IN
0x6417Bb5e...11f1860Ad
0 ETH0.0036731844.57807709
Reroll176436082023-07-07 18:09:11419 days ago1688753351IN
0x6417Bb5e...11f1860Ad
0 ETH0.0045162545.42689502
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
176437322023-07-07 18:34:11419 days ago1688754851
0x6417Bb5e...11f1860Ad
0 ETH
176437322023-07-07 18:34:11419 days ago1688754851
0x6417Bb5e...11f1860Ad
0 ETH
176437092023-07-07 18:29:35419 days ago1688754575
0x6417Bb5e...11f1860Ad
0 ETH
176437092023-07-07 18:29:35419 days ago1688754575
0x6417Bb5e...11f1860Ad
0 ETH
176437062023-07-07 18:28:59419 days ago1688754539
0x6417Bb5e...11f1860Ad
0 ETH
176437062023-07-07 18:28:59419 days ago1688754539
0x6417Bb5e...11f1860Ad
0 ETH
176437052023-07-07 18:28:47419 days ago1688754527
0x6417Bb5e...11f1860Ad
0 ETH
176437052023-07-07 18:28:47419 days ago1688754527
0x6417Bb5e...11f1860Ad
0 ETH
176437012023-07-07 18:27:59419 days ago1688754479
0x6417Bb5e...11f1860Ad
0 ETH
176437012023-07-07 18:27:59419 days ago1688754479
0x6417Bb5e...11f1860Ad
0 ETH
176436962023-07-07 18:26:59419 days ago1688754419
0x6417Bb5e...11f1860Ad
0 ETH
176436962023-07-07 18:26:59419 days ago1688754419
0x6417Bb5e...11f1860Ad
0 ETH
176436942023-07-07 18:26:35419 days ago1688754395
0x6417Bb5e...11f1860Ad
0 ETH
176436942023-07-07 18:26:35419 days ago1688754395
0x6417Bb5e...11f1860Ad
0 ETH
176436912023-07-07 18:25:59419 days ago1688754359
0x6417Bb5e...11f1860Ad
0 ETH
176436912023-07-07 18:25:59419 days ago1688754359
0x6417Bb5e...11f1860Ad
0 ETH
176436882023-07-07 18:25:23419 days ago1688754323
0x6417Bb5e...11f1860Ad
0 ETH
176436882023-07-07 18:25:23419 days ago1688754323
0x6417Bb5e...11f1860Ad
0 ETH
176436842023-07-07 18:24:35419 days ago1688754275
0x6417Bb5e...11f1860Ad
0 ETH
176436842023-07-07 18:24:35419 days ago1688754275
0x6417Bb5e...11f1860Ad
0 ETH
176436802023-07-07 18:23:47419 days ago1688754227
0x6417Bb5e...11f1860Ad
0 ETH
176436802023-07-07 18:23:47419 days ago1688754227
0x6417Bb5e...11f1860Ad
0 ETH
176436762023-07-07 18:22:59419 days ago1688754179
0x6417Bb5e...11f1860Ad
0 ETH
176436732023-07-07 18:22:23419 days ago1688754143
0x6417Bb5e...11f1860Ad
0 ETH
176436732023-07-07 18:22:23419 days ago1688754143
0x6417Bb5e...11f1860Ad
0 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DNAV2

Compiler Version
v0.8.18+commit.87f61d96

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 5 : DNA.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import "@openzeppelin/contracts/access/Ownable.sol";
import "erc721a/contracts/ERC721A.sol";

/////////////////////////////////////////////////////////////////////////////
//                                                                         //
//                                                                         //
//    ██╗░░░██╗░█████╗░██╗░░░░░██╗░░██╗░█████╗░██╗░░░░░██╗░░░░░░█████╗░    //
//    ██║░░░██║██╔══██╗██║░░░░░██║░░██║██╔══██╗██║░░░░░██║░░░░░██╔══██╗    //
//    ╚██╗░██╔╝███████║██║░░░░░███████║███████║██║░░░░░██║░░░░░███████║    //
//    ░╚████╔╝░██╔══██║██║░░░░░██╔══██║██╔══██║██║░░░░░██║░░░░░██╔══██║    //
//    ░░╚██╔╝░░██║░░██║███████╗██║░░██║██║░░██║███████╗███████╗██║░░██║    //
//    ░░░╚═╝░░░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝╚═╝░░╚═╝╚══════╝╚══════╝╚═╝░░╚═╝    //
//                                                                         //
//                                                                         //
/////////////////////////////////////////////////////////////////////////////

/**
 * Subset of a Utility token contract with only the methods that the dna contract will call.
 */
interface Utility {
    function approvedBurn(
        address spender,
        uint256 tokenId,
        uint256 amount
    ) external;
}

contract DNAV2 is Ownable {
    // =============================================================
    //                           CONSTANTS
    // =============================================================

    // Checks the `ownerOf` method of this address for tokenId reroll eligibility
    address public immutable TOKEN_CONTRACT;

    // Hash for the initial revealed tokens
    string public constant MINT_PROVENANCE_HASH =
        "037226b21636376001dbfd22f52d1dd72845efa9613baf51a6a011ac731b2327";

    // Hash for the tokens post armory v1 event
    string public constant ARMORY_V1_PROVENANCE_HASH =
        "60a731c1259c12c40f6eafee058235cb54eaed74593c7401b3568af30b74c65b";

    // Proof of hash will be given after all tokens are auctioned
    string public constant AUCTION_PROVENANCE_HASH =
        "eb8c88969a4b776d757de962a194f5b4ffaaadb991ecfbb24d806c7bc6397d30";

    // The Initial DNA is composed of 128 bits for each token
    // with each trait taking up 8 bits
    uint256 private constant _BITMASK_INITIAL_DNA = (1 << 8) - 1;

    // Offset in bits where the booster information will start
    uint256 private constant _BOOSTER_OFFSET = 128;

    // 11 rerollable traits will fit in 4 bits
    uint256 private constant _BITLEN_BOOSTER_TRAIT = 4;
    uint256 private constant _BITMASK_BOOSTER_TRAIT =
        (1 << _BITLEN_BOOSTER_TRAIT) - 1;

    uint256 private constant _BITLEN_SINGLE_BOOST = 10;
    uint256 private constant _BITMASK_SINGLE_BOOST =
        (1 << _BITLEN_SINGLE_BOOST) - 1;
    uint256 private constant _BITLEN_TRAIT_BOOST = 11;
    uint256 private constant _BITMASK_TRAIT_BOOST =
        (1 << _BITLEN_TRAIT_BOOST) - 1;

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

    // This IPFS code hash will have a function that can translate any token's
    // DNA into the corresponding traits. This logic is put here instead of on the
    // contract so that the gas fee for rerolling is minimal for the user.
    string public dnaTranslatorCodeHash;

    // Each call to reroll will give this many options to select during boost
    uint256 public numBoosts;

    // Defines what token is required to reroll traits
    address public utilityAddress;
    uint256 public utilityTokenId;

    // Only address allowed to change a token's dna.
    address public dnaInjectorAddress;

    // A token's dna cannot be changed unless both of these are active.
    bool public rerollActive;
    bool public boostingActive;

    // Mapping from traitId to whether it is rerollable
    mapping(uint256 => bool) public traitIdRerollable;

    // For pseudo-rng
    uint256 private _seed;

    // Mapping tokenId to DNA information. An extra bit is needed for
    // each trait because the random boosterValue does have a small
    // but non-zero probability to roll a 0. (1 in 1024)
    //
    // Bits Layout:
    // - [0..127]   `initialDna`
    // - [128]      `hasHairBooster`
    // - [129..138] `hairBooster`
    // - [139]      `hasClothesBooster`
    // - [140..149] `clothesBooster`
    // - [150]      `hasPrimaryBooster`
    // - [151..160] `primaryBooster`
    // - [161]      `hasHeadgearBooster`
    // - [162..171] `headgearBooster`
    // - [172]      `hasFaceBooster`
    // - [173..182] `faceBooster`
    // - [183]      `hasFaceAccBooster`
    // - [184..193] `faceAccBooster`
    // - [194]      `hasEyeBooster`
    // - [195..204] `eyeBooster`
    // - [205]      `hasMouthBooster`
    // - [206..215] `mouthBooster`
    // - [216]      `hasEarBooster`
    // - [217..226] `earBooster`
    // - [227]      `hasNeckBooster`
    // - [228..237] `neckBooster`
    // - [238]      `hasTattooBooster`
    // - [239..248] `tattooBooster`
    // - [249..255]  Extra Unused Bits
    mapping(uint256 => uint256) private _dna;

    // Bits Layout:
    // - [0..3]     `boosterIdx`
    // - [4..13]    `boosterRoll`
    // - [14..23]   `boosterRoll`
    // - [24..33]   `boosterRoll`
    // - [34..256]   Extra unused bits or more boosterRolls
    mapping(uint256 => uint256) public activeBooster;

    // =============================================================
    //                         Events
    // =============================================================

    event Bought(
        uint256 indexed tokenId,
        uint256 indexed traitId,
        uint256 tokenDna,
        uint256 boosterVal
    );
    event Boost(uint256 indexed tokenId, uint256 boosterId, uint256 tokenDna);

    // =============================================================
    //                         Constructor
    // =============================================================
    constructor(address tokenAddress) {
        TOKEN_CONTRACT = tokenAddress;
    }

    // =============================================================
    //                          Only Owner
    // =============================================================

    /**
     * @notice Allows the owner to update the IPFS code hash with a
     * function providing the translation between DNA and token traits.
     */
    function setDnaTranslatorCodeHash(
        string memory codeHash
    ) external onlyOwner {
        dnaTranslatorCodeHash = codeHash;
    }

    /**
     * @notice Allows the owner to change the number of selectable options per boost.
     */
    function setNumBoosts(uint256 updatedNumBoosts) external onlyOwner {
        numBoosts = updatedNumBoosts;
    }

    /**
     * @notice Allows the owner to change the dna of any tokenId and is used for initial dna injection.
     */
    function injectDna(
        uint256[] memory dna,
        uint256[] memory tokenIds
    ) external {
        if (msg.sender != dnaInjectorAddress) revert NotDnaInjector();

        for (uint i = 0; i < tokenIds.length; ) {
            _dna[tokenIds[i]] = dna[i];

            unchecked {
                ++i;
            }
        }
    }

    /**
     * @notice Allows the owner to update the dna translator script.
     */
    function setDnaInjector(address dnaInjector) external onlyOwner {
        dnaInjectorAddress = dnaInjector;
    }

    /**
     * @notice Allows the owner to select an address and token that must be burned to alter a token's
     * dna. This address must have an {approvedBurn} method that is callable by this contract for
     * another user's tokens.
     */
    function setRerollToken(address token, uint256 tokenId) external onlyOwner {
        utilityAddress = token;
        utilityTokenId = tokenId;
    }

    /**
     * @notice Allows the owner to enable or disable token owners from rolling their dna.
     */
    function setRerollActive(bool active) external onlyOwner {
        rerollActive = active;
    }

    /**
     * @notice Allows the owner to enable or disable token owners from finalizing rolls into their dna.
     */
    function setBoostingActive(bool active) external onlyOwner {
        boostingActive = active;
    }

    /**
     * @notice Allows the owner to set which traitIds are rerollable.
     */
    function setTraitIdRerollable(
        uint256 traitId,
        bool rerollable
    ) external onlyOwner {
        traitIdRerollable[traitId] = rerollable;
    }

    // =============================================================
    //                    Dna Interactions
    // =============================================================

    /**
     * @dev Returns the saved token dna for a given id. This dna can be translated into
     * metadata using the scripts that are part of the DNA_TRANSLATOR_CODE_HASH constant.
     */
    function getTokenDna(uint256 tokenId) external view returns (uint256) {
        return _dna[tokenId];
    }

    /**
     * @dev Adds an activeBooster to a given tokenId for a certain trait. The caller cannot be
     * a contract address and they must own both the Valhalla tokenId as well as the corresponding
     * Utility token to be burned.
     *
     * Note:
     * - A token CANNOT reroll a trait they do not have
     * - A token CAN override an existing activeBooster with another roll without calling {boost}
     * - The override is true even if a different rerollTraitId is selected from the first roll
     *
     * @param tokenId tokenId that the booster is attached to
     * @param rerollTraitId follows the mapping:
     * 0: Hair
     * 1: Clothes
     * 2: Primary
     * 3: Headgear
     * 4: Face
     * 5: FaceAcc
     * 6: Eye
     * 7: Mouth
     * 8: Ear
     * 9: Neck
     * 10: Tattoo
     */
    function reroll(uint256 tokenId, uint256 rerollTraitId) external {
        if (!rerollActive) revert RerollInactive();
        if (msg.sender != tx.origin) revert NotEOA();
        if (!traitIdRerollable[rerollTraitId]) revert TraitNotRerollable();
        if (IERC721A(TOKEN_CONTRACT).ownerOf(tokenId) != msg.sender)
            revert NotTokenOwner();

        Utility(utilityAddress).approvedBurn(msg.sender, utilityTokenId, 1);

        // Cheaper gaswise to do left bitshift by 3 than to multiply rerollTraitId by 8
        if (
            _dna[tokenId] &
                (_BITMASK_INITIAL_DNA <<
                    (_correctedRerollTraitId(rerollTraitId) << 3)) ==
            0
        ) revert TraitNotOnToken();

        // Shift _randomNumber up to make room for reroll traitId
        uint256 boosterVal = _randomNumber() << _BITLEN_BOOSTER_TRAIT;
        boosterVal = boosterVal | rerollTraitId;

        activeBooster[tokenId] = boosterVal;
        emit Bought(tokenId, rerollTraitId, _dna[tokenId], boosterVal);
    }

    /**
     * @dev Selects one of the boosters rolled from the {reroll} method and replaces the appropriate
     * section in the token dna's bits with one of the new values that was randomly rolled.
     */
    function boost(uint256 tokenId, uint256 boosterIdx) external {
        if (!boostingActive) revert BoostingInactive();
        if (IERC721A(TOKEN_CONTRACT).ownerOf(tokenId) != msg.sender)
            revert NotTokenOwner();
        uint256 boosterVal = activeBooster[tokenId];
        if (boosterVal == 0) revert NoBoosterAtIdx();
        activeBooster[tokenId] = 0;

        if (boosterIdx >= numBoosts) revert InvalidBoostIdx();
        uint256 selectedVal = (boosterVal >>
            (boosterIdx * _BITLEN_SINGLE_BOOST + _BITLEN_BOOSTER_TRAIT)) &
            _BITMASK_SINGLE_BOOST;

        // This shifts the value up one bit and adds a flag to show that this trait has been boosted.
        // This is needed on the small chance that random value generated is exactly 0.
        selectedVal = (selectedVal << 1) | 1;

        uint256 rerollTraitId = boosterVal & _BITMASK_BOOSTER_TRAIT;
        uint256 traitShiftAmount = _correctedRerollTraitId(rerollTraitId) *
            _BITLEN_TRAIT_BOOST +
            _BOOSTER_OFFSET;

        _dna[tokenId] =
            (_dna[tokenId] & ~(_BITMASK_TRAIT_BOOST << traitShiftAmount)) |
            (selectedVal << traitShiftAmount);
        emit Boost(tokenId, boosterIdx, _dna[tokenId]);
    }

    /**
     * @dev Returns the corrected index of where rerollTraitId is located in the initial dna.
     * This is needed because Identity, Background, and Aura traits are not rerollable and thus the
     * rerollTraitId might not always match its location in the dna.
     */
    function _correctedRerollTraitId(
        uint256 _rerollTraitId
    ) internal pure returns (uint256) {
        if (_rerollTraitId < 3) return _rerollTraitId;
        return _rerollTraitId + 2;
    }

    /**
     * @dev Makes a pseudo-random number. Although there is some room for the block.timestamp to be
     * manipulated by miners, the random number used here is not used to determine something with high
     * impact such as determining a lottery winner.
     *
     * Implementing a more secure random number generator would lead to a worse reroll experience.
     */
    function _randomNumber() internal returns (uint256) {
        return
            uint256(
                keccak256(
                    abi.encodePacked(block.timestamp, block.prevrandao, ++_seed)
                )
            );
    }

    error BoostingInactive();
    error InvalidBoostIdx();
    error NoBoosterAtIdx();
    error NotDnaInjector();
    error NotEOA();
    error NotTokenOwner();
    error RerollInactive();
    error TraitNotRerollable();
    error TraitNotOnToken();
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 3 of 5 : 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 4 of 5 : ERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721A.sol';

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _tokenApprovals[tokenId].value;
    }

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom}
     * for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _operatorApprovals[_msgSenderERC721A()][operator] = approved;
        emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
    }

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

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted. See {_mint}.
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return
            _startTokenId() <= tokenId &&
            tokenId < _currentIndex && // If within bounds,
            _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
    }

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

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

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

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     * by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public payable virtual override {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

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

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

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

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

        _beforeTokenTransfers(from, to, tokenId, 1);

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token
     * by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public payable virtual override {
        transferFrom(from, to, tokenId);
        if (to.code.length != 0)
            if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
                revert TransferToNonERC721ReceiverImplementer();
            }
    }

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

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

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

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

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

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

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

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

            uint256 toMasked;
            uint256 end = startTokenId + quantity;

            // Use assembly to loop and emit the `Transfer` event for gas savings.
            // The duplicated `log4` removes an extra check and reduces stack juggling.
            // The assembly, together with the surrounding Solidity code, have been
            // delicately arranged to nudge the compiler into producing optimized opcodes.
            assembly {
                // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
                toMasked := and(to, _BITMASK_ADDRESS)
                // Emit the `Transfer` event.
                log4(
                    0, // Start of data (0, since no data).
                    0, // End of data (0, since no data).
                    _TRANSFER_EVENT_SIGNATURE, // Signature.
                    0, // `address(0)`.
                    toMasked, // `to`.
                    startTokenId // `tokenId`.
                )

                // The `iszero(eq(,))` check ensures that large values of `quantity`
                // that overflows uint256 will make the loop run out of gas.
                // The compiler will optimize the `iszero` away for performance.
                for {
                    let tokenId := add(startTokenId, 1)
                } iszero(eq(tokenId, end)) {
                    tokenId := add(tokenId, 1)
                } {
                    // Emit the `Transfer` event. Similar to above.
                    log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
                }
            }
            if (toMasked == 0) revert MintToZeroAddress();

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

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

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

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

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

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

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

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

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

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

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

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

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

        address from = address(uint160(prevOwnershipPacked));

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Called during each token transfer to set the 24bit `extraData` field.
     * Intended to be overridden by the cosumer contract.
     *
     * `previousExtraData` - the value of `extraData` before transfer.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _extraData(
        address from,
        address to,
        uint24 previousExtraData
    ) internal view virtual returns (uint24) {}

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

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

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

    /**
     * @dev Converts a uint256 to its ASCII string decimal representation.
     */
    function _toString(uint256 value) internal pure virtual returns (string memory str) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but
            // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
            // We will need 1 word for the trailing zeros padding, 1 word for the length,
            // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
            let m := add(mload(0x40), 0xa0)
            // Update the free memory pointer to allocate.
            mstore(0x40, m)
            // Assign the `str` to the end.
            str := sub(m, 0x20)
            // Zeroize the slot after the string.
            mstore(str, 0)

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

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

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

File 5 of 5 : IERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"BoostingInactive","type":"error"},{"inputs":[],"name":"InvalidBoostIdx","type":"error"},{"inputs":[],"name":"NoBoosterAtIdx","type":"error"},{"inputs":[],"name":"NotDnaInjector","type":"error"},{"inputs":[],"name":"NotEOA","type":"error"},{"inputs":[],"name":"NotTokenOwner","type":"error"},{"inputs":[],"name":"RerollInactive","type":"error"},{"inputs":[],"name":"TraitNotOnToken","type":"error"},{"inputs":[],"name":"TraitNotRerollable","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boosterId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenDna","type":"uint256"}],"name":"Boost","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"traitId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenDna","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boosterVal","type":"uint256"}],"name":"Bought","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"},{"inputs":[],"name":"ARMORY_V1_PROVENANCE_HASH","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"AUCTION_PROVENANCE_HASH","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINT_PROVENANCE_HASH","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKEN_CONTRACT","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"activeBooster","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"boosterIdx","type":"uint256"}],"name":"boost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"boostingActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dnaInjectorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dnaTranslatorCodeHash","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenDna","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"dna","type":"uint256[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"injectDna","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"numBoosts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"rerollTraitId","type":"uint256"}],"name":"reroll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rerollActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"active","type":"bool"}],"name":"setBoostingActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"dnaInjector","type":"address"}],"name":"setDnaInjector","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"codeHash","type":"string"}],"name":"setDnaTranslatorCodeHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"updatedNumBoosts","type":"uint256"}],"name":"setNumBoosts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"active","type":"bool"}],"name":"setRerollActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"setRerollToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"traitId","type":"uint256"},{"internalType":"bool","name":"rerollable","type":"bool"}],"name":"setTraitIdRerollable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"traitIdRerollable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"utilityAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"utilityTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a060405234801561001057600080fd5b506040516114af3803806114af83398101604081905261002f91610099565b61003833610049565b6001600160a01b03166080526100c9565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156100ab57600080fd5b81516001600160a01b03811681146100c257600080fd5b9392505050565b6080516113bd6100f26000396000818161027a015281816104ca015261082201526113bd6000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80637b62b73f116100f9578063d6d214f911610097578063eeb2ba8011610071578063eeb2ba80146103c5578063f29b2239146103cd578063f2fde38b146103e0578063f9d0362f146103f357600080fd5b8063d6d214f91461038b578063e46c8e5c1461039e578063eb565dba146103b157600080fd5b80638da5cb5b116100d35780638da5cb5b1461034c5780639c3048dd1461035d578063b3e8c9f114610370578063b60c18571461037857600080fd5b80637b62b73f1461031b578063813dcfad1461032457806382f25b181461032c57600080fd5b806336339388116101665780634cd351d3116101405780634cd351d3146102da578063562d0b21146102ed5780635bbf68c714610300578063715018a61461031357600080fd5b8063363393881461027557806340be7bec146102b45780634b943fee146102c757600080fd5b806318f309b91161019757806318f309b9146102395780631e6f67091461024e5780632f9f63221461026257600080fd5b80630599f113146101be5780631642ac1c146101f157806316cedd7314610206575b600080fd5b6101de6101cc366004610dd6565b60009081526008602052604090205490565b6040519081526020015b60405180910390f35b6101f96103fc565b6040516101e89190610def565b610229610214366004610dd6565b60066020526000908152604090205460ff1681565b60405190151581526020016101e8565b61024c610247366004610e52565b610418565b005b60055461022990600160a81b900460ff1681565b61024c610270366004610ebd565b61044f565b61029c7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016101e8565b61024c6102c2366004610f52565b610467565b61024c6102d5366004610f89565b6106d5565b61024c6102e8366004610fb5565b6106fd565b60055461029c906001600160a01b031681565b61024c61030e366004610f52565b61073e565b61024c610a0d565b6101de60045481565b6101f9610a21565b6101de61033a366004610dd6565b60096020526000908152604090205481565b6000546001600160a01b031661029c565b61024c61036b366004610fb5565b610a3d565b6101f9610a7e565b61024c610386366004610dd6565b610b0c565b61024c610399366004611050565b610b19565b61024c6103ac3660046110b4565b610bc3565b60055461022990600160a01b900460ff1681565b6101f9610bfe565b60035461029c906001600160a01b031681565b61024c6103ee366004610e52565b610c1a565b6101de60025481565b6040518060600160405280604081526020016112c86040913981565b610420610caf565b6005805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b610457610caf565b60016104638282611168565b5050565b600554600160a81b900460ff166104aa576040517f0a2fe31d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040516331a9108f60e11b81526004810183905233906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa158015610511573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105359190611228565b6001600160a01b03161461055c576040516359dc379f60e01b815260040160405180910390fd5b600082815260096020526040812054908190036105a5576040517f9cb99d3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526009602052604081205560025482106105ef576040517fff6e61fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006105fe600161040061125b565b600461060b600a8661126e565b6106159190611285565b83901c16600190811b8117915060009061063090601061125b565b8316905060006080600b61064384610d09565b61064d919061126e565b6106579190611285565b905082811b8161066a600161080061125b565b6000898152600860205260409081902080549290931b19919091169290921790819055905187917fc660fd3b205f791a73a3455e6197bca3eb8c766ad6dcb0825df6509e62592f18916106c591898252602082015260400190565b60405180910390a2505050505050565b6106dd610caf565b600091825260066020526040909120805460ff1916911515919091179055565b610705610caf565b60058054911515600160a01b027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b600554600160a01b900460ff16610781576040517fbbe450b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3332146107ba576040517fba092d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008181526006602052604090205460ff16610802576040517fa88013c000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040516331a9108f60e11b81526004810183905233906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa158015610869573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088d9190611228565b6001600160a01b0316146108b4576040516359dc379f60e01b815260040160405180910390fd5b600354600480546040517f8c6eafde00000000000000000000000000000000000000000000000000000000815233928101929092526024820152600160448201526001600160a01b0390911690638c6eafde90606401600060405180830381600087803b15801561092457600080fd5b505af1158015610938573d6000803e3d6000fd5b50505050600361094782610d09565b901b60ff901b60086000848152602001908152602001600020541660000361099b576040517f7743cafa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060046109a7610d29565b60008581526009602090815260408083209390941b8617928390556008815290839020548351908152908101829052909250839185917f47abb63d521dd2e26fcdd6dd304df0a109af421045f9cf9d53a6d1b7f5c16376910160405180910390a3505050565b610a15610caf565b610a1f6000610d79565b565b6040518060600160405280604081526020016113486040913981565b610a45610caf565b60058054911515600160a81b027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff909216919091179055565b60018054610a8b906110e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610ab7906110e0565b8015610b045780601f10610ad957610100808354040283529160200191610b04565b820191906000526020600020905b815481529060010190602001808311610ae757829003601f168201915b505050505081565b610b14610caf565b600255565b6005546001600160a01b03163314610b5d576040517f52b5d46f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8151811015610bbe57828181518110610b7b57610b7b611298565b602002602001015160086000848481518110610b9957610b99611298565b6020026020010151815260200190815260200160002081905550806001019050610b60565b505050565b610bcb610caf565b6003805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039390931692909217909155600455565b6040518060600160405280604081526020016113086040913981565b610c22610caf565b6001600160a01b038116610ca35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610cac81610d79565b50565b6000546001600160a01b03163314610a1f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9a565b60006003821015610d18575090565b610d23826002611285565b92915050565b60004244600760008154610d3c906112ae565b918290555060408051602081019490945283019190915260608201526080016040516020818303038152906040528051906020012060001c905090565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215610de857600080fd5b5035919050565b600060208083528351808285015260005b81811015610e1c57858101830151858201604001528201610e00565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b0381168114610cac57600080fd5b600060208284031215610e6457600080fd5b8135610e6f81610e3d565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610eb557610eb5610e76565b604052919050565b60006020808385031215610ed057600080fd5b823567ffffffffffffffff80821115610ee857600080fd5b818501915085601f830112610efc57600080fd5b813581811115610f0e57610f0e610e76565b610f20601f8201601f19168501610e8c565b91508082528684828501011115610f3657600080fd5b8084840185840137600090820190930192909252509392505050565b60008060408385031215610f6557600080fd5b50508035926020909101359150565b80358015158114610f8457600080fd5b919050565b60008060408385031215610f9c57600080fd5b82359150610fac60208401610f74565b90509250929050565b600060208284031215610fc757600080fd5b610e6f82610f74565b600082601f830112610fe157600080fd5b8135602067ffffffffffffffff821115610ffd57610ffd610e76565b8160051b61100c828201610e8c565b928352848101820192828101908785111561102657600080fd5b83870192505b848310156110455782358252918301919083019061102c565b979650505050505050565b6000806040838503121561106357600080fd5b823567ffffffffffffffff8082111561107b57600080fd5b61108786838701610fd0565b9350602085013591508082111561109d57600080fd5b506110aa85828601610fd0565b9150509250929050565b600080604083850312156110c757600080fd5b82356110d281610e3d565b946020939093013593505050565b600181811c908216806110f457607f821691505b60208210810361111457634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610bbe57600081815260208120601f850160051c810160208610156111415750805b601f850160051c820191505b818110156111605782815560010161114d565b505050505050565b815167ffffffffffffffff81111561118257611182610e76565b6111968161119084546110e0565b8461111a565b602080601f8311600181146111cb57600084156111b35750858301515b600019600386901b1c1916600185901b178555611160565b600085815260208120601f198616915b828110156111fa578886015182559484019460019091019084016111db565b50858210156112185787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006020828403121561123a57600080fd5b8151610e6f81610e3d565b634e487b7160e01b600052601160045260246000fd5b81810381811115610d2357610d23611245565b8082028115828204841417610d2357610d23611245565b80820180821115610d2357610d23611245565b634e487b7160e01b600052603260045260246000fd5b6000600182016112c0576112c0611245565b506001019056fe303337323236623231363336333736303031646266643232663532643164643732383435656661393631336261663531613661303131616337333162323332373630613733316331323539633132633430663665616665653035383233356362353465616564373435393363373430316233353638616633306237346336356265623863383839363961346237373664373537646539363261313934663562346666616161646239393165636662623234643830366337626336333937643330a2646970667358221220bad027d953ee1854a7dd255fbdfe5885da696904ae69d11108babb29e5cd81c064736f6c63430008120033000000000000000000000000231d3559aa848bf10366fb9868590f01d34bf240

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101b95760003560e01c80637b62b73f116100f9578063d6d214f911610097578063eeb2ba8011610071578063eeb2ba80146103c5578063f29b2239146103cd578063f2fde38b146103e0578063f9d0362f146103f357600080fd5b8063d6d214f91461038b578063e46c8e5c1461039e578063eb565dba146103b157600080fd5b80638da5cb5b116100d35780638da5cb5b1461034c5780639c3048dd1461035d578063b3e8c9f114610370578063b60c18571461037857600080fd5b80637b62b73f1461031b578063813dcfad1461032457806382f25b181461032c57600080fd5b806336339388116101665780634cd351d3116101405780634cd351d3146102da578063562d0b21146102ed5780635bbf68c714610300578063715018a61461031357600080fd5b8063363393881461027557806340be7bec146102b45780634b943fee146102c757600080fd5b806318f309b91161019757806318f309b9146102395780631e6f67091461024e5780632f9f63221461026257600080fd5b80630599f113146101be5780631642ac1c146101f157806316cedd7314610206575b600080fd5b6101de6101cc366004610dd6565b60009081526008602052604090205490565b6040519081526020015b60405180910390f35b6101f96103fc565b6040516101e89190610def565b610229610214366004610dd6565b60066020526000908152604090205460ff1681565b60405190151581526020016101e8565b61024c610247366004610e52565b610418565b005b60055461022990600160a81b900460ff1681565b61024c610270366004610ebd565b61044f565b61029c7f000000000000000000000000231d3559aa848bf10366fb9868590f01d34bf24081565b6040516001600160a01b0390911681526020016101e8565b61024c6102c2366004610f52565b610467565b61024c6102d5366004610f89565b6106d5565b61024c6102e8366004610fb5565b6106fd565b60055461029c906001600160a01b031681565b61024c61030e366004610f52565b61073e565b61024c610a0d565b6101de60045481565b6101f9610a21565b6101de61033a366004610dd6565b60096020526000908152604090205481565b6000546001600160a01b031661029c565b61024c61036b366004610fb5565b610a3d565b6101f9610a7e565b61024c610386366004610dd6565b610b0c565b61024c610399366004611050565b610b19565b61024c6103ac3660046110b4565b610bc3565b60055461022990600160a01b900460ff1681565b6101f9610bfe565b60035461029c906001600160a01b031681565b61024c6103ee366004610e52565b610c1a565b6101de60025481565b6040518060600160405280604081526020016112c86040913981565b610420610caf565b6005805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b610457610caf565b60016104638282611168565b5050565b600554600160a81b900460ff166104aa576040517f0a2fe31d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040516331a9108f60e11b81526004810183905233906001600160a01b037f000000000000000000000000231d3559aa848bf10366fb9868590f01d34bf2401690636352211e90602401602060405180830381865afa158015610511573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105359190611228565b6001600160a01b03161461055c576040516359dc379f60e01b815260040160405180910390fd5b600082815260096020526040812054908190036105a5576040517f9cb99d3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008381526009602052604081205560025482106105ef576040517fff6e61fc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006105fe600161040061125b565b600461060b600a8661126e565b6106159190611285565b83901c16600190811b8117915060009061063090601061125b565b8316905060006080600b61064384610d09565b61064d919061126e565b6106579190611285565b905082811b8161066a600161080061125b565b6000898152600860205260409081902080549290931b19919091169290921790819055905187917fc660fd3b205f791a73a3455e6197bca3eb8c766ad6dcb0825df6509e62592f18916106c591898252602082015260400190565b60405180910390a2505050505050565b6106dd610caf565b600091825260066020526040909120805460ff1916911515919091179055565b610705610caf565b60058054911515600160a01b027fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff909216919091179055565b600554600160a01b900460ff16610781576040517fbbe450b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3332146107ba576040517fba092d1600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008181526006602052604090205460ff16610802576040517fa88013c000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040516331a9108f60e11b81526004810183905233906001600160a01b037f000000000000000000000000231d3559aa848bf10366fb9868590f01d34bf2401690636352211e90602401602060405180830381865afa158015610869573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088d9190611228565b6001600160a01b0316146108b4576040516359dc379f60e01b815260040160405180910390fd5b600354600480546040517f8c6eafde00000000000000000000000000000000000000000000000000000000815233928101929092526024820152600160448201526001600160a01b0390911690638c6eafde90606401600060405180830381600087803b15801561092457600080fd5b505af1158015610938573d6000803e3d6000fd5b50505050600361094782610d09565b901b60ff901b60086000848152602001908152602001600020541660000361099b576040517f7743cafa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600060046109a7610d29565b60008581526009602090815260408083209390941b8617928390556008815290839020548351908152908101829052909250839185917f47abb63d521dd2e26fcdd6dd304df0a109af421045f9cf9d53a6d1b7f5c16376910160405180910390a3505050565b610a15610caf565b610a1f6000610d79565b565b6040518060600160405280604081526020016113486040913981565b610a45610caf565b60058054911515600160a81b027fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff909216919091179055565b60018054610a8b906110e0565b80601f0160208091040260200160405190810160405280929190818152602001828054610ab7906110e0565b8015610b045780601f10610ad957610100808354040283529160200191610b04565b820191906000526020600020905b815481529060010190602001808311610ae757829003601f168201915b505050505081565b610b14610caf565b600255565b6005546001600160a01b03163314610b5d576040517f52b5d46f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b8151811015610bbe57828181518110610b7b57610b7b611298565b602002602001015160086000848481518110610b9957610b99611298565b6020026020010151815260200190815260200160002081905550806001019050610b60565b505050565b610bcb610caf565b6003805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b039390931692909217909155600455565b6040518060600160405280604081526020016113086040913981565b610c22610caf565b6001600160a01b038116610ca35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b610cac81610d79565b50565b6000546001600160a01b03163314610a1f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c9a565b60006003821015610d18575090565b610d23826002611285565b92915050565b60004244600760008154610d3c906112ae565b918290555060408051602081019490945283019190915260608201526080016040516020818303038152906040528051906020012060001c905090565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215610de857600080fd5b5035919050565b600060208083528351808285015260005b81811015610e1c57858101830151858201604001528201610e00565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b0381168114610cac57600080fd5b600060208284031215610e6457600080fd5b8135610e6f81610e3d565b9392505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715610eb557610eb5610e76565b604052919050565b60006020808385031215610ed057600080fd5b823567ffffffffffffffff80821115610ee857600080fd5b818501915085601f830112610efc57600080fd5b813581811115610f0e57610f0e610e76565b610f20601f8201601f19168501610e8c565b91508082528684828501011115610f3657600080fd5b8084840185840137600090820190930192909252509392505050565b60008060408385031215610f6557600080fd5b50508035926020909101359150565b80358015158114610f8457600080fd5b919050565b60008060408385031215610f9c57600080fd5b82359150610fac60208401610f74565b90509250929050565b600060208284031215610fc757600080fd5b610e6f82610f74565b600082601f830112610fe157600080fd5b8135602067ffffffffffffffff821115610ffd57610ffd610e76565b8160051b61100c828201610e8c565b928352848101820192828101908785111561102657600080fd5b83870192505b848310156110455782358252918301919083019061102c565b979650505050505050565b6000806040838503121561106357600080fd5b823567ffffffffffffffff8082111561107b57600080fd5b61108786838701610fd0565b9350602085013591508082111561109d57600080fd5b506110aa85828601610fd0565b9150509250929050565b600080604083850312156110c757600080fd5b82356110d281610e3d565b946020939093013593505050565b600181811c908216806110f457607f821691505b60208210810361111457634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610bbe57600081815260208120601f850160051c810160208610156111415750805b601f850160051c820191505b818110156111605782815560010161114d565b505050505050565b815167ffffffffffffffff81111561118257611182610e76565b6111968161119084546110e0565b8461111a565b602080601f8311600181146111cb57600084156111b35750858301515b600019600386901b1c1916600185901b178555611160565b600085815260208120601f198616915b828110156111fa578886015182559484019460019091019084016111db565b50858210156112185787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60006020828403121561123a57600080fd5b8151610e6f81610e3d565b634e487b7160e01b600052601160045260246000fd5b81810381811115610d2357610d23611245565b8082028115828204841417610d2357610d23611245565b80820180821115610d2357610d23611245565b634e487b7160e01b600052603260045260246000fd5b6000600182016112c0576112c0611245565b506001019056fe303337323236623231363336333736303031646266643232663532643164643732383435656661393631336261663531613661303131616337333162323332373630613733316331323539633132633430663665616665653035383233356362353465616564373435393363373430316233353638616633306237346336356265623863383839363961346237373664373537646539363261313934663562346666616161646239393165636662623234643830366337626336333937643330a2646970667358221220bad027d953ee1854a7dd255fbdfe5885da696904ae69d11108babb29e5cd81c064736f6c63430008120033

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

000000000000000000000000231d3559aa848bf10366fb9868590f01d34bf240

-----Decoded View---------------
Arg [0] : tokenAddress (address): 0x231d3559aa848Bf10366fB9868590F01d34bF240

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000231d3559aa848bf10366fb9868590f01d34bf240


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

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