Token Balance when there is no corresponding token account for the address #454
Unanswered
rayansayyah
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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;Beta Was this translation helpful? Give feedback.
All reactions