0

I am trying to write a program to transfer a SPL Token but I'm having trouble when I pass the token_program account to my instruction:

#[derive(Accounts)]
pub struct InitializeAuction<'info> {
    /// State of our auction program (up to you)
    #[account(
        init,
        payer = signer,
        space = 8 + BoyncAuction::AUCTION_SIZE
    )]
    pub state: Account<'info, BoyncAuction>,

    /// Account which holds tokens bidded by biders
    #[account(mut)]
    pub treasury: AccountInfo<'info>,

    #[account(mut)]
    pub signer: Signer<'info>,

    pub system_program: Program<'info, System>,
    pub token_program: Program<'info, Token>,
}

When I compile I get the error:

error[E0277]: the trait bound `Token: Id` is not satisfied
  --> programs/auction/src/lib.rs:62:24
   |
62 |     pub token_program: Program<'info, Token>,
   |                        ^^^^^^^^^^^^^^^^^^^^^ the trait `Id` is not implemented for `Token`
   |

I am using code from a not so old youtube example that compiled.

I am currently using anchor-cli 0.25.0, is something change that will not allow me to use a Token Program Account this way?

3
  • You need anchor-spl and anchor-lang as dependencies, not anchor-cli, necessarily. Also, can you restart your rust analyzer server or run cargo clean and recompile the file? Seems fine to me.
    – hrs8
    Commented Jul 26, 2022 at 14:46
  • My dependencies in Cargo.toml: [dependencies] anchor-lang = "0.22.1" anchor-spl = "0.25.0" spl-associated-token-account = "1.0.5" Commented Jul 26, 2022 at 14:59
  • I built clean, no change. Commented Jul 26, 2022 at 15:03

1 Answer 1

0

It turns out that I had been working in an existing anchor repo and the 'anchor-lang' in Cargo.toml did not corespond with what version of anchor-cli I have installed. ('0.22.0' vs '0.25.0').

That was causing tons of errors for me including the one I described above.

note: perhaps two different versions of crate `anchor_lang` are being used?'

^^ If you see this, check whatever you have installed vs what's declared unde [dependencies] in Cargo.toml.

0

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.