1

What should I consider when choosing the number of decimal places for an ERC20 token/stablecoin?

My first thought was to just use 18 which seems to be the standard because Ether uses 18. However Tether and USD Coin use 6 decimal places, while DAI and True USD use 18.

So my question is how should I make the decision? And what are the possible consequences of using either 6 or 18 decimal places?

3
  • 1
    just use 18 and don't mess with this number. you are going to have lots of problems if you deviate from the standard. It is not supposed to, but lots of hardcoded apps use 18. so better don't mess with it. I am telling you this as Blockchain Explorers developer
    – Nulik
    Commented Jul 29, 2021 at 15:40
  • That makes sense. Does using less decimals save storage space or allow for higher token supply? Commented Jul 30, 2021 at 7:49
  • yeah, 16 gas units for each byte which happens to be non-zero, and 4 units for each byte which appens to be zero. So if you cut by 10 decimal places you will save minium 40 gas units and maximum 160 in transaction cost, that if you pass balance as input to your contract. If not, the storage slot is 32 bytes anyway and it depends on Solidity if it is going to pack the balance with some other variables or not. If it does, you will save 20,000 gas on a SSTORE operation
    – Nulik
    Commented Jul 30, 2021 at 14:07

2 Answers 2

1

As you said, 18 is the standard. Use that unless you have some real reason to do otherwise - all integrations are easier if you use 18 like most other tokens.

Some tokens, especially stablecoins, use less decimals. This is mostly due to compatibility with off-chain things - or at least that was the case in one stablecoin project I was involved with. Many fiat systems utilize 6 decimals, so many fiat-pegged stablecoins utilize the same so off-chain systems are easier to integrated.

It's of course always a tradeoff: if you use less than 18, off-chain systems may be easier to integrate, but on-chain systems will be harder.

0

If possible, use the standard 18 decimals to avoid confusion.

USDT and USDC use 6 decimals, which can cause issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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