I'm having an odd problem working with some ERC20 token contracts I've written:

When I specify a decimal value, let's say 4 here for simplicity, the values show up differently in Mist vs etherscan.

For example, if I create a token with a supply of 1 with decimals of 4, the tokens show up as a value of 0.0001 in Mist but the value shows up as 1 in etherscan; however, if I click on the ERC20 icon in etherscan to view details on the token, there it agrees with Mist and states that the token supply is 0.0001.

So, I understand that the contract is going to be working with the smallest unit of the token, as set by the decimals value in the constructor; but I'm not quite sure how to get the value of the token itself, rather than the smaller units, to display in Mist and etherscan. Let me know if that doesn't make sense.


The way I think about this is that the number of tokens is:

tokenSupply = tokensIActuallyWant * (10 ^ decimals)

If I want 1 token with the ability to subdivide it with a precision of 2 decimal places, I represent that as 100.

Similarly if I want 1 token with the ability to subdivide that to 18 decimal places, I need to represent that as 1000000000000000000 (1 with 18 zeros).

Hope that helps.

  • To help clarify, using the terms in ERC-20: totalSupply = tokensIActuallyWant * (10 ^ decimals) – eth Oct 8 '17 at 20:14
  • 1
    so if I do not want my tokens to be divisible at all, i.e the smallest token unit is 1 token, then I ought to specify decimals = 0? – Dave Sag Feb 22 '18 at 7:19
  • Dave Sag: Yes. Exactly. – Thorkil Værge Apr 27 '18 at 8:03

protected by eth Dec 26 '17 at 0:01

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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