1

I am trying to mint a edition from a master edition with the following metaplex function:

let accounts = vec![
        ctx.accounts.new_metadata.to_account_info(),
        ctx.accounts.new_edition.to_account_info(),
        ctx.accounts.master_edition.to_account_info(),
        ctx.accounts.new_mint.to_account_info(),
        ctx.accounts.edition_mark_pda.to_account_info(),
        ctx.accounts.new_mint_authority.to_account_info(),
        ctx.accounts.payer.to_account_info(),
        ctx.accounts.token_account_owner.to_account_info(),
        ctx.accounts.token_account.to_account_info(),
        ctx.accounts.new_metadata_update_authority.to_account_info(),
        ctx.accounts.metadata.to_account_info(),
        ctx.accounts.token_program.to_account_info(),
        ctx.accounts.system_program.to_account_info(),
        ctx.accounts.rent.to_account_info(),
    ];
    invoke(
        &mint_new_edition_from_master_edition_via_token(
            ctx.accounts.token_metadata_program.key(),
            ctx.accounts.new_metadata.key(),
            ctx.accounts.new_edition.key(),
            ctx.accounts.master_edition.key(),
            ctx.accounts.new_mint.key(),
            ctx.accounts.new_mint_authority.key(),
            ctx.accounts.payer.key(),
            ctx.accounts.token_account_owner.key(),
            ctx.accounts.token_account.key(),
            ctx.accounts.new_metadata_update_authority.key(),
            ctx.accounts.metadata.key(),
            ctx.accounts.metadata.key(),
            1,
        ),
        &accounts,
    )?;

Unfortunatly I always receive this error:

'Program log: Instruction: MintEdition',
    'Instruction references an unknown account F5mAJWXVpQ4rupmvMGTY7ZDqK7UUzSkS7dTfTRX6WMLf',
    'Program 4euwMgqxB9GkxVBY7uXKRRuC68yhkNbsVUhDPYS1mbhD consumed 18852 of 200000 compute units',
    'Program 4euwMgqxB9GkxVBY7uXKRRuC68yhkNbsVUhDPYS1mbhD failed: An account required by the instruction is missing'

My function call from the frontend looks like the following:

await program.methods
            .mintEdition()
            .accounts({
                newMetadata: metadataAddress,
                newEdition: newEditionAddress,
                masterEdition: masterEditionAddress,
                newMint: newMint.publicKey,
                editionMarkPda: editionMarkPda,
                newMintAuthority: provider.wallet.publicKey,
                payer: provider.wallet.publicKey,
                tokenAccountOwner: provider.wallet.publicKey,
                tokenAccount: ata,
                newMetadataUpdateAuthority: provider.wallet.publicKey,
                metadata: metadataAddress,
                tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
                tokenProgram: TOKEN_PROGRAM_ID,
                systemProgram: anchor.web3.SystemProgram.programId,
                rent: anchor.web3.SYSVAR_RENT_PUBKEY,
            })
            .rpc();

This is how I get the editionMarkPda in the frontend:

await anchor.web3.PublicKey.findProgramAddress(
    [
        Buffer.from("metadata"),
        TOKEN_METADATA_PROGRAM_ID.toBuffer(),
        masterEditionMint.publicKey.toBuffer(),
        Buffer.from("edition"),
        Buffer.from("1"),
    ],
    TOKEN_METADATA_PROGRAM_ID
)

Any ideas what is missing?

1
  • It's probable that you're generating one of the PDAs wrongly. The edition_mark_pda is an easy one to get wrong. Can you show how you're generating it on your frontend?
    – Ademola
    Commented Oct 21, 2022 at 12:23

1 Answer 1

2

Try deriving editionMarkPda like this; It's what worked for me:

const EDITION_MARKER_BIT_SIZE = 248;
let edition = 1; // your edition in this case is 1

let editionNumber = new anchor.BN(Math.floor(edition/EDITION_MARKER_BIT_SIZE));
console.log("editionNumber: ", editionNumber.toString());

let editionMarkPda = (await anchor.web3.PublicKey.findProgramAddress([
  Buffer.from("metadata"), TOKEN_METADATA_PROGRAM_ID.toBuffer(), masterEditionMint.publicKey.toBuffer(),
  Buffer.from("edition"), Buffer.from(editionNumber.toString())], TOKEN_METADATA_PROGRAM_ID
))[0];
3
  • Thank you that helped, unfortunatly I am still receiving the same error.
    – philman
    Commented Oct 22, 2022 at 9:25
  • It's tricky to pinpoint the offending account in these kinds of cases. Try logging your public keys in your frontend to see which matches the "unknown account". If you can share a link to a github repo, I could look through it
    – Ademola
    Commented Oct 22, 2022 at 10:19
  • When logging all accounts I am passing to the instruction via the frontend none matches the unknown account which is irritating me. Did you receive a message on discord? I would provide my github there. Thanks a lot for you help.
    – philman
    Commented Oct 22, 2022 at 11:11

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.