I am using @solana/spl-token to create spl token, but I cant add metadata to the token, I know TOKEN_2022_PROGRAM_ID can do that, but how can I make it works with TOKEN_PROGRAM_ID?

Here is my code:

        fromPubkey: payer.publicKey,
        newAccountPubkey: keypair.publicKey,
        space: MINT_SIZE,
        programId: TOKEN_PROGRAM_ID,
      createInitializeMint2Instruction(keypair.publicKey, decimals, mintAuthority, freezeAuthority, programId)
  const signature = await sendAndConfirmTransaction(CONNECTION, transaction, [payer, keypair], confirmOptions);

1 Answer 1


You will need to add that using Metaplex Metadata Program](https://developers.metaplex.com/token-metadata)

Using UMI and the helpers that they provide, you can have both create SPL and add metadata instructions in a single method that they provide which you can use like this

import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { percentAmount, generateSigner, some } from '@metaplex-foundation/umi'
import { createFungible } from '@metaplex-foundation/mpl-token-metadata'

const umi = createUmi(clusterApiUrl("devnet"));

const mint = generateSigner(umi)
await createFungible(umi, {
  name: 'My Fungible',
  uri: 'https://example.com/my-fungible.json',
  sellerFeeBasisPoints: percentAmount(5.5),
  decimals: some(7), // for 0 decimals use some(0)

Don't forget to update with your NFT metadata for the name, symbol and off chain URI.

I wouldn't recommend using the old JS SDK because it isn't actively maintained.

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.