0

Faced with problem that CreateMetadataAccountV3 simulate fails with Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: An account required by the instruction is missing error.

Here is my piece of code:

        let (metadata,_) =
            Pubkey::find_program_address(
                &[
                    b"metadata",
                    &mpl_token_metadata::ID.to_bytes(),
                    &mint_keypair.pubkey().to_bytes()
                ],
                &mpl_token_metadata::ID
            );

        let create_metadata_account_v3_instructions =
            mpl_token_metadata::instructions::CreateMetadataAccountV3{
                metadata,
                mint: mint_keypair.pubkey(),
                mint_authority: self.keypair.pubkey(),
                payer: self.keypair.pubkey(),
                update_authority: (self.keypair.pubkey(), false),
                system_program: spl_token::ID,
                rent: None,
            }.instruction(CreateMetadataAccountV3InstructionArgs {
                data: DataV2 {
                name: "test".to_string(),
                symbol: "TST".to_string(),
                uri: "https://blog.hubspot.com/hs-fs/hubfs/image8-2.jpg".to_string(),
                seller_fee_basis_points: 0,
                creators: None,
                collection: None,
                uses: None,
            },
            is_mutable: false,
            collection_details: None,
        });

        let recent_blockhash = self.rpc_client.get_latest_blockhash()?;

        let transaction: Transaction = Transaction::new_signed_with_payer(
            &[
                create_account_instruction,
                initialize_mint_instruction,
                create_associated_token_account_instruction,
                mint_to_instruction,
                create_metadata_account_v3_instructions
            ],
            Some(&self.keypair.pubkey()),
            &[&mint_keypair, &self.keypair],
            recent_blockhash,
        );

        println!("{:?}", self.rpc_client.simulate_transaction(&transaction)?.value);

And simulate result:

RpcSimulateTransactionResult { err: Some(InstructionError(4, MissingAccount)), logs: Some(["Program 11111111111111111111111111111111 invoke [1]", "Program 11111111111111111111111111111111 success", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]", "Program log: Instruction: InitializeMint", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2919 of 999850 compute units", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success", "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]", "Program log: Create", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]", "Program log: Instruction: GetAccountDataSize", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1595 of 990038 compute units", "Program return: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA pQAAAAAAAAA=", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success", "Program 11111111111111111111111111111111 invoke [2]", "Program 11111111111111111111111111111111 success", "Program log: Initialize the associated token account", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]", "Program log: Instruction: InitializeImmutableOwner", "Program log: Please upgrade to SPL Token 2022 for immutable owner support", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1405 of 983425 compute units", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]", "Program log: Instruction: InitializeAccount3", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4214 of 979545 compute units", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success", "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 21883 of 996931 compute units", "Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]", "Program log: Instruction: MintTo", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4572 of 975048 compute units", "Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success", "Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]", "Program log: IX: Create Metadata Accounts v3", "Unknown program 11111111111111111111111111111111", "Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 8450 of 970476 compute units", "Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: An account required by the instruction is missing"]), accounts: None, units_consumed: Some(29524), return_data: None, inner_instructions: None }

You see that I'm sending a batch of instructions, so let me know if you need the whole code.

Thanks!

1
  • 1
    Are you passing in the actual metadata program itself? This catches quite a few people at (it did me at the start too). When trying to CPI into another program you have to remember to pass the program into your account list as well with your other accounts.
    – Tony Boyle
    Feb 9 at 2:28

1 Answer 1

0

The error "Unknown program 11111111111111111111111111111111" makes it seem like you're not passing the system program to the metadata program in your program -- be sure to include it!

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.