Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Token Balance when there is no corresponding token account for the address #454

Unanswered
rayansayyah asked this question in Q&A
Discussion options

Hi!
I have a problem with getting token balance for token accounts that are not created. Like Solnet examples i use TokenWallet class to get balance of a Solana token, but when i do it twice and my first try is for an existing (created) token account and second try is for a not existing (not created) token account, i get my first try balance again instead of an error or 0 value and second token address isn't added to tokens. Is there any solution to fix this or any other method to get token balance?
Here is the code:
TokenWallet tokenWallet = await TokenWallet.LoadAsync(rpcClient, tokens, new PublicKey(address));
var balances = tokenWallet.Balances();
var balance = balances[0].QuantityRaw;
return balance;

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /