hello i want to Calculate a token price in my pocket 。i think the formula is token balance * token price . i get the balance by getTokenBalances function , get the price by getTokenPrice function . Now I have a problem。 the getTokenBalances function return balance not Inaccurate. the value is 18 length. what should i do ,Hope to get a reply soon
You will have to convert that value with 18 digits to another value Baden on the number of decimals for that token. Not every token has 18 decimals.
You can look in utils in sdk for that conversion.
let me have a try tks
hi where is the document ? i can not fond the conversion in the document。 tks
got it , thank you very much
hello use the Units tools i can calculate some token coin , but some token coin result Incorrect。for example ,in bsc chain . token_address 0x7a565284572d03ec50c35396f7d6001252eb43b6 decimals value is 9 .blance is 11234674163970038401641248 . the code is const tokenValue = Moralis.Units.FromWei(“11234674163970038401641248”, 9) the result not correct. what should is do . the function not support bsc chain?
how do you know that you get the wrong value? looking in bscscan it looks like that token has a huge number for total supply