2

My token is program-controlled, i.e. my mint address (and authority) is a PDA.

For that reason, I have to create code within my Solana Program to add metadata to my token.

While I can easily mint, it has been a weekslong painful endeavor to try to cut through the jungle of metaplex complexities to achieve a simple feat: Add metadata to my token. So that it appears nicely in my customers' Phantom wallets.

I've created a github repo with the essence of the code I'm trying to get to work, see github addMeta.

Here's the error message I'm stuck at:

  1) addmeta
       Sets the token metadata:
     Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: An account required by the instruction is missing
      at Connection.sendEncodedTransaction (node_modules/@solana/web3.js/lib/index.cjs.js:7891:13)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async Connection.sendRawTransaction (node_modules/@solana/web3.js/lib/index.cjs.js:7848:20)
      at async sendAndConfirmRawTransaction (node_modules/@project-serum/anchor/dist/cjs/provider.js:172:23)
      at async AnchorProvider.sendAndConfirm (node_modules/@project-serum/anchor/dist/cjs/provider.js:88:20)
      at async MethodsBuilder.rpc [as _rpcFn] (node_modules/@project-serum/anchor/dist/cjs/program/namespace/rpc.js:15:24)
      at async Context.<anonymous> (tests/addmeta.js:58:5)

See code on github addMeta.

Any help greatly appreciated.

7
  • You are missing an account. Briefly scanning through your code seems you are missing the metaplex token metadata program. You just call mpl_token_metadata::id(), but you need to add it to your context.
    – Omega
    Commented Jul 18, 2022 at 12:29
  • @Omega, your comment should probably be an answer instead!
    – trent.sol
    Commented Jul 18, 2022 at 18:56
  • Agreed. It should be an answer. @ome Commented Jul 18, 2022 at 21:27
  • Tried passing metadata_program_id as an 8th account to the context, even though only 7 accounts are documented. At what position should I pass the 8th account? I tried first, last and a few others, but keep getting either "The program expected this account to be already initialized" (for mint) or "instruction expected an executable account" (for unspecified account). Are there any examples out there on how to call create_metadata_accounts_v3 properly, or at least some documentation that's accurate and includes all necessary accounts? Commented Jul 18, 2022 at 22:02
  • OK I'm one step further. I figured I accidentally tested on localnet, and it is clear we don't have a working metadata program there, so the error "expected and executable account" makes sense. Tried on Devnet, but getting custom program error: 0xb there. What is custom error 0xb and how can I fix it? Commented Jul 18, 2022 at 22:11

1 Answer 1

3

You are missing an account. Briefly scanning through your code seems you are missing the metaplex token metadata program.

You just call mpl_token_metadata::id(), but you need to add it to your context.

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.