I wrote a smart contract which will be used in an ICO. The contract is an erc20 token but it also provides functionality to mint tokens so basically users can call the payable function. This in turn calls a internal function to calculate the number of tokens that should be minted for that amount of eth, mints the tokens and transfers them to the caller.

My question is, is this the way to go? Is having an erc20 token which also contains the crowdsale functionality good practice? The reason I am asking this is because I read about the possibility of having an erc20 contract and a crowdsale contract, but I do not see the point of having 2 seperate contracts rather than 1.

My contract also has logic that when the ICO is over, minting of new tokens and so on cannot occur anymore and the contract then simply acts as a ledger and to allow token transfers between accounts.

Any clarifications would be greatly appreciated.

1 Answer 1


The best ICO smart contract practices are here:


Having functionality in a token that does not concern the token itself (like a crowdsale) is a bad practice. It is better to have modularized code without hardcoded values.

More about how to design software properly here:


  • I know about separation of concerns but the reason that I prefer having 1 smart contract is to avoid the additional transaction fee between contracts, which might fail and hence fail the entire 'transaction'. This (communicating between 2 contracts) adds complexity overall and also there is the problem of performance limitations of ethereum. I would like the smart contract to be as simple as possible so the ICO can go as smooth as possible
    – seedg
    May 25, 2018 at 7:40
  • If 1-10 dollar transaction fee is too much for your ICO and it makes you to result to inferior programming practices then you are in the wrong business. May 25, 2018 at 8:02

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.