1

can anyone help me over here, please.

use solana_program::account_info::AccountInfo;

use spl_token::state::Account;

fn get_token_account_data(account_info: &AccountInfo) -> Result<Account, ProgramError> {
    let account_data = account_info.data.borrow();
    let account = Account::unpack(&account_data)?;
    Ok(account)
}

let account = Account::unpack(&account_data);
   |                                 ^^^^^^^^^^^^^^^^^ function or associated item not found in spl_token::state::Account

1 Answer 1

2

Both pack and unpack are provided by the Pack trait. You'll have to first bring the trait into scope with use solana_program::program_pack::Pack;

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.