I'm trying to update primary_sale_happened to true in the metadata's NFT. I have deployed my program with anchor. But when I test it, I have this error printed in the console: Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: An account required by the instruction is missing. I suppose that I pass wrong inputs to the update_primary_sale_happened_via_token, but I didn't get what I have to pass to the method.

Here some context.

This is the code that I'm using in the rust program:

            ctx.accounts.metadata.key(), // desc="Metadata key (pda of ['metadata', program id, mint id])")
            ctx.accounts.owner_authority.key(), // desc="Owner on the token account")
            ctx.accounts.owner_token_account.key(), // desc="Account containing tokens from the metadata's mint")

Note: mpl_instruction is just an alias of mpl_token_metadata::instruction

And this is the code from my test file:

await program.methods.primarySale(
            new anchor.BN(saleAmount)
                mint: mint,
                ownerTokenAccount: ownerTokenAddress, // pass to the update_primary_sale_happened_via_token as fourth param
                ownerAuthority: wallet.publicKey, // pass to the update_primary_sale_happened_via_token as third param
                buyerTokenAccount: buyerTokenAddress,
                buyerAuthority: buyer.publicKey,
                metadata: metadataAddress, // pass to the update_primary_sale_happened_via_token as second param

I get the metadata with this call:

const metadataAddress = (await anchor.web3.PublicKey.findProgramAddress(

The owner_authority is the wallet's publickey which have been used to mint. wallet.publicKey

And the owner_token_account is retrieved with this call:

const ownerTokenAddress = await anchor.utils.token.associatedAddress({
            mint: mint,
            owner: wallet.publicKey

Here are the versions of the libs that I use for the program:

anchor-lang = "0.25.0"
anchor-spl = "0.25.0"
mpl-token-metadata = { version = "1.4.0", features = ["no-entrypoint"] }

What I'm doing wrong with the accounts? Is there an other account to pass to the method?

Thanks for your help.

1 Answer 1


It does not seams like there needs to be any more accounts needed in this instruction.

  • So, if I provide the right inputs to the update_primary_sale_happened_via_token method. That should mean, that I have to pass more account(s) to the vec accounts of the invoke method? Something like: invoke(instruction, $[metadata, owner, token, /* more accounts here? */]). N.B. I tried to pass system_program accounts to the vec but does not fix my problem.
    – nitame
    Sep 24, 2022 at 7:27

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.