'the trait `anchor_lang::AccountDeserialize` is not implemented for `anchor_spl::token::Mint`
I am trying to CPI the Token Program to send spl-tokens to a wallet. For this the derive accounts in the context struct has three accounts without any attribute over them:
- mint_token_out: Account<'info, Mint> (which is the mint address)
- token_out: Account<'info, TokenAccount>(which is the token account that the token would be sent out from) and
- token_program: Program<'info, Token>.
But I get four Trait not implemented errors. They are:
- the trait
AccountSerializeis not implemented foranchor_spl::token::Mintat line --- mint_token_out - the trait
anchor_lang::AccountDeserializeis not implemented forTokenAccountat line --- token_out: Account<'info, TokenAccount> - the trait
anchor_lang::Owneris not implemented forTokenAccountat line --- token_out: Account<'info, TokenAccount> - the trait
anchor_lang::Owneris not implemented foranchor_spl::token::Mintat line --- mint_token_out: Account<'info, Mint>
Is there something wrong I'm doing?
I have tried adding the constraint #[account(mut, has_one = wallet, owner = wallet)] as the account attribute for mint_token_out. But I still get the error..
Solution 1:[1]
That error indicates that you did not use #[derive(Accounts)] for the related struct that you created for the method.
#[derive(Accounts)]
pub struct YourTructForContext<'info>{}
#[derive(Accounts)] Implements an Accounts deserializer on the given struct. Meaning it allows this struct to process user addresses and accounts.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yilmaz |
