If I were to delegate an amount of spl tokens to a certain pubkey, how can I see (in the future) how much is there left as delegated token amount and which was the pubkey I delegated to?
1 Answer
On the Command Line
$ spl-token -um account-info --address <TOKEN-ACCOUNT>
Will query mainnet (-ud
for devnet, -ul
for localnet) for that token account and print to the console.
Typescript
Use the getAccount
function in @solana/spl-token
. https://github.com/solana-labs/solana-program-library/blob/master/token/js/src/state/account.ts#L95
Rust
Use the anchor-spl
crate. (client is a solana_client::rpc_client::RpcClient
, see https://docs.rs/solana-client/latest/solana_client/rpc_client/struct.RpcClient.html)
let token_act = client.get_account_data(&pubkey)?;
let token_act = anchor_spl::token::TokenAccount::try_deserialize(&mut token_act.as_slice())?;