简体   繁体   中英

Solana: On chain, how do you find out how many tokens are in someones token account?

I have what must be an incredibly simple question, but after a lot of internet searching all i've been able to find is how to do this offchain (ie with getTokenAccountBalance), but how do you do this on chain?

Is it stored in the data for the account? I was trying to find out what the structure of that was but also didn't come up with anything..

Many Thanks to anyone that can shed some light on this!

对于任何寻求答案的人,如下所示:

let token_account = spl_token::state::Account::unpack_unchecked(&program_token_wallet.try_borrow_data()?)?;

Easy method-

Go to solscan or solana explorer, input the wallet address and it'll show the number of tokens held by that addy')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM