Is it possible to get SOL balance and/or SPL token balances for a given account in an Anchor program?

1 Answer 1


The lamports of an account in Anchor can be found with:

let lmps: u64 = ctx.accounts.my_account.to_account_info().lamports();

If you have an account that is defined as Account<'info, anchor_spl::token::TokenAccount>, you can get the amount of SPL tokens stored in that account with:

let amt: u64 = ctx.accounts.my_token_account.amount;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.