Current location: Current location: Home > solidity > Solana Developer Bootcamp 2024 - Learn Blockchain and Full Stack Web3 Development - Projects 1-9 - Ep72 Text
Solana Developer Bootcamp 2024 - Learn Blockchain and Full Stack Web3 Development - Projects 1-9 - Ep72
[solidity] Time: 2025-07-11 11:35:07 Source: AIHackNode Author: html Click: 81 times
righthere how much did I grab I forget therewe go okay seeds collection mint it'snot going to be ai programming pythonthe The Collection mintit's going to be that ticketmint all right let's go ahead and grabthis is going to be the metadata accountso Pub we're going to say is a u ticketmetadata once again it's going to becreated by the metadata smart contractand the other one that we need is thatMaster Edition again so let's go grabthat you need this so that you can add aa nft to a collection um so instead ofthe collection mint it's going to bethat ticket mint again uh this is goingto be the Ticket MasterEdition all right so that should beright um okay so it's already telling usneed the metad program because we'redoing stuff metad program so Pub tokenmetad program token metad perfect okayand the next thing that we need to do issince we're buying a ticket we need adestination we need a token account togive for this um so let's go and putthat in here this is one thing we'regoing to need is the associated tokenaccount which we'll do in just a momentsocount in it pair equals pair uh we'regoing to do theassociated token mint equals token mintAssociated Authority this one's going tobe the pair because we're going to giveit to that person and thenAssociatedtoken token program equals the tokenprogramand then we have to create that specificaccount so it's going to be a pubdestination equals interfaceaccount of type info lifetime info tokenaccount Perfect all right and becausewe're using the token the associatedtoken program we once again need thesociate token program set so let's setit down here PubuhAssociated token program Associatedtoken and if you remember when we didthe master Edition earlier we alsoneeded rent so let's add of that realquick boom all right so that should beeverything for buying tickets now let'sactually write the code to buy thetickets go back up here and let's getstarted before we get started let'sactually do an anchor build just to makesure we're doing allright all right it passed just had awarning because that we have yourcontexts that's okay so first thing I'mgoing to get that clock so that we cantell if whether or not someone canactually buy uh a ticket so now we havethe clock uh then we're going to get theticket name um just so that we make surethat we set the ticket name this isgoing to be name we're going to do alittle bit of uh string concatenationand rust uh this is going to be Pluscontext. account accounts. tokenlottery. total tickets. two string asstringboom uh and now let's check so if clock.slot is less than context. accounts.token Lottery dot uh this is going to beLotter start time so the the lottery isnot ended or clock. slot is greater thanthe end time because we don't wantanybody buying after it ends uh we wantto throw an error uh we'll go Lotterynot open you can see here we alreadyhave an error code so that we need to dowe need to actually create those errorcodes so let's go down to the bottom andcreate those error codes uh so the waythat you create eror codes in in Salprograms or Salon smart contracts as youuse the macro errorcode Pub enum you can see it actuallyalready new Lottery is not open it's amessage that's the message there's ourenumall right so let's scroll back to ourcode we have the ticket name we've donethe clock slot check that someone's iseligible to buy the tickets now weactually have to do the buying oftickets so if you remember there was aprice to pay whenever you do the ticketso we're going to take thatmoney um from the buyer and deposit itinto our Lottery pot souh CPI context uh this is going to benew because we don't need any PDAsignatures here um we're going to docontext. accounts. this is the systemprogram2 account info uh we're going tohave to doSystem Program colon colontransfer whoops there we go all right soit's going to be from the pair to theToken Lottery it's not the authority cuzthat would be myself it's going to bethe token Lottery uh it's the tokenLottery count itself and the lorts isspecifically the token Lottery pricethat is not in this section it isactually outside of the transfer um it'sdownhere uh and it's actually just theLamportamount there wego all right so we've done the transfernext thing we need to do is we need tocreate the ticket so as earlier we'regoing to do a lot of the same thingwe're going to do let signerseeds um it's not going to be tokenLottery it's going to be the collectionmint because we have to use thecollection mint authority to create abunch of these a new ticket off of thiscollection and we have to Mint the newtoken so mint to once again CPI contextuh new with sereruh we're going to just enter a bunch ofthings realquick there wego uh the program signer seeds are areference the program is going to be acontext. accounts. tokenprogram uh. two accountinfo then we're going to use the mint2 the same one as the lasttime and we're going to Mint to the mintis going to be let's just set all thatit's a ticket mint we're going to Mintit to the destination and the authorityto do that minting is going to be thecollection mint Perfect all right solet's see all the errors that we have sofirst off I realize that this needs tobe bumps because that is the current waythat you grab the bump and see that mintto instruction what is so I'm missingsomething in the instruction uh this iswe're missing the amount that's okayvery easy fix it's going to be commaone there we go so we minted a single asingle token to the ticket of the ticketMin next up we're going to go create themetad accounts and create the masterEdition I'm going to go ahead and grabthat from the token Lottery and we'lljust add updated asneededso these two righthere I'm going to copy and paste thosejust so this save us a lot
(Editor in charge: go)
Solidity, Blockchain, and Smart Contract Course – Beginner to Expert Python Tutorial - Ep99XRP Ripple LIVE Senate Brad Garlinghouse - FROM WALL STREET TO WEB3 - Martyn Lucas Investor - Ep27
Related content
- GenAI Essentials – Full Course for Beginners - Ep85
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep148
- One On One Interview With Abisoye Bello _ Host_ Patricia Nkwane - Ep2
- Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep30
- Getting started with Web3 in 2025 _ Deep Dive Explainer - Ep8
- Web3 & Crypto Will Change The World As We Know It! Yat Siu - Ep4
- Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep3
- XRP Ripple LIVE Senate Brad Garlinghouse - FROM WALL STREET TO WEB3 - Martyn Lucas Investor - Ep7
- GenAI Essentials – Full Course for Beginners - Ep101
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep37
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep274
- One On One Interview With Abisoye Bello _ Host_ Patricia Nkwane - Ep8
- Godfather of AI_ I Tried to Warn Them, But We’ve Already Lost Control! Geoffrey Hinton - Ep1
- Web3 & Crypto Will Change The World As We Know It! Yat Siu - Ep13
Wonderful recommendations
- Harvard CS50’s Artificial Intelligence with Python – Full University Course - Ep20
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep292
- Getting started with Web3 in 2025 _ Deep Dive Explainer - Ep12
- Web3 Developer in 2024 Roadmap_ Solidity, Smart Contract, and Blockchain Development [Full Course] - Ep51
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep157
- Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course - Ep253
Popular Clicks