Tokens and balances
Look up ERC-20 token identity, metadata, and wallet balances.
TokenModule covers a token as an asset in
its own right: sdk.tokens.getToken reads its name, symbol, and decimals from the ERC-20
contract, getMetadata adds a logo when one is published, and getAccountBalance reads a wallet’s
holding in the token’s smallest unit.
Token is the shape every read returns for a
token. TokenAmount is how the SDK writes an
amount everywhere, from LOC face values to deposits: a token address and a bigint in that token’s
smallest unit.
This is wallet balance only: what an account holds, whatever the protocol. Collateral already in the Collateral Vault is a separate figure, covered in Vaults, collateral, and risk, and the rate between two tokens is in Pricing and oracles.
A wallet’s WETH balance, scaled to a human-readable amount:
const weth = await sdk.tokens.getToken({ address: WETH });if (!weth) return undefined;const balance = await sdk.tokens.getAccountBalance({ tokenAddress: WETH, accountAddress,});// Balances come back in the token's smallest units; scale by its decimals// for a human-readable amount.const wholeWeth = Number(balance) / 10 ** weth.decimals;Primary APIs
Interfaces
Token— An ERC-20 token: its address, name, symbol, decimals, and logo when one is available.TokenAmount— An amount of one ERC-20 token, in the token’s smallest unit.TokenModule— ERC-20 token operations: look up a token’s name, symbol, and decimals, resolve its logo, and read an account’s wallet balance.