Friendly token amount

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

Jump to: navigation, search

$friendly token amount is a function that returns an amount of a given token formatted with the decimal in the correct place. It is based on the token's decimals value defined in its contract.

Parameters

Chain: The blockchain where the token resides.

Token ID: The token you want to work with. This can be the symbol of the token, or it can be the contract address.

Amount: The raw amount of the token that you want to format.

Return Value

This function returns the friendly amount of the given token from the raw input amount.

Example

config defi wallet("your private key")
log("DAI Friendly Amount: {$friendly token amount("BinanceSmartChain", "DAI", "1000000000000000000")}")

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 command will take the raw amount "1000000000000000000" for DAI token on Binance Smart Chain and return a friendly output:

DAI Friendly Amount: 1

The function is very useful because some tokens have different levels of precision, and it's easy to get confused with the amount when the token has high precision. Always make sure to verify the amount before performing transactions on any blockchain.

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox