0

I am trying to implement the NFT burn from the metaplex programm: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/token-metadata/js/src/generated/instructions/BurnNft.ts

I managed to get all the accounts I need except the

 * @property [_writable_] masterEditionAccount MasterEdition2 of the NFT

Can someone explain me how I can derive it?

My guess is i do the same as for

 * @property [_writable_] metadata Metadata (pda of ['metadata', program id, mint id])

But then i need to add "edition" to it some how. But I dont know how. This is how I derive the meta data pda.

bool createdMetaDataPda  = PublicKey.TryCreateWithSeed(
            new PublicKey(nft.MetaplexData.mint),
            "metadata",
            TokenProgram.ProgramIdKey,
            out PublicKey derivedMetaDataAccount);

Thank you for any help :)

1 Answer 1

1

You're on the right track there! Just make sure you use the Token Metadata Program ("meta...") to derive, not the Token program.

So if I'd do it in type script it would look like this:

function getMasterEditionAccount(mint : web3.PublicKey) : web3.PublicKey {
  const seed1 = Buffer.from(anchor.utils.bytes.utf8.encode("metadata"));
  const seed2 = Buffer.from(mpl.PROGRAM_ID.toBytes());
  const seed3 = Buffer.from(mint.toBytes());
  const seed4 = Buffer.from(anchor.utils.bytes.utf8.encode("edition"));
  const [metadataPDA, _bump] = web3.PublicKey.findProgramAddressSync([seed1, seed2, seed3, seed4], mpl.PROGRAM_ID);
  return metadataPDA;
}

So on C# that would probably look something like this:

        var seeds = new List<byte[]>();
        seeds.Add(Encoding.UTF8.GetBytes("metadata"));
        seeds.Add(new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s").KeyBytes);
        seeds.Add(mint.KeyBytes);
        seeds.Add(Encoding.UTF8.GetBytes("edition"));

        PublicKey.TryFindProgramAddress(
            seeds, 
            new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"),
            out PublicKey metadataPDA, out var _bump);

Maybe there is a library that holds the Token Metadata Program ID, i don't know.. Also, i didn't test the code. Give it a try and let us know ;)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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