1

I am trying to create associated token address on solana program with below configuration

#[derive(Accounts)]
#[instruction(params: TokenParams)]
pub struct MintToken<'info> {    
    /// CHECK: This is the token that we want to mint
    #[account(
        mut,
        seeds = [b"mint"],
        bump,
        mint::authority = authority,
    )]
    pub mint_account: InterfaceAccount<'info, Mint>,

    #[account(
        init_if_needed,
        payer = authority,
        associated_token::mint = mint_account,
        associated_token::authority = authority,
        associated_token::token_program = token_program,
    )]
    pub token_account: InterfaceAccount<'info, TokenAccount>,

    /// CHECK: the authority of the mint account
    #[account(mut)]
    pub authority: Signer<'info>,

    pub token_program: Program<'info, Token2022>,

    pub system_program: Program<'info, System>,

    pub associated_token_program: Program<'info, AssociatedToken>,
}

and test config as

   let user1ATA = await getAssociatedTokenAddress(
      mintAccount,
      payer.publicKey,
      undefined,
      TOKEN_2022_PROGRAM_ID
    );

const mint = async (
    tokenParams,
    pdaMaintainers,
    mintAccount,
    pdaConfig,
    pdaWhitelist,
    user1ATA
  ) => {
 
    let mintToken = await program.methods
      .mintToken(tokenParams)
      .accounts({
        maintainers: pdaMaintainers,
        config: pdaConfig,
        whitelist: pdaWhitelist,
        mintAccount,
        tokenAccount: user1ATA,
        authority: admin.publicKey,
        tokenProgram: TOKEN_2022_PROGRAM_ID,
        systemProgram: anchor.web3.SystemProgram.programId,
        associatedTokenProgram: ASSOCIATED_PROGRAM_ID,
      })
      .signers([admin])
      .rpc();


    await confirmTransaction(mintToken);
  };

But getting the error "An account required by the instruction is missing", but all accounts are availableenter image description here

2
  • 2
    Have you tried switching associated_token::mint to token::mint and associated_token::authority to token::authority?
    – Ahri
    Jan 13 at 20:21
  • After changing to token::authority and token::mint I am getting error {Error: Signature verification failed. Missing signature for public key [2NoueZzqVcivrSMcThMqzQdnoQ9SMKHadrdNY9xgR8JL].} means it is asking for user1ATA signature, but I don't want to pass user1ATA signature, as the requirement is only one signer can be there
    – blackhorse
    Jan 14 at 5:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.