How to get a Token Account's Balance

The token account holds the token balance, which can be retrieved with a single PRC call

import { createSolanaClient, address } from "gill";
const { rpc } = createSolanaClient({
urlOrMoniker: "mainnet"
});
const tokenAccountAddress = address(
"GfVPzUxMDvhFJ1Xs6C9i47XQRSapTd8LHw5grGuTquyQ"
);
const balance = await rpc.getTokenAccountBalance(tokenAccountAddress).send();
console.log(balance);
Console
Click to execute the code.

A token account can only hold one kind of mint. When you specify a token account, you also specific a mint too.

Is this page helpful?

How to get a Token Account's Balance | Solana