0

I'm trying to get my head around the concept of this decimal in Eth. Should I change the decimals when I want to deploy outside of the Ethereum network? What would be the correct decimals value when I want to deploy in Neon network(part of Solana network)?

1 Answer 1

0

Neon EVM is an on-chain solution that brings native EVM to the Solana network. The thing about the EVM machine it can not process any floating point number using solidity. So like, when suppose you want to divide 3 ERC20 tokens by half, it will return 1(3/2, and take the floor value). So we will loos precision by 0.5. Instead, what the standard does is consider multiplying with a multiple of 10. So if the decimals is, say, 9, the calculation will happen considering (amount * 10 ** 9). For most ERC20 contracts, the standard value for decimals is using 18. So, now, if you calculate devising the ERC20 amount by half - (3* 10 ** 18) / 2 And you get the result 1.5e+18...and in the front end you know, divide by 10**18 to get the actual ERC20 amount which is 1.5, and now you don't lose any precision. This is why decimals is used. The higher the value is higher the precision, however, most ERC20 follow the standard of either 18 or 25 from my experience (18 is way more popular). I would recommend using one of them. Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.