Friendly token amount

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
(Created page with "'''$get token amount''' is a function that returns an amount of a specific token with the decimal in the correct place. It is important because cryptocurrencies often have d...")
 
Line 1: Line 1:
'''$get token amount''' is a function that returns an amount of a specific token with the decimal in the correct place.  
+
'''$defi token amount''' is a function that converts the amount of a token into a string representation with the decimal in the correct place.
  
It is important because cryptocurrencies often have different decimal places - for example, Ether has 18 decimal places.
+
This function is particularly beneficial for enterprise users who frequently manipulate various tokens on either the Avalanche or Binance Smart Chain blockchains.
 +
 
 +
== User Level ==
 +
 
 +
This function is exclusively available for enterprise users.
  
 
== Parameters ==
 
== Parameters ==
  
'''Chain:''' The blockchain network (such as Avalanche or BinanceSmartChain) where the token resides.
+
'''Chain:''' The blockchain where the token of interest is located. You can choose either "Avalanche" or "BinanceSmartChain".  
  
'''Token ID:''' The token for which you want to get the amount with the right decimal places. You can select from the dropdown list 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.
  
'''Amount:''' The raw amount of the token you want to convert to the correct decimal places.
+
'''Amount:''' The amount of the token you want to convert.
  
 
== Return Value ==  
 
== Return Value ==  
  
This function returns a string that represents the correctly formatted amount of the specified token.
+
This function returns a string value which is the representation of the given token amount with the decimal in the correct place.
  
 
== Example ==
 
== Example ==
  
 
<pre>
 
<pre>
log("Correctly formatted token amount: {$get token amount("Avalanche", "AVAX", "1000000000000000000")}")
+
set(#my token amount, $defi token amount("BinanceSmartChain", "BNB", "1000000000000000000"), "Global")
 +
ui text msg("Your BNB token amount with the correct decimal placement is: {#my token amount}")
 
</pre>
 
</pre>
  
The above script logs the correctly formatted amount of AVAX for the raw amount of "1000000000000000000" on the Avalanche blockchain. For an AVAX amount of "1000000000000000000" raw units, the correct amount would be "1" AVAX because AVAX has 18 decimal places, similar to Ether.
+
In this example, the script is calculating the correct decimal placement for the BNB token amount "1000000000000000000" on the Binance Smart Chain and then displaying the converted value in the UI.
 
+
**Please note:**
+
 
+
Be sure to correctly input the raw amount, as it directly affects the result. Misinterpretation of the raw amount can lead to significant discrepancies in the resulting value.
+

Revision as of 18:29, 4 July 2023

$defi token amount is a function that converts the amount of a token into a string representation with the decimal in the correct place.

This function is particularly beneficial for enterprise users who frequently manipulate various tokens on either the Avalanche or Binance Smart Chain blockchains.

Contents

User Level

This function is exclusively available for enterprise users.

Parameters

Chain: The blockchain where the token of interest is located. You can choose either "Avalanche" or "BinanceSmartChain".

Token ID: This is the identifier for the token you are interested in.

Amount: The amount of the token you want to convert.

Return Value

This function returns a string value which is the representation of the given token amount with the decimal in the correct place.

Example

set(#my token amount, $defi token amount("BinanceSmartChain", "BNB", "1000000000000000000"), "Global")
ui text msg("Your BNB token amount with the correct decimal placement is: {#my token amount}")

In this example, the script is calculating the correct decimal placement for the BNB token amount "1000000000000000000" on the Binance Smart Chain and then displaying the converted value in the UI.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox