3

I am trying to create Metadata for an NFT. I found this function and the second parameter is "metadata_account". I have been looking everywhere trying to find what this is. I thought I was creating the metadata, so I'm really confused what its asking for.

My guess: To create a new mint, I passed in a newly generated Keypair pubkey, is this similar, where I just pass in a newly created Pubkey?

mpl_token_metadata::instruction::create_metadata_accounts_v3 Documentation

1 Answer 1

2

metadata_account is the account that stores the metadata for the mint and is a PDA. enter image description here

From the client you can derive it using @metaplex-foundation/js:

const metadataAccountAddress = await metaplex
  .nfts()
  .pdas()
  .metadata({ mint: mintAddress }) // pubkey of the mint

If you are creating the metadata account via a CPI in Anchor, you can also validate the account address using mpl_token_metadata crate.

use mpl_token_metadata::pda::find_metadata_account
///CHECK:
#[account(
    mut,
    address=find_metadata_account(&mint.key()).0
)]
pub metadata_account: UncheckedAccount<'info>

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.