WDK logoWDK documentation

Check Balances

Query native TON, Jetton, and paymaster token balances.

This guide explains how to check native TON balances, Jetton token balances, paymaster token balances, and read-only account balances.

Native TON Balance

You can retrieve the native TON balance using account.getBalance():

Get Native TON Balance
const balance = await account.getBalance()
console.log('Native TON balance:', balance, 'nanotons')

Jetton Token Balance

You can check the balance of a specific Jetton token using account.getTokenBalance():

Get Jetton Token Balance
const jettonAddress = 'EQ...' // Jetton contract address
const jettonBalance = await account.getTokenBalance(jettonAddress)
console.log('Jetton token balance:', jettonBalance)

Paymaster Token Balance

You can check the balance of the configured paymaster token using account.getPaymasterTokenBalance():

Get Paymaster Token Balance
const paymasterBalance = await account.getPaymasterTokenBalance()
console.log('Paymaster Jetton balance:', paymasterBalance)

The paymaster token balance determines how many gasless transfers you can execute. Ensure the paymaster has sufficient token balance before initiating gasless transfers.

Read-Only Account Balances

You can check balances for any public key without a seed phrase using WalletAccountReadOnlyTonGasless:

Create Read-Only Account
import { WalletAccountReadOnlyTonGasless } from '@tetherto/wdk-wallet-ton-gasless'

const readOnlyAccount = new WalletAccountReadOnlyTonGasless(publicKey, {
  tonClient: {
    url: 'https://toncenter.com/api/v3',
    secretKey: 'your-api-key' // Optional
  },
  tonApiClient: {
    url: 'https://tonapi.io/v2',
    secretKey: 'your-ton-api-key' // Optional
  },
  paymasterToken: {
    address: 'EQ...' // Paymaster Jetton contract address
  }
})

You can retrieve balances from a read-only account using readOnlyAccount.getBalance() and readOnlyAccount.getPaymasterTokenBalance():

Read-Only Balances
const balance = await readOnlyAccount.getBalance()
console.log('Native TON balance:', balance)

const paymasterBalance = await readOnlyAccount.getPaymasterTokenBalance()
console.log('Paymaster token balance:', paymasterBalance)

Next Steps

With balance checks in place, learn how to send TON.

On this page