2

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 1

1

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())?;

Python

https://github.com/kevinheavey/anchorpy/blob/09e88c204cd5d3cd0b56c32b2cadc715f9bb8c58/src/anchorpy/utils/token.py#L234

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.