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
1 Asked on November 18, 2021 by moustafa-ali
1 Asked on November 18, 2021
1 Asked on November 18, 2021 by user491880
1 Asked on November 17, 2021 by bassie
1 Asked on November 17, 2021 by will_z
2 Asked on November 15, 2021 by leon-africa
20 Asked on November 12, 2021
1 Asked on November 12, 2021 by unha-back
crowdsale erc 20 openzeppelin contracts tokens truffle deployment
1 Asked on November 12, 2021 by kantus-jee
1 Asked on November 12, 2021 by andrew007
2 Asked on November 10, 2021 by maroodb
1 Asked on November 10, 2021 by nitin-jagtiani
1 Asked on November 10, 2021 by nick-furfaro
Get help from others!
Recent Questions
Recent Answers
© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP