Converts wei value into a ether value for decimals 9

I Want to Converts a wei value into a ether value for decimals 9 but i got wrong value.


In the Input Data we see amountOut: 500125000000000

This number after Converts to ether, must be amount of the Token or BNB .

But I get another amount.

I check for another Tokens (with another decimals), i got correct value.

Why ?

Im using this code for converts:

const tokenValue = Moralis.Units.FromWei("500125000000000", 9)

1 Like

it looks like that transaction converts BNB into a token with 9 decimal and Moralis.Units.FromWei("500125000000000", 9) give the right number in this case.

Please send the value

this is the value that I got: 500125

Right, but what is for value ?

it is the a value of this token: that has 9 decimals

Right, but in the bscscan the value of the coin shows: 485,121.25

Because you are comparing two different numbers.

You assume that amountOut (which is 500125000000000) is the amount the user gets in the end ( actually 485,121.25) but this is not the case.