ETH Price: $2,575.45 (-2.11%)

Transaction Decoder

Block:
16174080 at Dec-13-2022 06:45:59 AM +UTC
Transaction Fee:
0.015397620395055202 ETH $39.66
Gas Used:
1,244,462 Gas / 12.372913271 Gwei

Account State Difference:

  Address   Before After State Difference Code
0x3bAa3E3f...932EF1bDD
0 Eth
Nonce: 0
0 Eth
Nonce: 1
From: 0 To: 34088596409526344608972867909250077025764775911546934272324448810498272238333857282087726173912994976489877198202940956166547401804430614561997684873003323031457738504584980847525705628228277081134632466475903332907463199734801383209829599183148880673698669238376316956831147655110931776096682192537886331983928988846975271927632918644445719482424041183441982916191271193522035459069619624655018696533273661898939800235243135111944117319679742195141854779071320596763301756019484656746648730976812202750550642137199426704149955624085237366953396515526760057687086494829615107007588623843204462273816276597063133460821994446180341148772109518874306264070530443023323849967742681251286859828736860928974793035529779324207597074457763357943491926401999502417801998980503458198470627906577670539950489824180603295643556902052700595012646844606131517772770677968827499471213717565735565679744424147636563760863266296225726181981100140095774884790588687666089161143674008528107311771125187420153300896141359295438609839238528074667764522205905078855020113073190341218866096302569156866793239561643235160301672287549196619530537921174808513926373649045683041977760910021281585709080671796458897397533506134078306735350117105346467900403292410500640003872497123466507680905887609873372360800779069595082293684170010575052371936323238893177017049071615307445233945251127731401648242440189140689206807898124028861637168818888189278359215275271405845148387460029112679941481945294969725948216766983512899807620330908055832322568238821107154573516734661240321887051245917958632790015081317584442473712784062071472469687854253278950275853131599420883607250412667420433864858453637679944908416727336117852102021862306804446491701396673406484919308035996593165192468048832837166209798709384581609487493729772884096342911681069052483755609318746984795348010986294680479409598369657408377658411594917179382881872397073889040694609225035408100595145605876483518368590631386263676234030367628376952250451465394465282458591311048156400534863060325612141035526148630872566474517822322465320180976486888426277679942844712043246553786374636368717557261102698315233174737766202061692037027646850889159760214934152282165347583631110763991530648441518318823968970403687529885737646522111760653666075719378750387196456882615152025655197511097847968541212150206656413931934574675674093174611981678643224746074738702740356790487619055208248251904766288518987155632261978977070790078894818769645407784730215940843095604755373707843808303265346338923329125003766669961714977840097782781314695223440994354529015144070286559148017040409894845745888208548053135430261965746165875388552315414954870567349600671257579448279908303288182071329352401414900563953242101717514579317647223084529086725682064093888172107356444170655927945943029271877736377658742020143993458960160121549198243694047878265733346315369424973903899988789362053886253567558597856743869513455862017110971175907696185612773996130972199972455253689857569369512233947999133871219708350194357440433235086987113150124948770377938317739234854894605872114463507048941149421041707930168627677973024170517757892663194206463119170869885536091611728817143482982342359313479945235790061296117342815087616320466320853236102185200537941415213895086142193791985565187180083013712646852053852907775745024813814252561011572054288528646452913289154786480915786483192030658624827720924334981409855168387429212519206226918761813874442108147187009923204342500252513606460591440014203623881565804542245860122821987924892631292798593172746010687671267234450264883017571248341493664226424721031358254583489296208669072831097952498425452916935898869376307212867844520753034660070100493670730414470005127913373187149671213459634232880553081452544825974702962221166141821770501306550421443628878150019025218889990585253203604844964889762338372732984019522000600783398997723590500179446522875377869010955667294499974127693680752234786523248908759582990242289638070416057859566036694495559326031478263850022313444911196443380604513381051423060938773518796001545861571085774966038533492739856608983542106162051771040901978440241397291612726984992842263784791257556254629660505387697806644421926361346955564281712801749940674119171049426542987505801014811775492836079308586518991333727672778007265919709194059374160808169329140301416081571593507043999818418384546050359769954936684791532240017754793793731933198137680914016388563497751256947340720094645981766095280638234437550415126678885665206941211209569046300020206614638185540887946003069926505041981576960313291536243230156229184884945385878528416490640452232841357969442162270143846052558954365887306443657572379173446802647942510408171394282372744953483364375658383435688594141139458305919817865034600160254952711262593653803582757429002922555556331811257174311690945363392718405099091840467405461300253630843290532431738460603024731251240080872762012731499578039823701528055778790771513657627788883689348972070154458065414202691066115488060525814039141971107834070371210375643203204529426640158945346768283443240104496311060786905239377110861711489173858219465755805642564981405224276418486774405550550896051175271825456991344245492877251029965885612452217408695647953265646408371789811617736304410255205363655156615693252338245548376700408344424498510411573267968991577690596268449964762726082376903943577689258572550787220125040073298274668165176234715034941270831066626235790072535851732158609714533682062429637833849205390370976810449226039250076165888379777919138412246057948491326778654188811147345701069937281040044329183147449854659229677776720330562084176889227865682603573983342857763259009716270709248813460234262954242263872637487818575447067448971303479072986100670473776526434292341753525397694525512906614842203123798282080324487474267378663924278445367313741865733786187087183641624708073924308465878891650673008815466908363893831238184218290541308832088096312924138960842296272275235478556464865092007704780880981141871393923555781161616808743825054202308181657515926141712620948561806195445049707544094311691810197281641503147743166165851565316059809632502481591897044529277347382328844258673145983348124635385850511094588227084120856290975591851908103516303077995756093062791446244903023652467174170210336312649008761550686695014413529395733245345225960415127561731028356760123224772257790115485799411100743302405447908819161034181683819488635222848591852687853224050175061631639423093477459442416101456317366664734135709243440774651255362932453107756331076293291076340529546934966229005276619014318173316308577439036857615744547111837891076553130946163894847710028430689344441063220706258852295323640602950486225438756780283397189335434738954590799607435984947721358977974902962075084420553137005404546158863307763683716898966896352620964283496224779245670187695442640452177442315173788250545117150519788869623378380249917503949074606183247858778489375082194397454194769704830002978940222889698813956965066239314506577571621319867147435931183651096135050313006470712245916230819624888205915552181173734455933657595123920470382331651413031305368037354616333331090282026467274712597660484083350542390848877187279064199725688802913614934355012672477840286186589472199233334533472751075787772845620468045364316757461168581918316305880244756652944658585370986045763171278173008712664123767590520066890420094615234836846664143226957693659770749839671354134557069395966298834774497419927399668024026667490841150153248035945620337227045477820692108835826554238807969970168459143040777288352769827564281755153957697346674476294253279534968786323328634161836635424648580770066707613898708858258024286486395885242338304375617310909692342962133319448683417132202349982785985616175774412828113274380756147560158929433605604247528638189948201030126981627042070177850252534456510120031046803139897131960667851736482466049593335120925341857644447423763013737499374797653960339170339223269840030993054070929034116029537330985530115014741500121909493754641378813088822918294228367822073388778752346846969471372752225416926739309192730598750927524951368843102610329397595149628109999319940497698568973487526378522143771141762724347465054474853521720088732042517572911688661344277253704555544394571465934730871233429553139303366470373365559712728953041784231660448523031418207996488582708523698103328315247878471065495240899823673849681009696467441985863122177453053965194862422735631900889296949633900281117893619606434926482340343644058522536390172582154184698006698502756119955553689353961200701050666027630526861081161451479416130457580368128598782116673678934758155614308444223332552419776623572768656646021964941713794341020095219472224679511365133329773004400479519186848168182452412361125338122098959551572276826533563600781863832623746691934396277204991806909378634016733170560334346152126375939583714594833794399889404919908161032579258972868743118419283648252800964877137900528618364759997811985005510576195668726470822751942873800500505906973237866549908512811291455944864980869426584779290896770941177412183220707381751087309708071294312479768698216496096586259090122692775691203956470474505062770479087241175946222638350907140651311087247287234577292615528321296887181270977492465955809619554680141456242956020860457251157895537060471363436062233195877790122170559623740435405823671823067310273690320592580738691388678921891695409219222595498825058418056745050202236301937366027145670402910864587880041122153369939341710087234266376586293954829045603866541258840754074950714023331858745029138720629436610720852750930308343513915813099481515913929356917722199000492112892958280660277739097244578903672830300939998439529143150355528510656346117691591059487368041771985149952446433384177807014417060798595426246538581432376697215883521414846159491848279812326688871538564286052654559075704125128950215691784849502076623891709887197278252344377056981727418267054256918014545701806011776071933975977504528417778101207364471747940746207249874340576527843912975096994234123534940021095122111044521495290919838862296499943305519823559100566080365721551479381009192742017051767918174027629247217742572194381066282195693675502863866208745360469099430199823824617131032114170650359056870845761440823811488343066033716724856822978460437762362807980989183546389432042946106801282705585628659609834322815141063044524415271877635738988656881657949543128962039236969775001987678147576964980013117442742488961292513722567321228746590609385832925078682658054220297406345580644605325098157283369779222043613828847161423674425943890673821223068406263162627875050067262876867520369067706403652260034784809257615422379032565420256491701414761872646246665870091226163499849104170053367027573683560732011815794632237112771330662798666530566195174348597410245942701283529392758137167367217088923733772774671876586479481704096022966801230709038762521340197967702872974174510025590254890974462680329948126583972740208978084110542253254355764271149344681492924941678495447046860013278254024844083093305295525797056704105501544764832609404227342097493751179642893788177208825908439483384951304626403097053761617008237900395828129643059217287820795768724195849670278150300738991171658685828544330204091658415659290335850953984754113829903094184360048022696491671901166098374984899545687743493734922762820834358364402891296795532864007517045674632937307920618721468072325979902810325671043860070451
0x3bd214B3...b12f25fc8
(On-Chain Birbs: Deployer)
0.049232 Eth
Nonce: 0
0.033834379604944798 Eth
Nonce: 1
0.015397620395055202
(Fee Recipient: 0xc17e...e17)
50.607558522053504764 Eth50.607813650865748148 Eth0.000255128812243384

Execution Trace

OnChainBirbs.610d0560( )
/**

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

// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


contract OnChainBirbs is IERC721A { 

    address private _owner;
    function owner() public view returns(address){
        return _owner;
    }

    modifier onlyOwner() { 
        require(_owner==msg.sender);
        _; 
    }

    uint256 public constant MAX_SUPPLY = 3333;
    uint256 public MAX_FREE = 3333;
    uint256 public MAX_FREE_PER_WALLET = 1;
    uint256 public COST = 0.001 ether;

    string private constant _name = "On-Chain Birbs";
    string private constant _symbol = "OCB";
    string private _baseURI = "bafybeiep5h37oo5uwc4impqjpkuitrtpjo7gdipladyjxfn74646kxvpcq";

    constructor() {
        _owner = msg.sender;
    }

    function mint(uint256 amount) external payable{
        address _caller = _msgSenderERC721A();

        require(totalSupply() + amount <= MAX_SUPPLY, "SoldOut");
        require(amount*COST <= msg.value, "Value to Low");

        _mint(_caller, amount);
    }

    function freeMint() external{
        address _caller = _msgSenderERC721A();
        uint256 amount = 1;

        require(totalSupply() + amount <= MAX_FREE, "Freemint SoldOut");
        require(amount + _numberMinted(_caller) <= MAX_FREE_PER_WALLET, "Max per Wallet");

        _mint(_caller, amount);
    }

    // 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 tokenId of the next token to be minted.
    uint256 private _currentIndex = 0;

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


    // 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`
    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 => address) private _tokenApprovals;

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


    function setData(string memory _base) external onlyOwner{
        _baseURI = _base;
    }

    function setConfig(uint256 _MAX_FREE_PER_WALLET, uint256 _COST, uint256 _MAX_FREE) external onlyOwner{
        MAX_FREE_PER_WALLET = _MAX_FREE_PER_WALLET;
        COST = _COST;
        MAX_FREE = _MAX_FREE;
    }

    /**
     * @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 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 override returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than `_currentIndex - _startTokenId()` times.
        unchecked {
            return _currentIndex - _startTokenId();
        }
    }

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


    /**
     * @dev See {IERC165-supportsInterface}.
     */
    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: 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.
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view override returns (uint256) {
        if (_addressToUint256(owner) == 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 auxillary 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);
    }

    /**
     * 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 ownership that has an address and is not burned
                        // before an ownership that does not have an address and is not burned.
                        // Hence, curr will not underflow.
                        //
                        // We can directly compare the packed value.
                        // If the address is zero, packed is zero.
                        while (packed == 0) {
                            packed = _packedOwnerships[--curr];
                        }
                        return packed;
                    }
                }
        }
        revert OwnerQueryForNonexistentToken();
    }

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

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

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

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

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view override returns (address) {
        return address(uint160(_packedOwnershipOf(tokenId)));
    }

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

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

    
    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("ipfs://", baseURI, "/", _toString(tokenId), ".json")) : "";
    }

    /**
     * @dev Casts the address to uint256 without masking.
     */
    function _addressToUint256(address value) private pure returns (uint256 result) {
        assembly {
            result := value
        }
    }

    /**
     * @dev Casts the boolean to uint256 without branching.
     */
    function _boolToUint256(bool value) private pure returns (uint256 result) {
        assembly {
            result := value
        }
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public override {
        address owner = address(uint160(_packedOwnershipOf(tokenId)));
        if (to == owner) revert();

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

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

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view override returns (address) {
        if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        if (operator == _msgSenderERC721A()) revert ApproveToCaller();

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

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

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

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

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

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     */
    function _exists(uint256 tokenId) internal view returns (bool) {
        return
            _startTokenId() <= tokenId &&
            tokenId < _currentIndex;
    }

  

    /**
     * @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.
     */
    function _mint(address to, uint256 quantity) internal {
        uint256 startTokenId = _currentIndex;
        if (_addressToUint256(to) == 0) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();


        // Overflows are incredibly unrealistic.
        // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
        // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the balance and number minted.
            _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] =
                _addressToUint256(to) |
                (block.timestamp << BITPOS_START_TIMESTAMP) |
                (_boolToUint256(quantity == 1) << BITPOS_NEXT_INITIALIZED);

            uint256 updatedIndex = startTokenId;
            uint256 end = updatedIndex + quantity;

            do {
                emit Transfer(address(0), to, updatedIndex++);
            } while (updatedIndex < end);

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

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
            address from,
            address to,
            uint256 tokenId
            ) private {

        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

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

        address approvedAddress = _tokenApprovals[tokenId];

        bool isApprovedOrOwner = (_msgSenderERC721A() == from ||
                isApprovedForAll(from, _msgSenderERC721A()) ||
                approvedAddress == _msgSenderERC721A());

        if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();


        // Clear approvals from the previous owner.
        if (_addressToUint256(approvedAddress) != 0) {
            delete _tokenApprovals[tokenId];
        }

        // 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] =
                _addressToUint256(to) |
                (block.timestamp << BITPOS_START_TIMESTAMP) |
                BITMASK_NEXT_INITIALIZED;

            // 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 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 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 returns (string memory ptr) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), 
            // but we allocate 128 bytes to keep the free memory pointer 32-byte word aliged.
            // We will need 1 32-byte word to store the length, 
            // and 3 32-byte words to store a maximum of 78 digits. Total: 32 + 3 * 32 = 128.
            ptr := add(mload(0x40), 128)

         // Update the free memory pointer to allocate.
         mstore(0x40, ptr)

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

         // We write the string from the rightmost digit to the leftmost digit.
         // The following is essentially a do-while loop that also handles the zero case.
         // Costs a bit more than early returning for the zero case,
         // but cheaper in terms of deployment and overall runtime costs.
         for { 
             // Initialize and perform the first pass without check.
             let temp := value
                 // Move the pointer 1 byte leftwards to point to an empty character slot.
                 ptr := sub(ptr, 1)
                 // Write the character to the pointer. 48 is the ASCII index of '0'.
                 mstore8(ptr, add(48, mod(temp, 10)))
                 temp := div(temp, 10)
         } temp { 
             // Keep dividing `temp` until zero.
        temp := div(temp, 10)
         } { 
             // Body of the for loop.
        ptr := sub(ptr, 1)
         mstore8(ptr, add(48, mod(temp, 10)))
         }

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

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