6

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?

4 Answers 4

4

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.

2
  • Even though, I added metadata to my token, all wallets and even Solana Explorer take metadata from the legacy token-list: github.com/solana-labs/token-list/blob/main/src/tokens/…. I can't update that file because its repo is read-only. So, in fact, I have no way to update my token logo and name. @Jacob Creech, I would appreciate any advice on resolving this issue. Commented Jul 19, 2022 at 18:30
  • 1
    createCreateMetadataAccountV2Instruction is deprecated. Can you create an updated version with createCreateMetadataAccountV3Instruction?
    – Maxareo
    Commented Apr 19 at 14:21
1

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.

0

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

2
  • 1
    the quality of this answer could be improved by elaborating the contents of the URLs
    – trent.sol
    Commented Jul 17, 2022 at 16:43
  • i tried this site "token-creator-lac.vercel.app" but i got this error undefined: failed to send transaction: Transaction simulation failed: Blockhash not found Commented Jul 26, 2022 at 17:21
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.