2

I have followed this tutorial.

It works fine but I have 2 questions.

How to make metadata immutable?

  // Instruction to initialize Metadata Account data
  const initializeMetadataIx = createInitializeInstruction({
    programId: TOKEN_2022_PROGRAM_ID, // Token Extension Program as Metadata Program
    metadata: mintAddress, // Account address that holds the metadata
    updateAuthority: updateAuthority, // Authority that can update the metadata
    mint: mintAddress, // Mint Account address
    mintAuthority: updateAuthority, // Designated Mint Authority
    name: metaData.name,
    symbol: metaData.symbol,
    uri: metaData.uri,
  });

updateAuthority does not accept null.

Other question is that I want to update metadata with another request, if they are mutable but I cannot find the Instruction to do that. @solana/spl-token-metadata package there is not tutorial on that

3 Answers 3

2

Use the tokenMetadataUpdateAuthority helper and set newAuthority to null.

https://solana-labs.github.io/solana-program-library/token/js/functions/tokenMetadataUpdateAuthority.html

It invokes this instruction on the token extensions program: https://github.com/solana-labs/solana-program-library/blob/master/token/program-2022/src/extension/token_metadata/processor.rs#L166

7
0

this worked for making it immutable

createUpdateAuthorityInstruction({ programId, metadata: mint, oldAuthority: updateAuthorityPublicKey, newAuthority, }) 
0
export const getUpdateMetadataFieldIx = async ({
  mintAddress,
  updateAuthority,
  field,
  value,
}: {
  mintAddress: PublicKey;
  updateAuthority: PublicKey;
  field: "name" | "symbol" | "uri";
  value: string;
  isImmutable?: boolean;
}) => {
  const updateFieldIx = createUpdateFieldInstruction({
    programId: TOKEN_2022_PROGRAM_ID,
    metadata: mintAddress,
    updateAuthority: updateAuthority,
    field, // Key of the field to update
    value, // Value of the field to update
  });

  return updateFieldIx;
};

this is for updating metadata

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.