According to the ERC20 standard totalSupply
returns an uint
. Hence, this should be the amount of tokens in the smallest unit your token offers. This is not in Wei or any Ether unit, this is just the number of tokens (in your smallest unit) which you decide that exist.
Still, your token can specify decimals. For example, if you set uint8 public constant decimals = 8;
, your token would support 8 decimal places. But this is only for convenience, i.e. totalSupply
still needs to return values in the smallest unit.
For example, let's say you offer 1000 tokens with 2 decimal places. Consequently, totalSupply
needs to return 100000
(i.e. 1000 * 100
).
By the value of decimals
exchanges will know how to display your token. For instance, if someone owns 1337
of your tokens in the smallest unit, the exchange will display it as 13.37
tokens.
EDIT: Note that also all Ether values in solidity smart contracts need to be converted to the smallest Ether unit available, i.e Wei. So if you would issue 500 tokens with 2 decimals for 1 ETH, the price of the smallest unit of your token would be: 1 ether / (500 * 100) = 1e18 / (500 * 100) = 20000000000000
.