Friendly token amount

From UBot Studio
Revision as of 19:07, 4 July 2023 by LillyT (Talk | contribs)

Jump to: navigation, search

$formatted balance is a function that allows you to get the amount of a token with the decimal placed accurately.

This function essentially takes an amount of a token and adjusts it to have the decimal in the correct place based on the token's decimals value.

Parameters

Chain: The specified blockchain chain where the token exists. The available options are "Avalanche" or "BinanceSmartChain".

Token ID: The token for which the formatted balance must be calculated.

Amount: The total amount of the token represented as a string.

Return Value

This function returns a string, which is the calculated amount of the token adjusted to the correct decimal places.

Example

log("Formatted Binance Coin Balance: {$formatted balance("BinanceSmartChain", "BNB", "100000000000000000")}")

The output of this function will be the amount of the token, placed accurately on the decimal point.

Example Output:

Formatted Binance Coin Balance: 10 BNB

It's important to note that the "Amount" parameter must be provided as a string, even though it represents a numerical value. This is because the value may be larger than the maximum size of a number.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox