Assistance needed: Creating a function for minting edition NFTs from master editions

Hey everyone! I’m working on a Solana Metaplex NFT project using Rust and Anchor-Solana. I’m trying to write a function that mints a new edition NFT from a master edition NFT.

I’m using the mpl_token_metadata::instruction::mint_new_edition_from_master_edition_via_token instruction, but I’m confused about some of the required arguments. The instruction needs both metadata and metadata_mint fields, but the Metaplex docs only mention needing the master record metadata account.

Can anyone explain which account keys or values I should use for metadata and metadata_mint? And why?

Here’s a simplified version of my code:

pub fn mint_edition_nft(ctx: Context<MintEdition>, edition_num: u64) -> Result<()> {
    let accounts = vec![
        ctx.accounts.token_program.to_account_info(),
        ctx.accounts.new_metadata.to_account_info(),
        // ... other accounts ...
    ];

    invoke(&mint_new_edition_from_master_edition_via_token(
        ctx.accounts.token_program.key(),
        ctx.accounts.new_metadata.key(),
        // ... other parameters ...
        ctx.accounts.metadata.key(),
        ctx.accounts.metadata.key(),
        edition_num
    ), accounts.as_slice())?;

    Ok(())
}

I’d really appreciate any help or insights on this! Thanks in advance!

hey there singingsnow! i’ve been tinkering with nft minting too and it can be pretty confusing at first. lemme see if i can help clear things up a bit for ya

so, the metadata and metadata_mint are actually two different things. the metadata is for the new edition you’re making, not the master. you gotta derive that address using find_metadata_account. and the metadata_mint? that’s the mint address for your shiny new edition token.

have you thought about how you’re creating the new mint for each edition? that’s a key step. each edition needs its own unique mint.

oh, and quick tip - double-check you’re not using the same account for both fields. that’ll def cause issues.

what’s your overall goal with this project? sounds pretty cool! have you run into any other snags along the way?

I’ve worked on a similar project recently, and I can clarify the confusion about the metadata and metadata_mint fields. The metadata field should be the address of the metadata account for the new edition NFT you’re minting. You’ll need to derive this address using the find_metadata_account function from the Metaplex SDK.

As for the metadata_mint, this should be the mint address of the new edition token you’re creating. It’s different from the master edition’s mint. You’ll need to create a new mint account for each edition NFT.

In your code, you’re using the same account for both fields, which isn’t correct. Here’s how you might adjust it:

let (new_metadata_address, _) = Pubkey::find_program_address(
    &[b"metadata", token_metadata_program.key().as_ref(), new_mint.key().as_ref()],
    token_metadata_program.key()
);

invoke(&mint_new_edition_from_master_edition_via_token(
    ctx.accounts.token_metadata_program.key(),
    new_metadata_address,
    // ... other parameters ...
    ctx.accounts.master_edition_metadata.key(),
    ctx.accounts.new_mint.key(),
    edition_num
), accounts.as_slice())?;

Hope this helps clarify things!

hey singingsnow, i’ve minted edition nfts before. the new edition’s metadata account should be derived with find_metadata_account, and metadata_mint is its mint address—make a fresh mint for each edition. using the same account for both won’t work, so update your code accordingly!