Ethereum Asked by Dylan Kerler on October 24, 2020
What is the best practice for doing this?
In the ERC20 standard having a public decimals: uint256
is marked as optional.
But obviously you cannot display a token balance in the UI without having the decimals
.
So how should I handle the case where the decimals field is not there? Should I just assume the contract implements 18 decimals?
What is the standard here? Is it safe to say that 95% of contracts implement the decimals
variable?
The concept of decimals is purely for user-friendliness - inside the blockchain there are no decimals. That's why it's optional.
If there are no decimals then you simply display what the token amount inside the contract shows - things get easier than with decimals. So it behaves like decimals
was 0.
This concept is rather confusing for many people. You can read more for example here: https://ethereum.stackexchange.com/a/72481/31933
Answered by Lauri Peltonen on October 24, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP