2

I want to create a token entangler that pushes the minting to the user instead of requiring pre-minting by the owner. For that, I'm creating an Anchor program that first mints a collection token and its metadata, before allowing holders of the original collection to entangle their token (transfer OG token + mint entangled version and create metadata).

My problem is that I keep getting a NotEnoughAccountKeys error. My logs look like this for the failing instruction:

Program log: Instruction: Create Metadata Accounts v2
Program log: Error: NotEnoughAccountKeys
Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 3932 of 103222 compute units
Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: insufficient account keys for instruction
Program 6UnTeNe18TsxBPJfLYxRYUnWyUfALuxD1e23gMswxSN8 consumed 100710 of 200000 compute units
Program 6UnTeNe18TsxBPJfLYxRYUnWyUfALuxD1e23gMswxSN8 failed: insufficient account keys for instruction

The call that triggers this log is the following:

let original_metadata =
    Metadata::from_account_info(&ctx.accounts.original_collection_metadata).unwrap();

let authority_bump = *ctx.bumps.get("entangler_authority").unwrap();
let authority_seeds = &[AUTHORITY_SEED.as_bytes(), &[authority_bump]];
let authority_signer_seeds = &[&authority_seeds[..]];

// Mint the token
let mint_ctx = CpiContext::new_with_signer(
    ctx.accounts.token_program.to_account_info(),
    MintTo {
        mint: ctx.accounts.entangled_collection_mint.to_account_info(),
        authority: ctx.accounts.entangler_authority.to_account_info(),
        to: ctx
            .accounts
            .entangled_collection_mint_token_account
            .to_account_info(),
    },
    authority_signer_seeds,
);
token::mint_to(mint_ctx, 1)?;

// Create metadata
invoke_signed(
    &create_metadata_accounts_v2(
        ctx.accounts.token_metadata_program.key(),
        ctx.accounts.entangled_collection_metadata.key(),
        ctx.accounts.entangled_collection_mint.key(),
        ctx.accounts.entangler_authority.key(),
        ctx.accounts.signer.key(),
        ctx.accounts.entangler_authority.key(),
        original_metadata.data.name,
        original_metadata.data.symbol,
        original_metadata.data.uri,
        Some(vec![Creator {
            address: ctx.accounts.signer.key(),
            verified: true,
            share: 100,
        }]),
        royalties,
        false,
        true,
        None,
        None,
    ),
    &[
        ctx.accounts.entangled_collection_metadata.to_account_info(), // Metadata
        ctx.accounts.entangled_collection_mint.to_account_info(),     // Mint
        ctx.accounts.entangler_authority.to_account_info(),           // Mint authority
        ctx.accounts.signer.to_account_info(),                        // Payer
        ctx.accounts.entangler_authority.to_account_info(),           // Update authority
        ctx.accounts.system_program.to_account_info(),                // System program
        ctx.accounts.rent.to_account_info(),                          // Rent
    ],
    authority_signer_seeds,
)?;

Looking at metadata creation on an explorer, I can see that these are the correct accounts needed, other questions have similar accounts, I looked at Cardinal's code but I still can manage to get it to work

1 Answer 1

1

Turns out the error was setting the creator verified to true

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.