ETH Price: $2,454.84 (-0.30%)

Transaction Decoder

Block:
13038757 at Aug-16-2021 09:40:57 PM +UTC
Transaction Fee:
0.083349245 ETH $204.61
Gas Used:
2,381,407 Gas / 35 Gwei

Emitted Events:

Account State Difference:

  Address   Before After State Difference Code
0x3b64a202...2BC640a15
0.125559848860076856 Eth
Nonce: 0
0.042210603860076856 Eth
Nonce: 1
0.083349245
0x828bB288...Ce909d732
0 Eth
Nonce: 0
0 Eth
Nonce: 1
From: 0 To: 755986816444763507512953014102082284247371904469979810763144289794452988893392045720287373948046005216198885249496016847590231735681901784462670690843603044008657351470900205481317569901250127322694725974747748576381859567482183936265065406998125951761394814849211139138709607700779559270694528994855490767903893606385800187475912127349994845669337366666922673309919810754251235173379535474571443741579300778521824124431677251067281790540886684787282862191449004492613507041011470064039535491966135411647895129307008198977333294042581862926133841381490821601459904159554232044263104011528213687212860998399581742567894922446419274456482273379232557446366485525918842818163984768048741763974211827305817988700006159738625343404989887234550543129183122307055530502007892336641965090665011750154966994138805131573052642049884075077069621124286418744439211719007979573613183543175228794661243384015318754875640224924148765291553902188175125238530221515405203537556475938099919646266084134848970770983890505116374603611560862833016374359670939949798011761392866645286786118400994620364501245709854129832056503471994392060289347356959419452049835060168533873531024467091146968538947624194453379944272670081500230466996604834895072794155270114496817178806572181584707434988649405357488339630475586619206301272257999479875046030508140898190043216594360808069769606261283964152491821488535886472241986771984454280586362151536751041668960031977846937141905483617868130286307713449272150592073318468094610700783784994833418254761835288885682284257139954238783415805331884174591478312685025808443341622119473743478908759058156806036725006782472614699386652263364573987810444126811588729636703831673029701311743349023772783600605136404735525774424279728908020772964616546750735505169671488529769285612150097895558910122946399329685492646950363977094212166127831604683679115788392871212808459052732189427103644611326478928660444486242076326998546198931033194182884199614243525800871437127465343896733166755437256285414143059040472863714017796093494975909138888334477447536520269330487403040970680499980921373836643439935248342793036009709237539405331766517805145116586346875721244990558503011755913702435508151562581640302086238189003900375772273762300804405068731142212572951145223720095281056779571431762293576779892314118533882067846379607628429447330720069668503180968650921945363301152644999376735533903396010602976377572702981922304703441871092105797502770426810917785636899398783221757068640525268229064007725008621233660148957473186728012454848443541503006710970334450247201255939553202589386204490577158661471510580929820027179923939670697853999118823274579446428857065622795310704576467263022087160159824987242161125326331607090910396806800827027477597458531368305245405789351383049861009770850547501571552607633904811572289530615681344633932399034979769443683840482468104955578222045558350385290608341503028523932705306284632279417234027706138183782685697468906716012603834876155480189032015523135286236400012285838276044526697401179558045330711748847612960203841867934136482501336435507417088013560751144640442794211610674216606672448807511043069442891898012965906325572032555172402945789254854279555534781483122558811900416473879183081223896336272073692927721120361184598037076678119872686570797556891481519031087360629046565684310822289415182860707461671625712994187403322359476971611402613326816433825374566491197420605497845606345877021440175506931796708803708960728431759577902390642834619804511403770247063078260722427778588124935061764575223008546588882760460716797123627800731178139190891620985987763174501971774355601041546573029330092287043839350167813579601637971418093672015081582060205347532355317141623396561792630618577471721414058008389829353942542747917661469185333372257284444934148684995191934742234087639281122827163719929837538348013737484120217695850108253376891818487424431786223440294786886116402685874949500464408792844591411322083295793372349090552970877604131324165819083851224312093829145100885213331463097034670321232235581736402602881226289668594320209261838728513778884860774039893936138889580636458423553003595257890073986626075312619450862979262318223964711661069824870825517981414418352314324984598084551945048495661723412714094194053034281985353310287709724063845007472855814304548472413282862794114627744686970201362469234779806563078620181024569286070941829904986640365910146967779047077974580842938746953032113674602044078388775228582753024324882355773062033828708175376956976239440843448417822291106760668856634317311030995338585230148037401513917810570341379539638029296338890392474718301640517671630894121166938276623324583853875115806688286433274432147635155711395428528972336681916952103362735159353383610818067072524395732736234539168480898916915833850882168325786250552853168671237005288976452189359019251595438522847687532453725229346499453451329737936059768783206083145317982757967016598473018606871368989726038980393134472117529762510274610353504473734291236352058651874899113084593977434541952301252529447294185453849190437364487064434300842298757451252137703016741600447936197712716982697935563276819943912689463788333696219400757271726956329049645146039958542606433748095314147329363171277317645317010959230146680070424285496918645601782517094796490569693116619534331697269084371666930359607615624671611463360468086372959002226969748768662009671035947021263334508105522672898594477821036941327916030059726001741564424351658102674030704331962812635039636602410643290755848715277530352620388872258178681503140428797878359199205418953370482703028402618943474868801351610099796129337845656651320441339945883531596770625017758922962160596625305841825001150802701834707319600745324044593679522862957636029346015563515480013574202314106473153117116151972640159229988566059875378666578772488265144639511907814313245173311420452749502606213486350887377196042809849197000206652383182733989778918084733546253220580431651420513581329719556698753175600151909986431714783275719817789281318841631149502604624618538581060773517963350325972591295410342827619361964370845684498763303006200817489320486368336096666472118853909604997485836401954520443074407425142652502018391860022507121525219195292463927197796822359047839840232635214549148520902340381690347286564622035558634440735375733646928801947142531721386569813246320850926706661436656936570258302630517168556898015826117019034038444217481285610670811026901974659735083057379385017038914141344295725536310056995069444238930848528854214214736739334088720954206227895987914286517338351252859991925731259261959808946060995376413286519937210569995485554769673755547759279594919880771084358911610713669787663754142678638198256698009367180509207667586716417012260209203204478956953620279257351719065236870248773303032512871285874820547343975640974003629425062196592817937630137285547675706804231514412885393564419318750339856694149077720426475762733627762008492924962873082370026450675847206366708579359619863825435955975600470789833638637087030663620416767558665210077505560251408516951561653193635449139039397438186529845086654963054918761085631143150709066568141317777460302364358014653873099497086132943732641651635065031338713200843336753793222694629770314299422222720445563865793246445287695759973669227786990764063616093432106041575170606320172362722341201541227087773682791750039121037295549001651524857380730598899346147079289486951970013855520209896093413791957953805641873855826710540037853516078809172756376031940217156972144803111993682212506458497445589161126828151332805177805035362546504147491191427080714460761716436430057014764191517713733126368869189517691997689872335003654378371597487397173272675749526259088263986581368156578488013083773273384629165868031165637424832899564118609265785479800391335357529451342442471220996517652810938302770542844852132182156193158203243961144643984783000497368340505871006702204274381516628910739310131870792688752155671320900999239214969128330145146991832325266547821579206167675440849168756900219668632128460284307705525812290592371469504015460800613134264098686882438441122293210173910881627011662369037673669505608714645224078560012899893946095833127540372852452242974169873176900099855932590022622481081209315970518139798730087152508507489549126893038844880736121914776429581407783340599969227486918180608083964232655959580144354102882244146483653782933061505800861279647028743407609790157066956654745209022965346011271626832110253972607164834249678948638608678920522156583792127923798802506471371024912907084920355279987493649113798569741407395424984770232327509040979508264048164918504669650377107567119662437593906507400582285196959637077926953551232595011831611066980380203268767228276789969536041438720636340825146370593535059668235442802840652617429831624169262301433847329519168699969482407697497660591132935679291388329309126112630393048381369429871800133401906718426415473226319372594455255889035643238949377986366051701520481467963625215981446976515552770426779187749304080647534941127809104747864584111061908721701250063466191077386708034325923520800617561890365638882171020516592302199512114311277143174569597436475796166673016105058000681409865930472574069641569300388931781004399659353408801779230847377830413715562149272348918834427832415327519707226806847243112566700201695237749636473375722842728680152227691266276178618404302920174096487846207076766625858239462906506818628300664512863168718138540752265543897916588087675041951596061996899384571507067063931888574969130179800982334159209951132889788116886301316301922910896113682234432368301682673557749031149759247544117328424895559818825808237239587518508435663813011702111380886323513606187567568509887265999833765799238251917583585297872627656364762215105389869830756356031464021933467875153037972220807047056353386220009514503373480884162938804682657510364599396131548871257828141535658431226250611853161458147220360890480661193941871314680199585717891817845970832867503417352929887787975439931138063268905326871300466460552650880412360876448666567528140471531121088563521367797165524276265231938430739147824313925810223458567126478576387946342799104634111246648558640841759212837563577513917697826663677262750511840572672249940238531052730234130442934198694868819738563384616556105005954902058837323561069666046605213210080520999311638619623669726572701588720501649963763470280101373347768300506043596790362858559445434631177636278709711326449912813273382670648503279129890074086886394999563884852416613906951117174457277529694648840689468210032659939011890717844799718677555435926790125632616439468304212137566345426661558383801812533812968015639472482968657981134021349131505141648147001619600585319687494158387732519946612442359668741650424077882781034500615296869370589124308553645663564964911299878326494693866018542097144907041693083346291904800059404524213739326878731232093286581892158972251121239683873307998338173326667096769476994799628959196241147159773627596348712885092983891444094293128485559290573510657677112631643508292740441800653902178902894023430949851928569005330933480187047983652849090307702771242007364690997347647593226250940759054824261799640889063195686547390732172582455928285803750190756655482299991427346148456954929234127559100075992727119257616651413455322793526018510390666389055547435807698588170194271019083712376314911267285474117036438143016491990989417064106988115495065252823901741937054148265469711617373370733958207492778560379144207434787578512412207946581093149068029338262168900642427425956334973431800325653970842286439500251644028871064259172922427905211195152534229527518354342503220461004185886914763766962403427453979476193204928230888480888925137136472739806709706690430303316077415550583862777328440080740041278138798359726132426295339537392103825348780189375699232097903501191991449218350131347517754087933121328518188606204031372048806200049218298799744363027680986399219189653216124794731361896155414931600854220569367420588089611498308978066477074511462195454140545590611556227736541073937418333953396432544516775727375181110140215750193388346252566467643420429508837956021166059747177580640978301685476485391193422335754948781709974823156131008774618450838212002701251002266148859234588770848140161521255100614211558480064695831843236673208167177123892733146404065822568896890971812180231339262979178575672928734523502263476726167207149763036437675528830410745765922409292153465153377217344612773030697066147214384600692415833886932271994309630181152003609691514396418709168726164985420414503803033588347578773757468952910077835213773699819466069436640318481458168144121299486775117906621618224980806136889836159633400713607278463815671359211733737507130673369014596906383212037560915924304978767442611501999533136448326816958872819005302894718573746836800972056560704214935007480055387694831241954889101758662250432300014566630505609843324113044730869697243299449485932811446163130208322803209292627134879674965853990075363759348664424329674878445541265820332002396890494687518780910181589223062608862018394530806277417065700851739433660575480189306743552651079490945730616274591142319543704119802570465597011393714947152913917381944553645525021263046148503923332066992895481171555394431540475657113425438636484902848032679993923698300391451620706384648489507244441986220668474548859861639080625998875753301674136217363616867072072789636631521723195223725058600190150680297748439992550659400347629753805490218097237038733758240511406681994288211468070995475620259408327864430851197971053308685851763243255813995844479403479435989899839468504115257055335379393920853822727490117792520888005227636118926169593776133656300978188056476512600875915368327748223466014300159335452269652375422780479726684893996216433850232788269415312914002302515169139059732374621960318797749805308948077413218107576634981330577917532573148671254459723370789775168814225159155644885370080897942253627122349687378729022529309430322289602557735655462245701019294331349895265334407722639011971360325467807317851962870603878951847825896900146505647392229263663891461054610852927709208039101058273275961507537671073972982384937597227862140503397579973482067110219205424264060022795167099824377872900340856516380759125635371019577172438658974589128517929438790874606642805151452566839843283165648323859389885314043714053916433457210412352498769762085066376990943216108139015750309721724909703642857549948841515024153646604988485804994115562675555088395443375832723939637724275349353431339443004267806165371324139295551569766333579584388713200332327991878422529696255022522480724503533205831364160606789680857968695003970132734267748350921368309622506304777245385798568672635863053023933281655906705083855131640869779832133636494093747252643642643313122618063826649296793048273515867708437016250664651064926990299092892519110295533913641515292508459730535476000814443465251631400163266558870107923309335969557103062443767145227949527929344025653725393128167148344801875433763884648135069187590940006236321799046926118733762426325142170403908936638863541354098047712156051189470623777699045135209864645610771712553077849395108331860395239058365359842150885463627102078590864195282152508058308706715046027662543812371691600149472739556625837020880254209923974854216082040592112892199374029593973171373722606490740756594039575352989926478111223637027748062471192787893594925746619431361298986284007828100318173074363965936302675576055573652222487574719852712628921243094549835130661283358408226450020903405430775026171365318063451827805053959317199911757330961580283054825459324294606253993407716509389145649598425540086124427264448841949695696800586195215410643062895133113875388807458289701533425344690345065505488441130441150301813607957460635667760993177063689311065448405475231455249462553178200642088064301385263047495764811467349281426551349321615497762001115215327538478413410173648454799894826921191741687820737527502174814770340646856183422315012480667837042797184866894672029092779526053892380542761496500964618518654066259981901160256208973808281138778892758451291225083698378568816078532168105451390642328420446241195199309111904470328798870428428772058935433762064874967685660420136500033739388230550986046286750562683108791409395366848349553254099731227179633681133643556460215252345457229114678105310595158675195013583381102884347451513969989920031339739277816278995900935067016076933545113688924566702329137461132584239075458005196908121889379574982154151994576668337019824062694960787838088177760918198633786374339294612613959905246269395759566015291158919682199302305311308077546550241146388118730440845489761987938192752785408977738197194185154555122371561431108300291665085487661199466062250266266170708546052706171332982556502106902232365724659031414116286982541978201964846281076572914783714683173175925924110568745521050258630335716307179142324469223726397977464027789341574152695114043720868622799954270938774295843082829096014952655839384290894782179913716087465379486180269067066620242440382175248041342330895953139249445723293935769465029480589668440944745253930602604465701656480396520681579581925799941372267189272632735831033579272948919495533982851271750061030939084435673909491391476868332820956571198360905305120872801097791451441447642754761634809730413781420248359260383119304855876244120284342661457647625576289646350866366030923020002004354249189133154781068427287794213254588312806648772238779997570859811604197920693036582668407877464159523691348385144358008782024496884850343739563740375145503057125691019313639586554216456250716039416122658443090725824958296504137762715683793551103800371687254544934169510501534353909606489079059319460450766517412986783952354486821282531503232592621674679247157660693700298547916532831764243333202867435223213367255969448318322166511246893979462814831496142143188725445186991974964242848309267877438902125238943485623415365015568925049473179375095738382558284389358772265539893649322904876778243775478993776449383767310418536207104541939681369726138594473409098863092883518176744382050141179401695569468213139843523211229091265540253083870821704884141398351789761653813947118198251818989756996399417584168439709800184458807630960175312890647725555502230259914147998235251661543577765624208413583043013288858922713494776058933448790311565966651441007620286039046679455934515203537739166657763920862337544424777350218973108400789465743991889496718675264966781941518183443102990872586834395433697697748621655274309869469656314026515318389030861123245632797863434286399262216990509282237560825877969532991095835643577633537888763705243792915990476717459363360646903421860911374194726513213466656795335240812684522492968533292316102553519257560889661080332917003103159959097705199807140966233379746134534021036173933288490614737394859657028870421106111100318765600756808177730042842154288578300868274140853406628637436002931066701711930527892468215452722257286713830940432647717840989964068681617077746972412871814974099323689788494495723841086628095199363528620572543462247877173497616357184628317867872727547084200362114848997284296467437745121301435836795109540995943104661380855714949128441487254380219578378511637686026029228157637396004710413764958675959504343519962856072429918446347385860239920175841854895763822188980182387997886817399035979648772031767158179664657816144049390228633158157111641143547738109446970620783712803970101678527648811014977106026531226695710127866961430263688925462189551753011050168034871909415857539950777164127558788636162939869021217430183298102248021649753798401078397099838732203724260212039684395567072017485625331359737864242892343047610748848676029984502650505500218911664923808025949636076063294899746513699356583917175649426979270175572319776785818799822370517911770688414624185252278982407661355070179711884440313027967803696338479338503680712606446097490299385118807428973228716816576193913398575119865597296453742468338721576325400261900398023153530614798622535138263304102821033092073292562635708363099960943926871728080260493046910143735827077451675146177819879075649283452108212565491794820535328419219052141083101344985611929457364209446408307373259577318457256696784669602536866315976639388182667678748504117211433535144767219580793363017442685853861914698584300009451533962598163674881131200608616764900802294469933596852142531017552480203702836035890097932285211100393217007000492796345473738352606971120663396987628326699810568837813236358216174572444847931817026027206643538961993715332893590660178494219116308313568859880070660150339381871693187179073774111219272738276958184258722076048694262205936834798602188312550000517137204535017600685756306814798598664881566321835763432248311301435352845867966643203421980042702038695384037752397118809747427878177534810429984070958354244430096343245369022386971154269366036032140897487962442712483163445481222325922147143939731007627084902874679622918622322270584149307580522941858270385959736228667480255005215192588962116419465549726728725245828207428920543075189947230085447610294632771409536847698540819701074434377308166619754957593415866153100749417685220974230328982383420059570019686940303794139856702519705454247606679471419463368123485285480625724209298021248396894239836889778663104453241293978528145679444788769103375784187740270179374684089228689851824290595875304201291832148122602019297586002247989354940806470149289008862455032039097271055868581163438760735914882558810823029815802133668185459193874838875681252368203808292914742102439078189074826643790634943350950194904216078325453503985832463333262465431320692774708192345822567424366293737684406782803643003807692316497825123247566834985848893321313059180838683777531175822557057816793789212797755742582138049335841002633694083038034089622649020707888972332100555238118712012284177537729055355367268617761181370228416488952074665316558528806459142803145254257018319022428300917774879443624742958788908606283576897943080459749330642220005737587582979654524176555961514055660470741653489964396314926644582208912843820590112333723595151698072790089515821633461232810346938677758060744167941889502703242938819768328251835341602793702267971423777730031806548645197226651591686877815870864113568063439424124502942304591756176106496983032834395423015995722745222743888971130305443505478484765797459227238164148010743954799986721269056683541053161365040137273887971037476899535984560009549739473103779314370455217134212999042873193747403743672370071182302527103522046044224981362138738282083764337288158858484713836588705643468375594858333838301106507255481171084031480992037464388877700476429303864102595192916417081395846190314918193898849103989197211761670044077602022757848496903846647300517213409271571333351196810964224671423436353882349121814672292588827364907296524666583250901800571685738650717035253756651799175996219873754494113654549119947700399334858959294737711863115668327486082042574878131910280175467997152632207287761636055224204810257213217484349760977699645523990481399739098976087396754456672214488274456132642662656914452632684214868044462845829318967572343338235645701468031191697203475745187431388167033809725646060219609665836872416959091609831748071313964097859162587933337466248023738971373721096720886477704392436609344628989355777032524507646662808253518586504942987982663968228513872605875977842192789969313421972318939208768225134080016485003829654246464765760320953723690154776532740334843527714895810257244183082105254249900218051361150880360576404394129016201285634890898866227
(Ethermine)
1,888.558584093505534272 Eth1,888.561680579261844673 Eth0.003096485756310401

Execution Trace

BarrelyNaked.60806040( )
//SPDX-License-Identifier: Unlicense
pragma solidity ^ 0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
contract BarrelyNaked is ERC721, ERC721Enumerable, Ownable {
    using SafeMath for uint256;
    // metadata API endpoint  
    string private _metadataAPI;
    
    // Maximum token supply
    uint256 private _MAX_SUPPLY;
    // Date when token starts being available for minting
    uint256 private _saleStartUTS;
    // Tracks number of free minted tokens
    uint256 private _counterFreeMintedTokens;
    // Sets maximum possible purchases per transaction
    uint256 private _maxPurchaseCount = 20;
        
    // Mapping addresses that used their free mint
    mapping(address => bool) private _addressesUsedFreeMint;
    constructor(
        uint256 maxTokenSupply_,
        uint256 initSaleStartUTS_,
        string memory tokenName_,
        string memory tokenSymbol_,
        string memory initMetadataAPI_
    ) ERC721(tokenName_, tokenSymbol_) {
        _MAX_SUPPLY = maxTokenSupply_;
        _metadataAPI = initMetadataAPI_;
        _saleStartUTS = initSaleStartUTS_;
    }
    modifier checkSupplyAvailable(uint256 numberOfTokens_) {
        
        require(totalSupply().add(numberOfTokens_) <= _MAX_SUPPLY, "Exceeds max supply");
        _;
    }
    function withdraw() public onlyOwner {
        uint256 balance = address(this).balance;
        payable(msg.sender).transfer(balance);
    }
    function setSaleStart(uint256 saleStart_) public onlyOwner {
        _saleStartUTS = saleStart_;
    }
    function setMaxPurchaseCount(uint256 count_) public onlyOwner {
        _maxPurchaseCount = count_;
    }
     function setMetadataAPI(string memory newMetadataAPI_) public onlyOwner {
        _metadataAPI = newMetadataAPI_;
    }
    
    function hasSaleStarted() public view returns(bool) {
        return _saleStartUTS <= block.timestamp;
    }
    function getCurrentMintPrice() public view returns (uint256) {
        return getTokenMintPrice(totalSupply());
    }
    function hasClaimedFreeToken() public view returns(bool) {
        return _addressesUsedFreeMint[msg.sender];
    }
    function getTokenMintPrice(uint256 token_) public pure returns (uint256) {
        if (token_ >= 4000) {
            return 0.05 ether;
        } 
        
        if (token_ >= 3000) {
            
            return 0.04 ether;
        }
        
        if (token_ >= 2000) {
            return 0.03 ether;
        } 
        
        if (token_ >= 1000) {
            return 0.02 ether;
        }
        
        return  0.01 ether;
    }
    
    function getMintPriceForNextTokens(uint256 numberOfTokens_) public view returns (uint256) {
        uint256 requiredMintValue;
        for (uint256 index = 0; index < numberOfTokens_; index++) {
            
            uint256 tokenIndex  = totalSupply().add(index);
            requiredMintValue = requiredMintValue.add(getTokenMintPrice(tokenIndex));
        }
        return requiredMintValue;
    }    
   
    function _mintTokens(uint256 numberOfTokens_) internal {
        
        for (uint256 index = 0; index < numberOfTokens_; index++) {
            _safeMint(msg.sender, totalSupply());
        }
    }
    function claimFreeToken() public checkSupplyAvailable(1)  {
        
        require(hasSaleStarted(), "Sale hasn't started");
        require(!hasClaimedFreeToken(), "Free token claimed");
        require(_counterFreeMintedTokens < 1000, "All free tokens were claimed");
    
        _addressesUsedFreeMint[msg.sender] = true;
        _counterFreeMintedTokens = _counterFreeMintedTokens.add(1);
        _mintTokens(1);
    }
    function mintTokens(uint256 numberOfTokens_) public payable checkSupplyAvailable(numberOfTokens_) {
        
        require(hasSaleStarted(), "Sale hasn't started");
        require(numberOfTokens_ <= _maxPurchaseCount, "Exceeds minting limit");
        uint256 requiredMintPrice;
        uint256 currentMintPrice = getCurrentMintPrice();
        uint256 newTotalSupply = totalSupply().add(numberOfTokens_); 
        uint256 newMintPrice = getTokenMintPrice(newTotalSupply);
        
        if( newMintPrice == currentMintPrice ){
            requiredMintPrice = currentMintPrice.mul(numberOfTokens_);
        }  else {
            requiredMintPrice = getMintPriceForNextTokens(numberOfTokens_);
        }
        require( requiredMintPrice == msg.value,  "Invalid ether value");
        _mintTokens(numberOfTokens_);
        
    }
    function MAX_SUPPLY() public view returns (uint256) {
        return _MAX_SUPPLY;
    }
    function maxPurchaseCount() public view returns (uint256) {
        return _maxPurchaseCount;
    }
    function _baseURI() internal view override returns(string memory) {
        return _metadataAPI;
    }
    function _beforeTokenTransfer(address from, address to, uint256 tokenId ) internal virtual override(ERC721, ERC721Enumerable) {
        super._beforeTokenTransfer(from, to, tokenId);
    }
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721, ERC721Enumerable) returns (bool) {
        return super.supportsInterface(interfaceId);
    }
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_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 {
        _setOwner(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");
        _setOwner(newOwner);
    }
    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }
    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }
    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }
    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }
    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }
    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }
    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }
    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
    using Address for address;
    using Strings for uint256;
    // Token name
    string private _name;
    // Token symbol
    string private _symbol;
    // Mapping from token ID to owner address
    mapping(uint256 => address) private _owners;
    // Mapping owner address to token count
    mapping(address => uint256) private _balances;
    // Mapping from token ID to approved address
    mapping(uint256 => address) private _tokenApprovals;
    // Mapping from owner to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;
    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return
            interfaceId == type(IERC721).interfaceId ||
            interfaceId == type(IERC721Metadata).interfaceId ||
            super.supportsInterface(interfaceId);
    }
    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }
    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }
    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }
    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }
    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
    }
    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, can be overriden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }
    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");
        require(
            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );
        _approve(to, tokenId);
    }
    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");
        return _tokenApprovals[tokenId];
    }
    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");
        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }
    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }
    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _transfer(from, to, tokenId);
    }
    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }
    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }
    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }
    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }
    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }
    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }
    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(
        address to,
        uint256 tokenId,
        bytes memory _data
    ) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, _data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }
    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");
        _beforeTokenTransfer(address(0), to, tokenId);
        _balances[to] += 1;
        _owners[tokenId] = to;
        emit Transfer(address(0), to, tokenId);
    }
    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721.ownerOf(tokenId);
        _beforeTokenTransfer(owner, address(0), tokenId);
        // Clear approvals
        _approve(address(0), tokenId);
        _balances[owner] -= 1;
        delete _owners[tokenId];
        emit Transfer(owner, address(0), tokenId);
    }
    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {
        require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");
        _beforeTokenTransfer(from, to, tokenId);
        // Clear approvals from the previous owner
        _approve(address(0), tokenId);
        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;
        emit Transfer(from, to, tokenId);
    }
    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }
    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        if (to.isContract()) {
            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721Receiver(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }
    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual {}
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;
    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;
    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
    }
    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }
    /**
     * @dev See {IERC721Enumerable-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _allTokens.length;
    }
    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }
    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);
        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }
    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }
    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }
    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).
        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];
        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }
        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }
    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).
        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];
        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];
        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
}
// SPDX-License-Identifier: MIT
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;
    }
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);
    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);
    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;
    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;
    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;
    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);
    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;
    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Metadata is IERC721 {
    /**
     * @dev Returns the token collection name.
     */
    function name() external view returns (string memory);
    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() external view returns (string memory);
    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.
        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }
    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");
        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }
    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCall(target, data, "Address: low-level call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }
    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }
    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }
    function _verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) private pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
// SPDX-License-Identifier: MIT
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);
    }
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
// SPDX-License-Identifier: MIT
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);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721Enumerable is IERC721 {
    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);
    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}