DEV Community

Tejaswa Hinduja
Tejaswa Hinduja

Posted on

Solana Token Launchpad (with metadata) -2

I hope you are coming from the previous blog
So we created tokens using the token-22 program which supports extensions (Metadata Pointer Extension) stored directly in the mint account.

Token-2022 can store basic metadata on-chain:-name,symbol,uri,etc.
The uri is a link to off-chain metadata json
{
"name": "My Token",
"symbol": "MT",
"description": "Example token",
"image": "arweave://...",
"attributes": [...]
}
There are a few ways to store this json, the easiest i found is through irys(arweave).Lets get started with that, install these first @irys/web-upload-solana , @irys/web-upload
Lets first set up the a irys uploader

and fund the irys account so that they give us some storage to upload our data

Now do you remember in the last blog we built a form for the user to enter some metadata for the token, now we need to upload that metadata and convert it into a metaplex std json


What this function does is it takes the input from the form and converts it into a json(metaplex std) and then gives it to irys which then returns a uri.
Now we store this uri in our metadata object and use it while creating the mint account
createInitializeInstruction({
programId: TOKEN_2022_PROGRAM_ID,
mint: mintKeypair.publicKey,
metadata: mintKeypair.publicKey,
name: metadata.name,
symbol: metadata.symbol,
uri: metadata.uri,
mintAuthority: wallet.publicKey,
updateAuthority: wallet.publicKey,
}),

And we are done, few things i would like to add, I am storing only the json ideally you want to store everything on areweave or ipfs including the image.
Also how do wallets discover the metadata and show token image:-
When a wallet detects a token in your account, it first reads the mint account from the token program From this it learns about mint address,extensions and some other stuff.If the mint uses the TokenMetadata extension, the wallet reads:name,symbol,uri.

If you found the blog helpful give it a like and follow, also connect on socials:-
Twitter:-https://x.com/Tej_Codes
LinkedIn:-https://linkedin.com/in/TejaswaHinduja

Top comments (0)