Token Management
Request all available tokens and their balances, manage token approvals and more.
Get available tokens
getTokens
Retrieves a list of all available tokens on specified chains.
Parameters
-
params
(TokensRequest, optional): Configuration for the requested tokens.-
chains
(ChainId[], optional): List of chain IDs or keys. If not specified, returns tokens on all available chains. -
chainTypes
(ChainType[], optional): List of chain types.
-
-
options
(RequestOptions, optional): Additional request options.
Returns
A Promise that resolves to TokensResponse
getToken
Fetches details about a specific token on a specified chain.
Parameters
-
chain
(ChainKey | ChainId): ID or key of the chain that contains the token. -
token
(string): Address or symbol of the token on the requested chain. -
options
(RequestOptions, optional): Additional request options.
Returns
A Promise that resolves to Token
object.
Get token balance
Please ensure that you configure the SDK with EVM/Solana providers first. They are required to use this functionality. Additionally, it is recommended to provide your private RPC URLs, as public ones are used by default and may rate limit you for multiple requests, such as getting the balance of multiple tokens at once.
Read more Configure SDK Providers.
getTokenBalance
Returns the balance of a specific token a wallet holds.
Parameters
-
walletAddress
(string): A wallet address. -
token
(Token): A Token object.
Returns
A Promise that resolves to a TokenAmount
or null
.
getTokenBalances
Returns the balances for a list of tokens a wallet holds.
Parameters
-
walletAddress
(string): A wallet address. -
tokens
(Token[]): A list of Token objects.
Returns
A Promise that resolves to a list of TokenAmount
objects.
getTokenBalancesByChain
Queries the balances of tokens for a specific list of chains for a given wallet.
Parameters
-
walletAddress
(string): A wallet address. -
tokensByChain
[chainId: number]: Token[]: A list of Token objects organized by chain IDs.
Returns
A Promise that resolves to an object containing the tokens and their amounts on different chains.
Managing token allowance
Token allowance and approval functionalities are specific to EVM (Ethereum Virtual Machine) chains. It allows smart contracts to interact with ERC-20 tokens by approving a certain amount of tokens that a contract can spend from the user’s wallet.
Please ensure that you configure the SDK with the EVM provider. It is required to use this functionality.
Read more Configure SDK Providers.
getTokenAllowance
Fetches the current allowance for a specific token.
Parameters
-
token
(BaseToken): The token for which to check the allowance. -
ownerAddress
(string): The owner of the token. -
spenderAddress
(string): The spender address that was approved.
Returns
A Promise that resolves to a bigint
representing the allowance or undefined if the token is a native token.
getTokenAllowanceMulticall
Fetches the current allowance for a list of token/spender address pairs.
Parameters
-
ownerAddress
(string): The owner of the tokens. -
tokens
(TokenSpender[]): A list of token and spender address pairs.
Returns
A Promise that resolves to an array of TokenAllowance
objects.
setTokenAllowance
Sets the token allowance for a specific token and spender address.
Parameters
-
request
(ApproveTokenRequest): The approval request.-
walletClient
(WalletClient): The wallet client used to send the transaction. -
token
(BaseToken): The token for which to set the allowance. -
spenderAddress
(string): The address of the spender. -
amount
(bigint): The amount of tokens to approve. -
infiniteApproval
(boolean, optional): If true, sets the approval to the maximum uint256 value.
-
Returns
A Promise that resolves to a Hash
representing the transaction hash or void
if no transaction is needed (e.g., for native tokens).
revokeTokenApproval
Revokes the token approval for a specific token and spender address.
Parameters
-
request
(RevokeApprovalRequest): The revoke request.-
walletClient
(WalletClient): The wallet client used to send the transaction. -
token
(BaseToken): The token for which to revoke the allowance. -
spenderAddress
(string): The address of the spender.
-
Returns
A Promise that resolves to a Hash
representing the transaction hash or void
if no transaction is needed (e.g., for native tokens).