Solana Developer Bootcamp 2024 - Learn Blockchain and Full Stack Web3 Development - Projects 1-9 - Ep71

[news] Time: 2025-07-11 11:39:20 Source: AIHackNode Author: php Click: 46 times
quick allright so that the image wasn'tgenerating because it's actually the URIis supposed to be diddy scandala Json file um I justgrabbed an example one um we're notgoing to create one real quick but thisis an example one of name test tokensymbol test description your test uhyour image and here's your actual imageso that's why it's not showing up um I'mgoing to go ahead and generate this onGitHub real quick so we're just going tocreate this on GitHub uh under the thedeveloper boot camp and I will be rightback all right so I've created thisunder the project 8 token Lottery it's ametad j. Json it has that image that Igrabbed from the internet um you can usethe same URL so what you do is you goclick onRaw copy and paste that go into hereupdate your URI to that specific yoururl um and then if you go look at nowthis transaction or this token you cansee the token has a ticket a to tokenlottery ticket hash TLT right so now wecancontinue so we've now initialized thelottery the next thing that we want todo is we want to actually buy tickets umso let's goe and buy those tickets I'mgoing to just make this uh shouldtest token Lottery just so that we cando the whole thing in one this is notnecessarily a good test but it's just sothat we don't have to worry about it uhevery time werestart all right so we'll get back tothis let's go to Libs and start buildingout that newinstruction so we've initialized theconfig we initialized the lottery I'mgoing to go and minimize all these so itdoesn't get in our way the next one thatwe have if we go back to our design isbuy ticket so let us do that buy ticketinstruction we have to go afterwardslet's go at the end ofthis all rightso Pub fun buy ticket uh you can see italready kind of gener whoops generatedsome code for us I'm going to minimizethis again there you go buy ticket um soit's going to have a buy ticket contextand we're going to get started I'm goingto head uh we're going to have an amountI'm just going to have it buy ticket oneticket in a time just so that we don'thave to worry about this um we can dothe amounts on the front end and that'sfine all right so we have the buy ticketnow we need to create the accounts forit so let's go down here and createthose accounts so it's uhderive accounts uh Pub struct uh uhcontext or buyticket that's our context it alreadytried to generate a bunch of things forus I'm going to remove all of them theonly thing that we're we know we'regoing to need so far is we need thesigner because we need someone to payfor it uh and then we're going to needthe pub uh SystemProgram because we're going to create anew ticket all right so the next thingthat we need is we're going to need anew mint for this new ticket so let'sinitialize a new mint so we're going todo collection or sorryaccount uh we're going to have it in itagain uh pair equals pair as usual uhwe're going to create this as a as a newseed it's going to be the specific tokenlottery number um that we're going touse it which actually in order to dothat we need to do the lottery as wellso let's grab that token Lottery realquickum this is going to be amutable it's going to be mutable notimmutable because we're going to beupdating the ticket count within it uhit's going to have those seeds and thoseseeds are going to be B token Lotteryand then the bump is going to equaltoken lottery. bump this is so that Ican easily derive it so Pub tokenLottery token Lottery info all right sonow we have seeds the seeds for this oneis going to betoken uncore Lottery dot ticket it'sgoing to be the number of tickets so buttotal tickets so it's going to be thecurrent ticket number number two L Lebyes little Indian bytes that's going tobebump and then we're going to beinitializing this is going to be ticketmint it's going to be once again anotherinterface account of uhinfomint so we're missing some code here uhbecause it's a mint we have to provideall the information for it so mint uhdecimals equals z uh mintAuthority equals the we're going to havethis as the collection mint thatcollection mint is going to be verypowerful yet again uh looks like I'mmissing a colon that is fine there wego mint freeze Authority is going to bethat collection mint againmint uh tokenprogram is going to be that tokenprogram all right so you can see herewe're already missing some things we aremissing the token program and we'regoing to so it's probably going to sayright here yeah missing token programand we're also missing that collectionmint uh so let's go ahead and createthose real quick so Pub is going to bethe token program token interface allright so we need that that collectionmint account um this collection mint isgoing tobeaccount is going to be mutable becausewe're going to increase the number oftokens on it while we're going to use itbasically uh the seeds are going to bethe collection mint account again socollectionmint. asre and then bump unfortunatelywe couldn't save it because it's not ouraccount collection mint Enterprise an nomint uh all right so we have that nextwe're going to need a few things uhwe're going to need a a metad accountfor our ticket mint we're going to needthat same Master Edition account that wehad earlier and then we're going to needalso a the The Collection metadataaccount as well so let's go and buildthoseout all right so first off we havea new account we're going to do thefirst one is the metad account so seedsare the same as earlier so let's go grabthose seeds where do theygo um it's an initializedLottery it is going to be right here nothere um right here all right so seedsare these and go ahead and grab all ofthis code

(Editor in charge: article)

Related content
Wonderful recommendations
Popular Clicks
Friendly links