1

As we know, decimals is an optional parameter on ERC20.

I was wondering what if decimals is not set on a contract.

Does it mean that if I send 10 in the transfer function, it means that it actually transfers 10? Does this mean that default decimals is 0?

0
1

You're right that not specifying decimals, would treat it as 0.

It sounds tautological, but to answer your related questions, a totalSupply of 100 would be 100 tokens, and a transfer of 10, would transfer 10 tokens.


When using decimals, make sure to see this question because it does affect the values for totalSupply and transfer amounts: Decimals on ERC20 Tokens?

0

The transfer() function does not care if there are decimals or not. It is purely a cosmetic divisor for human display.

4
  • Yeap. true, but my actual question is if user has 10 tokens on a ERC20 contract which doesn't have decimals property stored on it, does this mean user has actually 10 tokens ? May 31 '21 at 18:11
  • mainly, I am asking that if you don't have decimals property on a contract, then what would be the default decimals ? May 31 '21 at 18:11
  • The transfer() function does not care. There is an uint256 number and it can present whatever you want. May 31 '21 at 18:12
  • I know, i know .. I am asking something else. Let's say I deploy ERC20 without decimals property and totalSupply as 100.. Now, when users look at my contracts and see totalSupply, what will they think ? totalSupply is 100 or totalSupply is 100*10**18 ? Basically, without decimals , what's the default decimals on ERC20 ? May 31 '21 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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