Friendly token amount
$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.