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

[rust] Time: 2025-07-11 11:51:02 Source: AIHackNode Author: ai Click: 16 times
need one of thoseaddresses give it a moment and ai job loss resetit willcreate an address that starts with MNTsomething. Json so that address is wherewe're going to put our token mint let'sput a token mint at that address that isSPLtokencreate token and we're going to specifythe program ID of the token extensionsprogram which starts with token and thena z and then all this other stuff soI'll just paste that inand we want to use the metadataextension because it makes our liveseasier enablemetadata um and we will finally we willsay our um address to use to make ournew token great that's done um so we'venow made a new token on salana um theaddress of our token is the same as theone we we ground earlier uh it has ninedecimals which means that if you've evertransferred Soul before you'll noticethat to send one Soul you send 1 billionlamp ports it's the same with our newtoken we've specified nine decimalplaces so you send uh 1 billion wholeminor units to send one major unit uhthis is actually not even a blockblockchain thing it's a financialprogramming thing whenever you sendsomeone $250 in the real world youprobably actually send them 250 centsand it's because computers don't handledecimal very well they work in binary soif we always send whole numbersof whatever the mining unit is sentslamp ports your own tokens mining unitit makes it easier for the computers souh We've made our new mint let's gocheck it out in salana Explorer so I'min salana Explorer and I will say devetthank you very much and I will paste inour token mint address and check it outit says unknown token it says token 22min which is a using token extensionsum there haven't been any tokens mintedyet nine decimals as we just talkedabout um and there's not really thatmuch here there's no kind of metadata oranything yet um and it says unknowntoken so let's fix that let's add somemetadata now to do that you're going toneed to upload firstly a an image andthen a Json file somewhere public on theinternet if we were making a token formain net a real ious production token wewould probably want to use adecentralized storage service somewherelike R weave um or Iris uh that is abasically kind of like a blockchain butfor Json files and images and all thatkind of stuff uh rather than you knowsalana is a blockchain for transactionslike traditional blockchains these uhdecentralized storage services aredesigned to um keep things online for areally long time because they're notowned by anybody um and they'reresilient to attacks and all this kindof stuff they're they're a good place toput something that you want to be aroundfor a really long time um in our case uhthis is just a test token so we're goingto use GitHub and we'll just be usingthose raw GitHub links the importantthing to realize here is that our linkhas to just open our image file or ourJson file directly no HTML no anythingelse around um make sure that when youvisit that link in your web browser itjust shows an image file or some Jsondepending on the image or the Json soupload the image first add it to ametadata file that looks a little bitlike this you'll just have a name asymbol a description and the image thatyou uploadedearlier take that metadata file andupload it to somewhere public as well ummake sure that you have a URL that loadsyour metadata file directly in yourbrowser for example I have one righthere there we go um so I can now addthat metadata to my token soSPL token and we're going tosay uhinitializemetadata and we're going to specify ourtoken uh I'm just going to get it fromthe the file name now MNT file name andwe're going to specify name for ourtoken and a symbollike and then finally that URL to get tothat Json file uh and then salana willgo and take that Json file and put thatimage put that data I mean to saydirectly inside the blockchain you'llsee uh everything has gone successfullyand if we go back to salana Explorer atthis point and reloadour um our token you'll see unknowntoken has been replaced by example um aswe specified before and now there's awhole bunch of metadata now name symbolthe URI with the image uh that's all nowshowing on salana Explorer so great wenow have a token mint and it looks niceso we can use this token mint to Minttokens let's mint some tokens and as themint Authority we can mint them intoanyone's account but let's mint someinto our own account so that we cantransfer them out to other people if welike SPL token uh we're going to need atoken account in our personal mintAuthority account just to store thesetokens so create accounts um for thismintso so we're just making uh a PDA and itwill or an Associated token account tostore um just these tokens in our ownpersonal accountonce we've done that we can go and mintsome new tokens that's SPL token mintour token which is MNT something orother and how many tokens do we wantlet's say 100 maybe 1,000 tokens that'sgood done let's go and look at firstlyour token mint and then our own personalaccount to uh see what's changed so ifwe go back to salana Explorer and lookat the token mint again you can see thecurrent Supply which is the amount oftokens that have ever been minted is1,000 in fact let's let'smint another1,000 you can see salana Explorerupdates again and you can see 2,000tokens have been minted um Also let'scheck our personal account uh as themint Authority which we called what wasit BOS something or rather there we goand if we check in our ownaccount we can see that 0.5 sold that wegave to to ourselves earlier minus a fewtransaction fees but more importantly ifwe check intokens we can see that we have 2,000 ofthesetokens and the type of tokens is ourtoken mint address that we made beforewe can transfer these tokens we can burnthem we can delegate them we can do allthe normal things we do with

(Editor in charge: article)

Related content
Wonderful recommendations
Popular Clicks
Friendly links