Get native token balance

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 1: Line 1:
'''$native token balance''' is a function that gets the balance of the native token on a specific blockchain.
+
'''$get native token balance''' is a function that retrieves the balance of the native token on the specified blockchain chain (Avalanche, BinanceSmartChain etc).
 
+
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 from which you want to obtain your native token balance. The options are "Avalanche" or "BinanceSmartChain".
+
'''Chain:''' The name of the chain from which you want to get the balance.
  
== Return Value ==  
+
== Return Value ==
  
This function returns a string value - your wallet balance for the native token on the specified blockchain.
+
This function returns the balance of the native token on the specified chain.
  
 
== Example ==
 
== Example ==
  
 
<pre>
 
<pre>
set(#my native token balance in BSC, $native token balance("BinanceSmartChain"), "Global")
+
config defi wallet("your private key")
ui text msg("Your native token balance in Binance Smart Chain is: {#my native token balance in BSC}")
+
log("Avalanche Balance: {$get native token balance("Avalanche")}")
 +
log("BinanceSmartChain Balance: {$get native token balance("BinanceSmartChain")}")
 
</pre>
 
</pre>
  
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 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 example fetches the balance of the native token on both Avalanche (AVAX) and Binance Smart Chain (BNB). Replace "Avalanche" or "BinanceSmartChain" with the chain you're interested in.
 +
 
 +
The output will display your balance of the native token for the selected chain.
 +
 
 +
Example Output:
 +
<blockquote>
 +
<p>Avalanche Balance: 10.2</p>
 +
<p>BinanceSmartChain Balance: 5.3</p>
 +
</blockquote>
 +
 
 +
This information can be useful when you want to check how much native token (like AVAX or BNB) you have before making a transaction, because these tokens are often used for transaction fees.

Latest revision as of 19:48, 4 July 2023

$get native token balance is a function that retrieves the balance of the native token on the specified blockchain chain (Avalanche, BinanceSmartChain etc).

[edit] Parameters

Chain: The name of the chain from which you want to get the balance.

[edit] Return Value

This function returns the balance of the native token on the specified chain.

[edit] Example

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

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 example fetches the balance of the native token on both Avalanche (AVAX) and Binance Smart Chain (BNB). Replace "Avalanche" or "BinanceSmartChain" with the chain you're interested in.

The output will display your balance of the native token for the selected chain.

Example Output:

Avalanche Balance: 10.2

BinanceSmartChain Balance: 5.3

This information can be useful when you want to check how much native token (like AVAX or BNB) you have before making a transaction, because these tokens are often used for transaction fees.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox