Get token balance
The $wallet balance function retrieves the balance of a specific token in your DeFi wallet.
Parameters
Chain: The blockchain chain that the respective token belongs to.
Token ID: The token for which you want to check the balance. If your desired token isn't in the dropdown, you can enter its contract address.
Return Value
It returns the balance of the chosen token in your DeFi wallet, as a string.
Example
config defi wallet("your private key") log("BinanceSmartChain BNB Balance: {$wallet balance("BinanceSmartChain", "BNB")}") log("Avalanche AVAX Balance: {$wallet balance("Avalanche", "AVAX")}")
Please replace "your private key" with your actual DeFi wallet's private key.
Be mindful when you are handling your private key. It's a sensitive piece of data that allows full control over your funds in your DeFi wallet. Therefore, never share this key publicly or with anyone.
This script will print out the balance of Binance Coin (BNB) on the Binance Smart Chain and AVAX on Avalanche.
Example Output:
BinanceSmartChain BNB Balance: 5.23568
Avalanche AVAX Balance: 12.4577
This function will help you to keep track of your holdings in different tokens on various blockchains.