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 December 18, 2021 by vikujangid
4 Asked on December 18, 2021 by sreesankar-g-warrier
4 Asked on December 16, 2021
1 Asked on December 16, 2021 by anatoly
1 Asked on December 16, 2021 by abz
2 Asked on December 14, 2021 by adheep-mohamed-abdul-kader
1 Asked on December 13, 2021 by aleh
1 Asked on December 13, 2021 by suzana-maranho-moreno
1 Asked on December 13, 2021 by tabz
1 Asked on December 13, 2021 by shahzain-tariq
2 Asked on December 11, 2021 by alwaysquestioning
1 Asked on December 11, 2021 by user39184
3 Asked on December 11, 2021 by venkatesh-muthyala
0 Asked on December 11, 2021 by mahsum-urebe
1 Asked on December 9, 2021 by jerry-j
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP