Check Balances
Query native, ERC-20, and paymaster token balances.
This guide explains how to read balances from an EIP-7702 gasless account.
Native Balance
Use getBalance() to read the native token balance in wei.
const balance = await account.getBalance()
console.log('Native balance:', balance)ERC-20 Balance
Use getTokenBalance(tokenAddress) to read one ERC-20 token balance in the token's base units.
const usdtBalance = await account.getTokenBalance('0xdAC17F958D2ee523a2206206994597C13D831ec7')
console.log('USDT balance:', usdtBalance)Multiple ERC-20 Balances
Use getTokenBalances(tokenAddresses) to read several token balances at once.
const balances = await account.getTokenBalances([
'0xdAC17F958D2ee523a2206206994597C13D831ec7',
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
])
console.log(balances)The return value maps each token address to a bigint balance.
Paymaster Token Balance
In paymaster-token mode, getPaymasterTokenBalance() reads the configured paymasterToken.address.
const feeTokenBalance = await account.getPaymasterTokenBalance()
console.log('Paymaster token balance:', feeTokenBalance)getPaymasterTokenBalance() throws ConfigurationError when the account is configured for sponsorship mode because no paymaster token is present.
Read-only Balance Checks
All balance methods are available on WalletAccountReadOnlyEvm7702Gasless.
const readOnlyAccount = await account.toReadOnlyAccount()
const balance = await readOnlyAccount.getBalance()
const tokenBalance = await readOnlyAccount.getTokenBalance('0xdAC17F958D2ee523a2206206994597C13D831ec7')