ETH Price: $2,235.21 (+1.70%)

Transaction Decoder

Block:
15401047 at Aug-24-2022 05:19:20 AM +UTC
Transaction Fee:
0.01364611008666997 ETH $30.50
Gas Used:
2,226,770 Gas / 6.128208161 Gwei

Emitted Events:

115 MetaLamboz.OwnershipTransferred( previousOwner=0x00000000...000000000, newOwner=[Sender] 0x2f8d9a3a6871b6ddfa255aab3a2ac1da1b96452a )

Account State Difference:

  Address   Before After State Difference Code
0x261dFC09...a095895Cc
0 Eth
Nonce: 0
0 Eth
Nonce: 1
From: 0 To: 2220560254550331218007414465622833685314999391024338916332218676027781399715821947884900235115334509453326211886816555680499482945867000962192074205900300370970375012293236755287766575511182472478067449610629785351955834429349251498993291030820600580320689785085152572680248779064133073234779000480262757828572868184630243777274632131825493547160878533281383481919355232920884144530865853307194369153097283556072824615114487613909823084544746787151591635750257963765828872220772680392617658021695266459371048105392108646958270678128372391431561391684551900087461744343711701638214833227465856025705422623205752405809078645845775165674799369585546508870294167211379887691719709275574432370517772300510844748208778895651185641135755584613726868254419700847879412314358425733184748574949356553483372808927749893444971227983968970119470655385720721033443376574198264857178525186359216773296921664785187434368828554221280042033030523692282792310371258555813629185637365081209483677658939971350218083897480588369628198186677046126413151073458631848220716690542787877536012308739437500341562402420295205915693994732971767378272523298192805558352826031480325636436319486368357704127050016464997357900798228317039189548322552900510870324117344330351257705482780155318788269873872976120704263385190629955875961844691239672657127252211486032747229253594696373439571734115272744281596030020759234352254919503149973734318820247970975039017807953644218626655431534120266407351363529442094335197264700014579498338733821823623987452748352492432691130927758633892610418953031604879483112830352097308211345902508540468225652480191183224546065561107824343156056638966836732602718906826526677037864626235873001330744352817111810821874039499027303325561915644030209356104072650909795480164541712184571338777604480733144620865984149910912850482078256307888070214937861350762664456228819259923345586718705863265357422862812434760775449049430843803451013519353503410849783596137534205965818252794075266729942090619309906213806401958813670474423047056979029615691087516235734927345710298939919451259823055883625517910186053154513686649135896729102030433242431169454409984868175870699120429772455715317477673074348913883685174221222516556254268337398456674779225644447934182075446497986577036011995441204827527422988542740224941449958768038048383687882461927647667106305620102068189521936756821617316599218674578424815839395195036919683037955974786319097071020406204984141834822932952191885283813879905798103272782260360451803960552589774293882996002343838731321830513117050400522023592614450114000605489229313021671807491966934137077631460657960993092055376265754491209289621805352800712852614730132140889830209632100469381252060842025124878725750105907516738296529603338749977006720988800687216648159645603350485265082032288761471667200619150310784324476748619010830948952849533093991809480861167190956524766828246777915622102976363473590172626396348457641963635839599746963794143012265290845408776336154048000388348880780256478248161926700767702419210126930658173855623511885330178567909968680714047464877455611902500563930635559215221831238642282814890390447933495376964165957594782091674866829934684863852862500687934849021809199817218622244509505726743666487320877291711110367042942064338556346351171124647523380901784461301646063418777817973820274982730115140373501470943174948159121407434354556832801105983445332753454993856482988591409750997623326722371423187340617984577148440609574170537610040165386277353060901071957563629163834937320928233416674750877975911803348798722351232182884419064349797799025692876427097547685432626373831164560090199027299300605044739783566173901908349885493947497664836026232044746573402388459194595195025863787050984584369133222329266315675737791527269706508228724982257982660371367213537204701916306844334163975775500903055457284820996248323575820082063324546403299099035815237243545336023869645037555660560272139231476483460838314984192431643463289779186568369600043949821130680615771595174873594455460900101706439960712820399959482244397328143211668701687655345979074210739992119079125195297727224234225081253868697179190927021223175022516274342259010288304758023850200436835028413860846132514435542452911337238210241510899239707653086664296311102738767169945181589193023599152889107129897390139266950297429201444593361836680000026568650713713971495139957636496548288904491493306243814833237938695681228786717931961058758087606460311207139068902886955895771894132998992780043223599900386123046615784276059427888925271546529653832587011772766267074069391766438022531603247678840957223331930686377577925840956798165955296690872309028430545459745761360452062248713695955325001781971774014910588160369719337376267697840673157294589728272950745440072751455751019585880104701366273558756999991933800846028018583730364894408887554935938789102341741324171627026087525508831951363632597555121136878502487221552127380695861196237795025416526070464624818531224331987643647751132029391265102706235236420747829054833175552588212226473443212669897527443984884011290736675632157110093190455634359780893817435506969993538660074004958726395679564082797274066586838311240401647589924964204217385135511471929285289902439714356365153615808217255800010807206007125842002109900906401129622565632931581964763148558224950237162460221109798639641363555328314007737657996675684120911561734468327479303241064661850529882825582275922094319765922941134950127183306680036573980456067569914228822177683980992974501101398477895754990937898463304889741415679081342220928681819803717387497639545019367065690260972555848473170796484663552527243476325968692926539607510298504274611318970046397001572781612265157306797642922549808252682606093381089874061970327653536973062872580149346742730454562436536883926794351473104399685278707703110506466159415213934107624709600438459714284033515659452819294275505899729714548686187501320640247174260199212897656138581272462106685832341049498378699498555778830941735363016227755687820486694739733649452631714555906835208451718069429300187142611704046882273953972213138506776313814811250479336468238828371135970787218066541690464576000604551570065966786102330101457973609001129270467276632377296948082515406762056977199572983594983623719683192557380154285172249138011912695641133585099413624382940082816162478038870178325396128381337392173111943905264297020089718774997441950119627053884367518065541408091956177812951765195005712170560068329864568738355222816265543728733062454668669012026878931463365062647686666043463307981681862847803769142036871539339393002252957604071438282197132713808753968845434270045963565956520433561959302496874719300750056894780564100582756244273453132432312111635607193808120633089772732147874465535967478561211728446963768663083926141077585175024633187509452381309507564164069602605408103211555173425677051669044470733584121977206844877738377744726798239446792326946762206841191263016832638350332752649848041759627321395170756822192547961852381050747262733188882071691916241135898446314035642109423686521645721699336340730871064860559753670010999991046874680946713834899437301495228095387300756159472052732269045496657068344099215582596006980998233936551041961971101821782534816803325682116616899461197511405717359326754298754388947460858718769035435737448471796405398751287978575536814798537894065006505997762478091892099406529647343936598005371999118331505695946878327037245505736498715479802818808538702045616391256261144686301942420091189342644070804019841453935499526378832071518276190300040675305093155909489162089393664608211954220509510403571688485268202711394326857277354689919047077745126778964004765492850654752168361841973493696247573030569479894005208843332588723775312453477087245986316199505232744262281494904620469788754914520889186565917368623233592622758937395654563552615309540026141791812090549440362897080350923115253654290167814433107128824008649676131813635926000243091242664090499788501736351816063487901474299864483558672457111409573758270879267022789330228743019160046892531749557290958086222809070609238873532899446097685710080879762590193069392032291875580796777487602580327588862755280248875013821260919406051161143792348730637375292688551731695044436067430047361270209598952324385873928811073716426411812059416113678448179589985148921167221844459321463138097725195119596514598029660218421721254018376579608651021758344885075433693181468255945322638040935998078921026690371445287836626931643531914947820618785657549573811020972931768921735630048357813772147176506452911420898174544181381679098907997702752700992430743217435602489432675064217352287154992090426803029188251740398624925765347702603407341012030716285414549578849034252017355070877931708991800909037479040020677737784302832843238136897088987161082411767497384171847611988265955436613480602904693703617123674601934157574147368064153009822162609679721926344539101886830325653717770742428982339386797428059825773037542659113809733606710062893184741463387396720419135773737364178001516344284516009166803456421176360422995401870489280575805066465365416162374058061010264314592855788295619198140950227699972569057731565456120307966571764016921016139225366823692434721243944836463358182618615619482522667620905569483013046300780275664951974005003649918568269909006004043713104564868812281103651563550554666544651041980985680342117472706777240801661807840782027495226057042476049414001328267239904685608311180905202044482294405331232463688938311654469465796911728464064145431847290597786970540442018600616922704130328753938310418312570891024403428085607697202020047809125181434094024021269389309194712605629344724898745878665937420138020984609198904262498003233847635727172107018221030840449775105847778876848731828664843797068782718471531464186139713620140263173698625669463454272685559053321918388182870244506684627532183109935553435885561231739567783036499606674765144453139289667442273783489518084443388279169899669252322159881874699291962846569716547773329768265069890239071315609980909765443177703108956381523677609920044545100120196472362094157304076413536147878731369340140391116250832872496445285811836801161839630505239882481143218189727751882683652529116780721288125440274798195370496875497921372848301909231897576698451606925876413611686948082144081808861799122409473697084363912149573388758178262548519796273840736029045819620185103892843577486709035251761868884162570587364437811937207424748102235955408708363751131979069061019538969397211426667012424188217749601109723119738440495119846367165871696440261158223110413147448087843316262006919185923686237216215428001837281780549252506020808901174825132605545614915948635402030505567005936573174829207520611931704070950192599257857644410903608240340250349990067273291350806951775158037628921825937288898333002421618513268308801549296512555417624017148365636948208541798507693397406307485854190447952225969036049968099209108616008511860691721543446594991081880831805827190859447785189356817297522361739534985461270133072242398058664999124412437639250209311631433497206354820857888027866324826050784610602670814594913160529056473317484939347273525939363910888140256266364771616787584993084529160066803818896665741889898827064383229190775059529624926604212878537697762350418758137938191832526176251043250007641502157409554266976458452377532747823230217976409778214899891527645296607993503333585589460192631322672336917112960414688231399315006477844601754673615477960711902173489694453054247624474006212052598263845277921287939072039443347345050042780873770585027229980311089603898187810800845005553499885832693883260820256091102534228129905136942179430006014128913737905606896536624415975786521015642988837164269508114549361124931131959744810113623873228874987863839127439046959073093447132020716436248690263513674553747935555443367385110404315877756858374610548759855044906834747909742755615306475696991826145014137137627082715519375400846738341608567985548093492076738022530169932367612799811351261483692852928984000886492794486539036807205369249360374277699610322581697180365257238616674711853422080253799520600057170949260246453635078000936848084266777887553313974249518078827170720952847842074686972066445086464020982278650008387871650814508764270205062276844626810599937393026954510710301173603330664497281921002272157441938781254925328746114761641650896951247191722049281123154633243340911258305001223899400085087537685966153839006966811281745867391450154946330003955824233449144165869754157636570193666784684043978990364805857930084519632504819110678964243127591049130513313698574684431298871583044221548910154768655694308301041955933070318910190552187393382854474218664326507121676959847996704382954181442872020104288772931614040169182359163346639210810177981314014247510563707977672547935108529176110602501769765159756992906515016330724809849792697567921894122929209632394539921708146665801235303004444389519735248503413526026280237769544859095742881071122353143653413773547558011141567006402836259535985745301300874838838502504035208792555867053090689906363360276216953319926291932160507886894801114242441887740483824354854497870467960074031829039442278911876422387445545072047478740154047948730539516395523020809427283630669235670920146658377722683934712880411657809524315054936649968900236900811862474882224509925045800383621520676938238146890623073035134422919297840989061670530208105956777408602224955308689449496999825385235530996528378683808584346966200985859344759869478554444120077273581870999552867619181013364807044472271098252316733366951175580942111110140359991763665760435854673215899276711835060710694475784047386416352347705046424147512139665858433027301241996097297666142515582409501094717819275388112930583573582993835474014348102871413487132140428308997020216857087364898860091979854266544407636400549267756664760554797401601531712064942947639021143203805074157054134791560644632476789909517046004342008418868597162217438681696714371215571744740417580463715373997604062766177107569375827578009215762794362945247067823289278296015930891277914284686083801469242596245523447202082431989493098747537555394228868909805835032230480443585216232640676609850663791148443762460885579559387806732450452695347329336053928419059628863369247617183240861631295604776732244160327183941330274448451108223245067956353461293744498740715765278504770439874236293127656992356201739117940951902043882315402395539615169283428668560346004764609115547093300453832163804675605725927704544689003209486250706378786197865272499467792646434469539798936587706353362426234833691692835389468287178319513072751674672439199168565874086985776740906682022108577159841274598768767722360225773131190203782273714681778273084885229437623565238444589933993822379490820574359351656877835566143254397997709891174701599569458111763618904669463833642038309362612373718624489140045433392123039630455532526868288872933625593731018909142579227710728305836052993020953022083216908835002886635831459543046596452173922857979975259573727011562178922188362685897803810517703201241712736059215411969253630995141833835637777928313693860311844777019354516808153185412905432551012858387174991845675662442378271061537443248752603504888095144096052609372962962227987070753394327029432964225997211528493550909875150950828510644871375355187699058610304277514844981193370655502017315870292752359592449611227782979248435979130869082025711037896194678359265978424977442091124383757846768174203107114553106185059991998506820302720011557079246412883610566328037948828152849212772073083068027429377231713160016318363817351904579096172910592195725262047752204814990500488110754001954234036148499346573298904819209601334520870373232097490426454530158603819403476901394443272159745983168808448665358600483400957815717882474689700374081585540801745300273377073861014827143519947015798026885884910052678412711901214139333031187704444660455686379436337389187339576273043382901349984166823824677371631804879309125784983553635588569349956561709562412974750503038174161541393804031949117055108521116653914187011115539722979698892427731602435660052089094879821125837456097198032678927952860070177942382742678214913616616331236107432721114991579376089828607180322807567537877750867236474993585459581801938401793410523147016180448613502119043973819573499216091906204693699838626909694490244561805106109437259747213404208197152018207551627463559348798132523388145268729990075926304593536833560834862703513032884745054594413167851418392485254140199604267095066447545301846247743617865192855904439693735939339350798096179378619828534146704972705730885874407327959056192520593771564814873627641239728572939286081737173501857274928120490043788355477561844647259320081051704704331376613908832840309813882527605111344347995291687858630123206732571321400810976327584886102116805411647001390089341617342282385764176523754390334094377449056151535370830948856234819232064806777726114261445585146058108749514721859198904326114637261434085000712705397694616472366604211569557072613358139738397156385982096890106184750905943789400941559950017590156783143132486396281931025216781103758875217039336021286724876718581739486991093886276792314331693970605006841883357836536074948923736620485608049972335771674042174143398230450658093107370827872800561958687050085230145898944313980473794070569418046787129397640129714478765471615151756769103037598489168004492474513037632291562303446970565931554362915618610293423965796003144389339606112389290181286591870016998477449949156772162712773821691201128645176430316487531946919728766583061313387880964888594929956740755244042175637293408471390125719343185932570134839297290839568728739760911654685157938384791804514130093434134555971061553702489944834793791688514601474469718494276986713034279986304166286932659198237442447516813495944815622111963737969197219504842302237360519542227748818632806837075219423596553520421219802877271223199678043328124774877336492300030902812633980976898566057758020641335092405134123494924316882512446787529950833773117862236708500716536657230960614138034282421709933004459509913854107308345606953379499285226780231078024889196561901532760492947963909198882670703834797376564779537709748438091692505226846987763267673083164955839817544696940330959160050996453314907080932341504534272690905768126035636749510695451133677654820821706167542604487336359896669811003944158717385720831657246149890283649673671036715740220036276872770866716089756334291822152275546510114398699549542634288420403929134728311925506778581564339822979911970089006586522523944978344240341168867804944097045538865859088424920625477961051010844479462311918194466358866348149680137095580705009024374925714523984210950624918638504273303331270987160370531955849159766702203561511146604210421648033607779134112870922761341012787523216210974205234507823936821943190397865767381686930380973365926553861389190239041815460447343660681738617426607339868877279801875517541834657758524997840397303179698303572972363391426602179357694241463677104625063101649119404839023439418795786333501363334304674333488519647725789382437181779680111798342446622077543461681340749220623295386918383978180328368414901981587632273357636249831152965669397870308585047262942686614843472063921261594822679017318782009386656002744851963434163850219852250928649976942325350946622440658048999226579936864170020703917997339317619096104981093817789972149368258603142505292825750781831915364936663873429849258495683381831994246073925682895625821822049268232775360392180220824517628497556087831156723556782079308021116236182276595502512567283110654085743080132850521573978262128903697107042185800465127296281409197550810931081690516149118853174669342000318245414162190808962960774433923701479671017509726405914471837316961394097388239283954573504368531972532869132519608362482393748223535749791027115346612592281856453576506255320603399357159238692865973332357398713926889067178643187367699708724556509601108452136927933090783994606160276547326298922833093185809891570107477493553573153140557462519460986007492955977250163522082028946083300543977960567791896876212758681537773138094229629960998471829153546367790548663498689075552936434860567713524242160442315353790803787996196136654476972208656449154703051134567199657666755503496085299202073345118611227620331859745230092503234748733278493689561437825842599686210602402722826700467890086230748281464486019998207077368633974909613638226261151632042406497445563430748954525790234108731402133736057626205645738067052564589523541816954502585382100058388205064279241468100925429515386799007256647027293539198368995409222548373129604935020066225121867340086028693526073963876180179970948745476423819820936754295791516226903041568352992828113236920941053094305750165427026858472951184315026582801326229880329401210449310674072162660946469446479511802866329733937880788931908822540614747077452002316672883657033038438034472277515388933911737753221460726165711721974020289702134506053072710102094064292348165141607314493870938479504222944846468439715287227671384599941984875923732803645732438149567931279825734493769185205676992447083256803928294549848110982127623187787290472798933154588087665462561718886810268356243493057554106024034198359388962550787241527744663966007881668089429257275089606544541684767733658943911277404137892001727984219273262520391889227162742058207827004062384378475057773471800745215084293615370379719639945629925449955271363196837534963163618745098050623410498029500172072732224461505166530646311108477151983727339075712570292867836817004958273258045379808331151966873407462903171200479995825236900840314290293315141683
0x2F8D9a3A...a1B96452a
0.15 Eth
Nonce: 0
0.13635388991333003 Eth
Nonce: 1
0.01364611008666997
(Ethermine)
898.314561948515041757 Eth898.320128873515041757 Eth0.005566925

Execution Trace

MetaLamboz.6001600a( )
///////////////////////////////////////////////////////////////////
//                                                               //
//                        MetaLamboz NFT                         //
//   Contract Development by https://twitter.com/ViperwareLabs   //
//                                                               //
///////////////////////////////////////////////////////////////////

// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/MerkleProof.sol)

pragma solidity ^0.8.0;

/**
 * @dev These functions deal with verification of Merkle Trees proofs.
 *
 * The proofs can be generated using the JavaScript library
 * https://github.com/miguelmota/merkletreejs[merkletreejs].
 * Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
 *
 * See `test/utils/cryptography/MerkleProof.test.js` for some examples.
 */
library MerkleProof {
    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf
    ) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

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

    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
        assembly {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

// File: @openzeppelin/contracts/utils/Strings.sol


// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;


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

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

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

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

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

// File: @openzeppelin/contracts/utils/Address.sol


// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol


// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

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

// File: @openzeppelin/contracts/utils/introspection/IERC165.sol


// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

// File: @openzeppelin/contracts/utils/introspection/ERC165.sol


// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;


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

// File: @openzeppelin/contracts/token/ERC721/IERC721.sol


// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;


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

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

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

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

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

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

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

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

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

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

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

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

// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol


// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)

pragma solidity ^0.8.0;


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

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

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

// File: erc721a/contracts/IERC721A.sol


// ERC721A Contracts v3.3.0
// Creator: Chiru Labs

pragma solidity ^0.8.4;



/**
 * @dev Interface of an ERC721A compliant contract.
 */
interface IERC721A is IERC721, IERC721Metadata {
    /**
     * 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();

    /**
     * The caller cannot approve to the current owner.
     */
    error ApprovalToCurrentOwner();

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

    // Compiler will pack this into a single 256bit word.
    struct TokenOwnership {
        // The address of the owner.
        address addr;
        // Keeps track of the start time of ownership with minimal overhead for tokenomics.
        uint64 startTimestamp;
        // Whether the token has been burned.
        bool burned;
    }

    // Compiler will pack this into a single 256bit word.
    struct AddressData {
        // Realistically, 2**64-1 is more than enough.
        uint64 balance;
        // Keeps track of mint count with minimal overhead for tokenomics.
        uint64 numberMinted;
        // Keeps track of burn count with minimal overhead for tokenomics.
        uint64 numberBurned;
        // For miscellaneous variable(s) pertaining to the address
        // (e.g. number of whitelist mint slots used).
        // If there are multiple variables, please pack them into a uint64.
        uint64 aux;
    }

    /**
     * @dev Returns the total amount of tokens stored by the contract.
     * 
     * Burned tokens are calculated here, use `_totalMinted()` if you want to count just minted tokens.
     */
    function totalSupply() external view returns (uint256);
}

// File: @openzeppelin/contracts/utils/Context.sol


// 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: erc721a/contracts/ERC721A.sol


// ERC721A Contracts v3.3.0
// Creator: Chiru Labs

pragma solidity ^0.8.4;







/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension. Built to optimize for lower gas during batch mints.
 *
 * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..).
 *
 * Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
 *
 * Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
 */
contract ERC721A is Context, ERC165, IERC721A {
    using Address for address;
    using Strings for uint256;

    // The tokenId of the next token to be minted.
    uint256 internal _currentIndex;

    // The number of tokens burned.
    uint256 internal _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 _ownershipOf implementation for details.
    mapping(uint256 => TokenOwnership) internal _ownerships;

    // Mapping owner address to address data
    mapping(address => AddressData) private _addressData;

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

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

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

    /**
     * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens.
     */
    function totalSupply() public view override returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than _currentIndex - _startTokenId() times
        unchecked {
            return _currentIndex - _burnCounter - _startTokenId();
        }
    }

    /**
     * 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(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view override returns (uint256) {
        if (owner == address(0)) revert BalanceQueryForZeroAddress();
        return uint256(_addressData[owner].balance);
    }

    /**
     * Returns the number of tokens minted by `owner`.
     */
    function _numberMinted(address owner) internal view returns (uint256) {
        return uint256(_addressData[owner].numberMinted);
    }

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

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

    /**
     * Sets the auxillary 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 {
        _addressData[owner].aux = aux;
    }

    /**
     * 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) {
        uint256 curr = tokenId;

        unchecked {
            if (_startTokenId() <= curr) if (curr < _currentIndex) {
                TokenOwnership memory ownership = _ownerships[curr];
                if (!ownership.burned) {
                    if (ownership.addr != address(0)) {
                        return ownership;
                    }
                    // 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.
                    while (true) {
                        curr--;
                        ownership = _ownerships[curr];
                        if (ownership.addr != address(0)) {
                            return ownership;
                        }
                    }
                }
            }
        }
        revert OwnerQueryForNonexistentToken();
    }

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

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

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

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        if (!_exists(tokenId)) revert URIQueryForNonexistentToken();

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

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

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

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

        _approve(to, tokenId, owner);
    }

    /**
     * @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 == _msgSender()) revert ApproveToCaller();

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

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

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        _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);
        if (to.isContract()) if(!_checkContractOnERC721Received(from, to, tokenId, _data)) {
            revert TransferToNonERC721ReceiverImplementer();
        }
    }

    /**
     * @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 && !_ownerships[tokenId].burned;
    }

    /**
     * @dev Equivalent to `_safeMint(to, quantity, '')`.
     */
    function _safeMint(address to, uint256 quantity) internal {
        _safeMint(to, 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.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal {
        uint256 startTokenId = _currentIndex;
        if (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();

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

        // 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 {
            _addressData[to].balance += uint64(quantity);
            _addressData[to].numberMinted += uint64(quantity);

            _ownerships[startTokenId].addr = to;
            _ownerships[startTokenId].startTimestamp = uint64(block.timestamp);

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

            if (to.isContract()) {
                do {
                    emit Transfer(address(0), to, updatedIndex);
                    if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
                        revert TransferToNonERC721ReceiverImplementer();
                    }
                } while (updatedIndex < end);
                // Reentrancy protection
                if (_currentIndex != startTokenId) revert();
            } else {
                do {
                    emit Transfer(address(0), to, updatedIndex++);
                } while (updatedIndex < end);
            }
            _currentIndex = updatedIndex;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @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 (to == address(0)) revert MintToZeroAddress();
        if (quantity == 0) revert MintZeroQuantity();

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

        // 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 {
            _addressData[to].balance += uint64(quantity);
            _addressData[to].numberMinted += uint64(quantity);

            _ownerships[startTokenId].addr = to;
            _ownerships[startTokenId].startTimestamp = uint64(block.timestamp);

            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 {
        TokenOwnership memory prevOwnership = _ownershipOf(tokenId);

        if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();

        bool isApprovedOrOwner = (_msgSender() == from ||
            isApprovedForAll(from, _msgSender()) ||
            getApproved(tokenId) == _msgSender());

        if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
        if (to == address(0)) revert TransferToZeroAddress();

        _beforeTokenTransfers(from, to, tokenId, 1);

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

        // 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 {
            _addressData[from].balance -= 1;
            _addressData[to].balance += 1;

            TokenOwnership storage currSlot = _ownerships[tokenId];
            currSlot.addr = to;
            currSlot.startTimestamp = uint64(block.timestamp);

            // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
            // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
            uint256 nextTokenId = tokenId + 1;
            TokenOwnership storage nextSlot = _ownerships[nextTokenId];
            if (nextSlot.addr == address(0)) {
                // This will suffice for checking _exists(nextTokenId),
                // as a burned slot cannot contain the zero address.
                if (nextTokenId != _currentIndex) {
                    nextSlot.addr = from;
                    nextSlot.startTimestamp = prevOwnership.startTimestamp;
                }
            }
        }

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

    /**
     * @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 {
        TokenOwnership memory prevOwnership = _ownershipOf(tokenId);

        address from = prevOwnership.addr;

        if (approvalCheck) {
            bool isApprovedOrOwner = (_msgSender() == from ||
                isApprovedForAll(from, _msgSender()) ||
                getApproved(tokenId) == _msgSender());

            if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
        }

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

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

        // 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 {
            AddressData storage addressData = _addressData[from];
            addressData.balance -= 1;
            addressData.numberBurned += 1;

            // Keep track of who burned the token, and the timestamp of burning.
            TokenOwnership storage currSlot = _ownerships[tokenId];
            currSlot.addr = from;
            currSlot.startTimestamp = uint64(block.timestamp);
            currSlot.burned = true;

            // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
            // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
            uint256 nextTokenId = tokenId + 1;
            TokenOwnership storage nextSlot = _ownerships[nextTokenId];
            if (nextSlot.addr == address(0)) {
                // This will suffice for checking _exists(nextTokenId),
                // as a burned slot cannot contain the zero address.
                if (nextTokenId != _currentIndex) {
                    nextSlot.addr = from;
                    nextSlot.startTimestamp = prevOwnership.startTimestamp;
                }
            }
        }

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

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

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

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

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

// File: @openzeppelin/contracts/access/Ownable.sol


// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;


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

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

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

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

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

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

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

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



pragma solidity ^0.8.0;



contract MetaLamboz is ERC721A, Ownable {
    bytes32 public root;
	using Strings for uint;

	uint public constant MINT_PRICE = 0 ether;
	uint public constant MAX_NFT_PER_TRAN = 1;
    uint public constant MAX_PER_WALLET = 1;
    uint public MAX_FREE_MINT = 1;
	uint public maxSupply = 420;

    bool public isWhitelistMint = false;
    bool public isPublicMint = false;
    bool public isMetadataFinal;
    string private _baseURL;
	string public prerevealURL = 'ipfs://bafybeifjjv6x5izvtq6jb65wwivz43lrw7vf7htescaalrlemd3j7tk7n4/prereveal.json';
	mapping(address => uint) private _walletMintedCount;

    // Name
	constructor()
	ERC721A('MetaLamboz', 'LAMBO') {
    }

	function _baseURI() internal view override returns (string memory) {
		return _baseURL;
	}

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

	function contractURI() public pure returns (string memory) {
		return "";
	}

    function finalizeMetadata() external onlyOwner {
        isMetadataFinal = true;
    }

	function reveal(string memory url) external onlyOwner {
        require(!isMetadataFinal, "Metadata is finalized");
		_baseURL = url;
	}

    function mintedCount(address owner) external view returns (uint) {
        return _walletMintedCount[owner];
    }

    function setRoot(bytes32 _root) external onlyOwner {
		root = _root;
	}

    function setWhitelistState(bool value) external onlyOwner {
		isWhitelistMint = value;
	}

    function setPublicState(bool value) external onlyOwner {
		isPublicMint = value;
	}

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

	function airdrop(address to, uint count) external onlyOwner {
		require(
			_totalMinted() + count <= maxSupply,
			'Exceeds max supply'
		);
		_safeMint(to, count);
	}

	function reduceSupply(uint newMaxSupply) external onlyOwner {
		maxSupply = newMaxSupply;
	}

    function setNumFreeMints(uint newFreeMints) external onlyOwner {
		MAX_FREE_MINT = newFreeMints;
	}

	function tokenURI(uint tokenId)
		public
		view
		override
		returns (string memory)
	{
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

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

	function isValid(bytes32[] memory proof, bytes32 leaf) public view returns (bool) {
        return MerkleProof.verify(proof, root, leaf);
    }

    function WHITELIST_MINT(bytes32[] memory proof) public {
        uint count = 1;
		require(isWhitelistMint, "Whitelist mint has not started");
        require(isValid(proof, keccak256(abi.encodePacked(msg.sender))), "Wallet not on the allowlist");
		require(_totalMinted() + count <= maxSupply,'Exceeds max supply');
        require(_walletMintedCount[msg.sender] == 0,'Exceeds max free mints');

		_walletMintedCount[msg.sender] += count;
		_safeMint(msg.sender, count);
	}
    
    function PUBLIC_MINT(uint count) external payable {
		require(isPublicMint, "Public mint has not started");
		require(count <= MAX_NFT_PER_TRAN,'Exceeds NFT per transaction limit');
		require(_totalMinted() + count <= maxSupply,'Exceeds max supply');
        require(_walletMintedCount[msg.sender] + count <= MAX_PER_WALLET,'Exceeds max per wallet');

        uint payForCount = count;
        uint mintedSoFar = _walletMintedCount[msg.sender];
        
        //1 Free Mints Default
        uint maxFree = MAX_FREE_MINT;

        if(mintedSoFar < maxFree) {
            uint remainingFreeMints = maxFree - mintedSoFar;
            if(count > remainingFreeMints) {
                payForCount = count - remainingFreeMints;
            }
            else {
                payForCount = 0;
            }
        }

		require(
			msg.value >= payForCount * MINT_PRICE,
			'Ether value sent is not sufficient'
		);

		_walletMintedCount[msg.sender] += count;
		_safeMint(msg.sender, count);
	}
}