When creating a token, I want to add symbol, name, and logo to my token so it shows up on wallets and explorers correctly.
How do I do that?
To add metadata to a spl-token, you need to use the Metaplex Metadata Fungible Token Standard.
With JavaScript, you can use the @metaplex-foundation/js
and @metaplex-foundation/mpl-token-metadata
libraries to create a metadata account associated with your token.
import { DataV2, createCreateMetadataAccountV2Instruction } from '@metaplex-foundation/mpl-token-metadata';
import { findMetadataPda } from '@metaplex-foundation/js';
const metadataPDA = await findMetadataPda(mintKeypair.publicKey); // This is derived from the mint account's public key
const tokenMetadata = {
name: "Test Token",
symbol: "TEST",
uri: https://token-creator-lac.vercel.app/token_metadata.json,
sellerFeeBasisPoints: 0,
creators: null,
collection: null,
uses: null
} as DataV2;
const createNewTokenTransaction = new Transaction().add(
createCreateMetadataAccountV2Instruction({
metadata: metadataPDA,
mint: mintPublicKey,
mintAuthority: userPublicKey,
payer: userPublicKey,
updateAuthority: userPublicKey,
},
{ createMetadataAccountArgsV2:
{
data: tokenMetadata,
isMutable: true
}
}
)
await sendTransaction(createNewTokenTransaction, connection);
The above sets the metadata to use the name
"Test Token", symbol
"TEST", and the logo to the image
field in the json from uri
.
createCreateMetadataAccountV2Instruction
is deprecated. Can you create an updated version with createCreateMetadataAccountV3Instruction
?
An important point to note: if your token is fungible, then according to the metaplex metadata standard, it must have a decimals value > 0. If your token has been set to decimal values 0 it will be displayed on UIs which comply with the metaplex metadata standard as an NFT even if it has supply > 1. So be sure to set decimals to at least 1 if you want your token to be displayed as a "token". This means that for all programmatic purposes for which you previously interacted with your mint, you must multiply token count by 10 since the on-chain amount values now represent "decitokens" not whole tokens.
Another method to add token metadata to a SPL token is using websites for it (which basically run the same command as jacob described).
E.g. with https://token-creator-lac.vercel.app/ or https://app.strataprotocol.com/launchpad
You can use now the Metadata Pointer Token Extension to add metada to tokens (not NFT's). This is way easier than using metaplex, and is a stardard since 2022, see this guide https://solana.com/developers/guides/token-extensions/metadata-pointer that coints a walk through on how to implement it. Here is a token with metadata created through this method https://solana.fm/address/5RDgetphrERHEwJMrkoKUqapzPXf4HMzcYwHbr3XtZ7C/transactions?cluster=devnet-solana