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...")
 
(Example)
 
(7 intermediate revisions by one user not shown)
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.
+
'''$get token balance''' is a function that returns your wallet balance for a given token on a specific blockchain chain.
  
 
== Parameters ==
 
== Parameters ==
  
'''Chain:''' The blockchain network (e.g., Avalanche, BinanceSmartChain) where the token resides.
+
'''Chain:''' The blockchain chain where the token resides.  
  
'''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:''' The token you want to check the balance of. This can be the symbol of the token, or it can be the contract address.
  
 
== Return Value ==
 
== Return Value ==
  
This function returns a string that represents the balance of the specified token.
+
This function returns your wallet balance for the given token on the specified chain.
  
 
== Example ==
 
== Example ==
  
 
<pre>
 
<pre>
log("My balance of AVAX on Avalanche Chain: {$get wallet balance("Avalanche", "AVAX")}")
+
config defi wallet("your private key")
log("My balance of BNB on Binance Smart Chain: {$get wallet balance("BinanceSmartChain", "BNB")}")
+
log("DAI Balance: {$get token balance("BinanceSmartChain", "DAI")}")
 +
log("ETH Balance: {$get token balance("Avalanche", "ETH")}")
 
</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.
+
Please replace "your private key" with your actual DeFi wallet's private key.
  
**Please note:**
+
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.
  
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.
+
The output will be the balance of your DeFi Wallet for the specified chain in the particular tokens.
 +
 
 +
Example Output:
 +
<blockquote>
 +
<p>DAI Balance: 500</p>
 +
<p>ETH Balance: 2.5</p>
 +
</blockquote>

Latest revision as of 01:42, 5 July 2023

$get token balance is a function that returns your wallet balance for a given token on a specific blockchain chain.

[edit] Parameters

Chain: The blockchain chain where the token resides.

Token ID: The token you want to check the balance of. This can be the symbol of the token, or it can be the contract address.

[edit] Return Value

This function returns your wallet balance for the given token on the specified chain.

[edit] Example

config defi wallet("your private key")
log("DAI Balance: {$get token balance("BinanceSmartChain", "DAI")}")
log("ETH Balance: {$get token balance("Avalanche", "ETH")}")

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.

The output will be the balance of your DeFi Wallet for the specified chain in the particular tokens.

Example Output:

DAI Balance: 500

ETH Balance: 2.5

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox