anchor shows erros “no associated item named `__anchor_private_gen_idl_type` found for struct `anchor_spl::token::TokenAccount` in the current scope”

  Kiến thức lập trình

I run my code, and it shows, looks like I need to intro pub token_program: Program<'info, Token>, but I did, you can get more information from my code below


error[E0599]: no associated item named `__anchor_private_insert_idl_defined` found for struct `anchor_spl::token::Mint` in the current scope
   --> programs/sol404/src/instructions/createmint.rs:153:10
    |
153 | #[derive(Accounts)]
    |          ^^^^^^^^ associated item not found in `Mint`
    |
    = note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)


error[E0599]: no associated item named `__anchor_private_insert_idl_defined` found for struct `anchor_spl::token::TokenAccount` in the current scope
   --> programs/sol404/src/instructions/createmint.rs:153:10
    |
153 | #[derive(Accounts)]
    |          ^^^^^^^^ associated item not found in `TokenAccount`
    |
    = note: this error originates in the derive macro `Accounts` (in Nightly builds, run with -Z macro-backtrace for more info)


here is my code, I try to create a mint and a ATA account, and I used

#[derive(Accounts)]
pub struct CreateMint<'info> {
    // Use ADMIN_PUBKEY as constraint, only the specified admin can invoke this instruction
    #[account(
        mut,
        address = ADMIN_PUBKEY
    )]
    pub admin: Signer<'info>,

    // The PDA is both the address of the mint account and the mint authority
    #[account(
        init,
        seeds = [b"jelly"],
        bump,
        payer = admin,
        mint::decimals = 9,
        mint::authority = jelly_token_mint,
    )]
    pub jelly_token_mint: Account<'info, Mint>,
    
    ///CHECK: Using "address" constraint to validate metadata account address, this account is created via CPI in the instruction
    #[account(
        mut,
        address = MetadataAccount::find_pda(&jelly_token_mint.key()).0,
    )]
    pub jelly_metadata_account: UncheckedAccount<'info>,


    #[account(
        init,
        payer = admin,
        associated_token::mint = jelly_token_mint,
        associated_token::authority = admin,
    )]
    pub jelly_token_account: Account<'info, TokenAccount>,


    pub associated_token_program: Program<'info, AssociatedToken>,
    pub token_program: Program<'info, Token>,
    pub token_metadata_program: Program<'info, Metadata>,
    pub system_program: Program<'info, System>,
    pub rent: Sysvar<'info, Rent>,
}

and here is my cargo.toml, I am not sure whether it is a version problem

[package]
name = "sol404"
version = "0.1.0"
description = "Created with Anchor"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "sol404"

[features]
default = []
cpi = ["no-entrypoint"]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
idl-build = ["anchor-lang/idl-build"]

[dependencies]
anchor-lang = {version = "0.29.0", features = ["init-if-needed"]}
anchor-spl = {version = "0.29.0", features = ["metadata"]}
mpl-token-metadata = "4.1.2"
solana-program = "1.18.11"

I can’t get any useful information from google, and GPT, anyone can help me?

LEAVE A COMMENT