0

I have been trying to update the metadata for my Solana token, but I'm encountering difficulties. I have tried two different websites and even attempted to hard code the metadata, but none of these approaches have worked so far. I'm looking for guidance or suggestions on how to successfully update the token metadata. Below are the details of what I have attempted:

First Website:

Name: https://app.strataprotocol.com/launchpad/manual/new Steps followed: filled all info Issue faced: i got a error message " unable to process "

Second Website:

Name: https://token-creator-lac.vercel.app/ Steps followed: filled all info that asked Issue faced: just loading thats all Hard coding:

Approach: some github repos Issue faced: not worked faced many error i fixed still i got error I would appreciate any assistance, guidance, or alternative methods to successfully update the token metadata for my Solana token. Thank you in advance for your help!

1
  • The above code worked perfectly thank you! Commented Oct 14 at 19:59

2 Answers 2

1

We can use @metaplex-foundation/js. Please check the guide.

  • You have to use createCreateMetadataAccountV3Instruction instead of using createCreateMetadataAccountV2Instruction .

Please check "I want to add metadata to the Solana token on cli"

1

Here's a code you can use:

You need to have your wallet pk as an array Change mint address, name and symbol

import { Commitment, Connection, Keypair, PublicKey, Transaction, sendAndConfirmTransaction, SystemProgram} from "@solana/web3.js"
import wallet from "./wallet.json"
import  {createCreateMetadataAccountV3Instruction } from "@metaplex-foundation/mpl-token-metadata";

// We're going to import our keypair from the wallet file
const keypair = Keypair.fromSecretKey(new Uint8Array(wallet));

//Create a Solana devnet connection
const commitment: Commitment = "confirmed";
const connection = new Connection("https://api.devnet.solana.com", commitment);

// Define our Mint address
const mint = new PublicKey("zdbdfbdbn")

// Add the Token Metadata Program
const token_metadata_program_id = new PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s')

// Create PDA for token metadata
const metadata_seeds = [
    Buffer.from('metadata'),
    token_metadata_program_id.toBuffer(),
    mint.toBuffer(),
];
const [metadata_pda, _bump] = PublicKey.findProgramAddressSync(metadata_seeds, token_metadata_program_id);

(async () => {
    try {
        // Start here
        const metadaAccount = createCreateMetadataAccountV3Instruction(
            {
              metadata: metadata_pda,
              mint: mint,
              mintAuthority:keypair.publicKey,
              payer: keypair.publicKey,
              updateAuthority: keypair.publicKey,
              systemProgram: SystemProgram.programId,
            },
            {createMetadataAccountArgsV3: 
              {
                data:{
                  name: "xxx",
                  symbol: "xxx",
                  uri: "",
                  sellerFeeBasisPoints: 0,
                  creators: null,
                  collection: null,
                  uses: null

                },
                isMutable: true, 
                collectionDetails: null
              }
            }
        );
        const tx = new Transaction().add(metadaAccount);
        const txhash = await sendAndConfirmTransaction(
            connection,
            tx,
            [keypair]
        );
        console.log(`Success! Check out your TX here: https://solscan.io/tx/${txhash}?cluster=devnet`);
    } catch(e) {
        console.error(`Oops, something went wrong: ${e}`)
    }
})();

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.