Varun Chodha
Varun Chodha

Reputation: 33

How to grab the Token count in solana Web3

Hey i want to fetch the token amount how do I do that? I have reached this point but want to hold just the value

used this till here console.log("Signature: ",hash.meta.postTokenBalances);

Upvotes: 0

Views: 1887

Answers (1)

Jon C
Jon C

Reputation: 8412

It's up to you what you need. Let's use SOL as an example, which as 9 decimal places, such that 1 SOL = 1_000_000_000 lamports

  • amount is the total amount of lamports, so 90_000_000_000 in your example
  • uiAmountString is the formatted amount of SOL, so 90.000000000 in your example

If you need to do calculations, you should hold on to amount to do the math, and decimals to display it. If you only need to display, then uiAmountString will be easiest.

Upvotes: 1

Related Questions