newbie here ! I'm trying to mint some token 2022 from a rust program. i followed every single instruction i found about turning a classic token 2017 to a 2022 compatible, like changin the default program_id and stuff.

My test script fails with "failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x4" (Owner does not match?)


use anchor_lang::prelude::*;
use anchor_lang::solana_program::program::invoke_signed;
use anchor_spl::metadata::mpl_token_metadata::instructions::FreezeDelegatedAccount;
use anchor_spl::metadata::mpl_token_metadata::instructions::ThawDelegatedAccount;
use anchor_spl::metadata::mpl_token_metadata::ID as MetadataTokenId;
use anchor_spl::token;
use anchor_spl::token_2022;
use anchor_spl::{
    token_interface::{TokenAccount, Mint, MintTo, mint_to, TokenInterface},
    token::{Approve, Mint as NftMint, Revoke, TokenAccount as NftTokenAccount},


    pub stake_mint: InterfaceAccount<'info, Mint>, // reward spl token
    /// CHECK: manual check
    #[account(seeds = ["mint".as_bytes().as_ref()], bump)]
    pub stake_authority: UncheckedAccount<'info>,
        associated_token::token_program = token_2022_program,
    pub user_stake_ata: InterfaceAccount<'info, TokenAccount>, // reward spl token ata
    pub token_2022_program: Interface<'info, TokenInterface>

The function

pub(crate) fn process_redeem(
    redeem_account: &mut Redeem,
    stake_authority_bump: u8,
) -> Result<()> {
        let cpi_mint_program = redeem_account.token_2022_program.to_account_info();
    let cpi_mint_accounts: MintTo<'_> = MintTo {
        mint: redeem_account.stake_mint.to_account_info(),
        to: redeem_account.user_stake_ata.to_account_info(),
        authority: redeem_account.stake_authority.to_account_info(),
    let seeds = &["mint".as_bytes(), &[stake_authority_bump]];
    let signer = &[&seeds[..]];
    let cpi_mint_ctx = CpiContext::new_with_signer(cpi_mint_program, cpi_mint_accounts, signer);
    token_2022::mint_to(cpi_mint_ctx, capped_redeem_amount as u64)?;

Thanks to anybody willing to help me

1 Answer 1


This sounds very much like you forgot to specify the token22 program in one of your function calls. Its hard to see without the full code, but double check all parts that have tokenProgram is parameter.

Here is a full example on how to mint a token with meta data in anchor. https://github.com/solana-developers/program-examples/blob/main/tokens/token-2022/nft-meta-data-pointer/anchor/program/programs/extension_nft/src/instructions/mint_nft.rs

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.