Get token balance

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Created page with "'''$get wallet balance''' is a function that returns the balance of a given token in your wallet. This function is useful when you need to check your DeFi wallet's token balan...")
 
Line 1: Line 1:
'''$get wallet balance''' is a function that returns the balance of a given token in your wallet. This function is useful when you need to check your DeFi wallet's token balances on different blockchain networks.
+
'''$defi wallet balance''' is a function that gets your wallet balance for a given token. If your desired token isn't in the dropdown list, you can enter its contract address.
 +
 
 +
This function is particularly useful for enterprise users who are managing numerous different tokens across various blockchains.
 +
 
 +
== User Level ==
 +
 
 +
This function is exclusively available for enterprise users.
  
 
== Parameters ==
 
== Parameters ==
  
'''Chain:''' The blockchain network (e.g., Avalanche, BinanceSmartChain) where the token resides.
+
'''Chain:''' The blockchain on which your DeFi Wallet and the token of your interest is located. The options are "Avalanche" or "BinanceSmartChain".  
  
'''Token ID:''' The token whose balance you want to check. This could be any token that resides within the specified blockchain network. You can select from the dropdown options or manually enter the contract address if your desired token isn't listed.
+
'''Token ID:''' This is the identifier for the token you are interested in. If your desired token isn't in the dropdown list, you can manually enter its contract address.
  
== Return Value ==
+
== Return Value ==  
  
This function returns a string that represents the balance of the specified token.
+
This function returns a string value, your wallet balance for the specified token on the selected blockchain.
  
 
== Example ==
 
== Example ==
  
 
<pre>
 
<pre>
log("My balance of AVAX on Avalanche Chain: {$get wallet balance("Avalanche", "AVAX")}")
+
set(#my token balance in Avalanche, $defi wallet balance("Avalanche", "AVAX"), "Global")
log("My balance of BNB on Binance Smart Chain: {$get wallet balance("BinanceSmartChain", "BNB")}")
+
ui text msg("Your AVAX balance in Avalanche is: {#my token balance in Avalanche}")
 
</pre>
 
</pre>
  
The above script example writes the balance of AVAX in the wallet on the Avalanche chain, and the balance of BNB on the Binance Smart Chain to the log.
+
In this example, the script is setting a global variable for your balance of the AVAX token on the Avalanche chain, and then displaying it in the UI.
 
+
**Please note:**
+
 
+
It's essential to make sure that the wallet is connected (using the '''connect defi wallet''' command) to your desired blockchain network before running the '''$get wallet balance''' function. Otherwise, the function will not be able to fetch and return the balance.
+

Revision as of 18:28, 4 July 2023

$defi wallet balance is a function that gets your wallet balance for a given token. If your desired token isn't in the dropdown list, you can enter its contract address.

This function is particularly useful for enterprise users who are managing numerous different tokens across various blockchains.

Contents

User Level

This function is exclusively available for enterprise users.

Parameters

Chain: The blockchain on which your DeFi Wallet and the token of your interest is located. The options are "Avalanche" or "BinanceSmartChain".

Token ID: This is the identifier for the token you are interested in. If your desired token isn't in the dropdown list, you can manually enter its contract address.

Return Value

This function returns a string value, your wallet balance for the specified token on the selected blockchain.

Example

set(#my token balance in Avalanche, $defi wallet balance("Avalanche", "AVAX"), "Global")
ui text msg("Your AVAX balance in Avalanche is: {#my token balance in Avalanche}")

In this example, the script is setting a global variable for your balance of the AVAX token on the Avalanche chain, and then displaying it in the UI.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox