Get native token balance

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Created page with "'''$get native balance''' is a function that fetches the balance of the native token on a specified blockchain. Native tokens are integral to their blockchain network and are ...")
 
Line 1: Line 1:
'''$get native balance''' is a function that fetches the balance of the native token on a specified blockchain. Native tokens are integral to their blockchain network and are generally used to pay for transaction fees, computational services, and other operational costs.
+
'''$native token balance''' is a function that gets the balance of the native token on a specific blockchain.
 +
 
 +
This function is designed for enterprise users who are interacting with various blockchains and need to keep track of their native token balances.
 +
 
 +
== User Level ==
 +
 
 +
This function is exclusively available for enterprise users.
  
 
== Parameters ==
 
== Parameters ==
  
'''Chain:''' The blockchain network (e.g., Avalanche, BinanceSmartChain) where the native token resides.
+
'''Chain:''' The blockchain from which you want to obtain your native token balance. The options are "Avalanche" or "BinanceSmartChain".
  
== Return Value ==
+
== Return Value ==  
  
This function returns a string representing the balance of the native token in your connected wallet on the specified blockchain network.
+
This function returns a string value - your wallet balance for the native token on the specified blockchain.
  
 
== Example ==
 
== Example ==
  
 
<pre>
 
<pre>
log("My balance of AVAX: {$get native balance("Avalanche")}")
+
set(#my native token balance in BSC, $native token balance("BinanceSmartChain"), "Global")
log("My balance of BNB: {$get native balance("BinanceSmartChain")}")
+
ui text msg("Your native token balance in Binance Smart Chain is: {#my native token balance in BSC}")
 
</pre>
 
</pre>
  
The above example script logs the balance of the native tokens (AVAX for Avalanche and BNB for BinanceSmartChain) in the default wallet.
+
In this example, the script is setting a global variable for your balance of the native token on the Binance Smart Chain, and then displaying it in the UI.
 
+
**Please note:**
+
 
+
Make sure that the wallet is connected to your desired blockchain network before running the '''$get native balance''' function using the `connect defi wallet` command. Without a connected wallet, the function will not be able to fetch and return the balance.
+

Revision as of 18:29, 4 July 2023

$native token balance is a function that gets the balance of the native token on a specific blockchain.

This function is designed for enterprise users who are interacting with various blockchains and need to keep track of their native token balances.

Contents

User Level

This function is exclusively available for enterprise users.

Parameters

Chain: The blockchain from which you want to obtain your native token balance. The options are "Avalanche" or "BinanceSmartChain".

Return Value

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

Example

set(#my native token balance in BSC, $native token balance("BinanceSmartChain"), "Global")
ui text msg("Your native token balance in Binance Smart Chain is: {#my native token balance in BSC}")

In this example, the script is setting a global variable for your balance of the native token on the Binance Smart Chain, and then displaying it in the UI.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox