Retrieve token balance
How to retrieve the balance of a token for a wallet
To fetch the balance of a certain token for a wallet, you need to call the function getTokenBalance which will return a promise containing a TokenBalance object. If you need the entire balance a certain wallet holds, it is recommended to use the getTokenBalances function.

Function

1
venlyConnect.api.getTokenBalance("<WALLET_ID>", "<TOKEN_ADDRESS>");
Copied!

Example

1
const venlyConnect = new VenlyConnect('YOUR_CLIENT_ID');
2
venlyConnect.api.getTokenBalance("c8ec9954-fa1a-4682-9cf8-ef5c1015d1d1","0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0").then((tokenBalance) => {
3
console.log("The balance of",tokenBalance.symbol,"is",tokenBalance.balance);
4
})
Copied!

Returns

1
{
2
balance: 392.10420561176494
3
decimals: 18
4
logo: "https://raw.githubusercontent.com/ArkaneNetwork/content-management/master/tokens/ethereum/mainnet/logos/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0.png"
5
rawBalance: "392104205611764916095"
6
symbol: "MATIC"
7
tokenAddress: "0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0"
8
transferable: true
9
type: "ERC20"
10
}
Copied!

Function Reference

The function reference describes the different functions that are available in the Widget. For each function you can find the signature, it's parameters, and possible options documented.
Last modified 7d ago