Friendly token amount

From UBot Studio
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
'''$defi token amount''' is a function that converts the amount of a token into a string representation with the decimal in the correct place.
+
'''$get proper token amount''' is a function that returns the amount of a specified token with the decimal in the correct place. This command is very useful for enterprise users managing transactions with various tokens, ensuring the correct token quantities are used.  
 
+
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 where the token of interest is located. You can choose either "Avalanche" or "BinanceSmartChain".  
+
'''Chain:''' The blockchain network chain associated with the token. Available options include Avalanche and Binance Smart Chain.
  
'''Token ID:''' This is the identifier for the token you are interested in.
+
'''Token ID:''' The identifier of the token for which the correct amount is to be obtained. If your desired token is not available in the dropdown, you can input its contract address.
  
'''Amount:''' The amount of the token you want to convert.
+
'''Amount:''' The raw quantity of the specified token that needs to be adjusted for decimals.
  
== Return Value ==  
+
== Return Value ==
  
This function returns a string value which is the representation of the given token amount with the decimal in the correct place.
+
This function returns a string that represents the correct amount of the specified token, considering the decimal placement.
  
 
== Example ==
 
== Example ==
  
 
<pre>
 
<pre>
set(#my token amount, $defi token amount("BinanceSmartChain", "BNB", "1000000000000000000"), "Global")
+
ui console view
ui text msg("Your BNB token amount with the correct decimal placement is: {#my token amount}")
+
config defi wallet("your private key here")
 +
log("Proper token amount: {$get proper token amount("BinanceSmartChain","0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c","50000000000000000000")}")
 
</pre>
 
</pre>
  
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.
+
Make sure to replace "your private key here" with your actual private key. Private keys are sensitive information that needs to be handled securely.
 +
 
 +
The output of this script will display the amount of the specified token (given by the ID "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" on the Binance Smart Chain) adjusted for appropriate decimal placement. The output might look something like this:
 +
<blockquote>
 +
Proper token amount: 50.0
 +
</blockquote>

Revision as of 18:58, 4 July 2023

$get proper token amount is a function that returns the amount of a specified token with the decimal in the correct place. This command is very useful for enterprise users managing transactions with various tokens, ensuring the correct token quantities are used.

Parameters

Chain: The blockchain network chain associated with the token. Available options include Avalanche and Binance Smart Chain.

Token ID: The identifier of the token for which the correct amount is to be obtained. If your desired token is not available in the dropdown, you can input its contract address.

Amount: The raw quantity of the specified token that needs to be adjusted for decimals.

Return Value

This function returns a string that represents the correct amount of the specified token, considering the decimal placement.

Example

ui console view 
config defi wallet("your private key here")
log("Proper token amount: {$get proper token amount("BinanceSmartChain","0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c","50000000000000000000")}")

Make sure to replace "your private key here" with your actual private key. Private keys are sensitive information that needs to be handled securely.

The output of this script will display the amount of the specified token (given by the ID "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c" on the Binance Smart Chain) adjusted for appropriate decimal placement. The output might look something like this:

Proper token amount: 50.0
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox