I want to do a simple crowdsale for lets say 500.000.000 tokens.

For 1 ether you will get 100.000 tokens. 20% will be holded by me, others goes to crowdsale. What wont be sold, it will be burned.

I did try multiple crowdsale contracts but i cannot make it work.

Biggest problem is with price. (example is from ethereum.org - with contract published on ethereum.org i get tokens back when send eth, but price is not good...)

        price = etherCostOfEachToken * 1 ether;

How can I make it that i will get 100.000 coins for 1 ether? Is there some contract example that will do that? I also tried Zeppelin and others but i cannot figure it out...

Thanks, Ales

1 Answer 1


The formula should be really simple. Every internal amount is expressed in wei, it is better to use that unit to our calculation.

1 ether = 10^18 wei = 100000 tokens = 100000 * 10^decimals

Now if you send msg.value wei using the cross product you have to receive

msg.value * 100000 * 10^decimals / 10^18 wei

It is recommended to always use 18 decimals for tokens in that case we can simplify, and if you contribute msg.value you should get

msg.value * 100000

in tokens.

In the OpenZeppelin Crowdsale contract you should set the _rate to 100000 in the Crowdsale constructor.

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.