1

I am confused with decimal places and how it effects the rate of token we set for ICO etc. Lets say, ERC20 Token A have 2 decimal places and per ether 10 tokens shall be sell, then how shall I set the price per wei in contract?

How many A tokens = 1 wei ?

When: 10 tokens = 1 ether.

0

The primary designation of the decimals function is off-chain display (it doesn't mean that it should not be used on-chain, but you should consider it very carefully before being tempted to do so).

This function can be used in order to avoid the need for displaying very low significant digits.

For example, instead of displaying 1234567890000000000 wei, you can display 1.23456789 ether.

Regarding the rest of your question:

10 tokens = 1 ether -->

10 tokens = 1000000000000000000 (1e+18) wei -->

1 token = 100000000000000000 (1e+17) wei -->

1 wei = 0.00000000000000001 (1e-17) token

As you can see, your token decimals have no impact on this; they only mean that 1 token will be represented in your contract via the numeric equivalence of 10 ** decimals.

0

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.