I’m working on a Solana project using Rust and the Anchor framework to build NFT functionality. I need to create a method that can mint edition NFTs based on an existing master edition token.
I’m trying to utilize the mpl_token_metadata::instruction::mint_new_edition_from_master_edition_via_token function, but I’m uncertain about two specific parameters. It requires both master_metadata and master_metadata_mint arguments, but the official documentation seems to only require the master record metadata account.
My question is: What specific account keys should I input for the master_metadata and master_metadata_mint parameters?
Here’s my current implementation:
pub fn mint_edition_from_master(
ctx: Context<MintEditionContext>,
edition_number: u64,
) -> Result<()> {
let account_infos = vec![
ctx.accounts.spl_token.to_account_info(),
ctx.accounts.edition_metadata.to_account_info(),
ctx.accounts.edition_account.to_account_info(),
ctx.accounts.master_edition_account.to_account_info(),
ctx.accounts.edition_mint.to_account_info(),
ctx.accounts.mint_authority.to_account_info(),
ctx.accounts.funding_account.to_account_info(),
ctx.accounts.holder.to_account_info(),
ctx.accounts.holder_token_account.to_account_info(),
ctx.accounts.metadata_authority.to_account_info(),
ctx.accounts.master_metadata.to_account_info(),
ctx.accounts.master_metadata.to_account_info(),
ctx.accounts.system_program.to_account_info(),
ctx.accounts.rent_sysvar.to_account_info(),
];
invoke(&mint_new_edition_from_master_edition_via_token(
ctx.accounts.spl_token.key(),
ctx.accounts.edition_metadata.key(),
ctx.accounts.edition_account.key(),
ctx.accounts.master_edition_account.key(),
ctx.accounts.edition_mint.key(),
ctx.accounts.mint_authority.key(),
ctx.accounts.funding_account.key(),
ctx.accounts.holder.key(),
ctx.accounts.holder_token_account.key(),
ctx.accounts.metadata_authority.key(),
ctx.accounts.master_metadata.key(),
ctx.accounts.master_metadata.key(),
edition_number
), account_infos.as_slice())?;
msg!("Successfully minted edition NFT!");
Ok(())
}
#[derive(Accounts)]
pub struct MintEditionContext<'info> {
#[account(mut)]
pub edition_metadata: UncheckedAccount<'info>,
#[account(mut)]
pub edition_account: UncheckedAccount<'info>,
#[account(mut)]
pub master_edition_account: UncheckedAccount<'info>,
#[account(mut)]
pub edition_mint: UncheckedAccount<'info>,
#[account(mut)]
pub edition_mark_account: UncheckedAccount<'info>,
#[account(mut)]
pub mint_authority: Signer<'info>,
#[account(mut)]
pub funding_account: AccountInfo<'info>,
#[account(mut)]
pub holder: UncheckedAccount<'info>,
#[account(mut)]
pub holder_token_account: UncheckedAccount<'info>,
#[account(mut)]
pub metadata_authority: UncheckedAccount<'info>,
#[account(mut)]
pub master_metadata: UncheckedAccount<'info>,
pub spl_token: Program<'info, Token>,
pub system_program: Program<'info, System>,
pub rent_sysvar: AccountInfo<'info>,
}
Any guidance on the appropriate account mapping would be really beneficial!