0

How can I implement a price structure into a crowdsale smart contract so that a price per token would be increased after a certain time?

I want to use best practices for this but cannot find information on this.

Would it be safe to use this kind of implementation?

  if(now >= phase1Start){
      rate = 200;
  }
  else if(now >= phase2Start){
      rate = 100;
  }

I would use the unix timestamp for the phase1Start and phase2Start variables, is this how it is done in crowdsales usually?

0

Yes, using timestamps is the usual way to do it.

Note the nuance with timestamps on blockchain. The miner that mines the block can manipulate the timestamp, but they are limited in what they can do. See answers, for example, here: https://forum.ethereum.org/discussion/comment/80636/#Comment_80636
Can a contract safely rely on block.timestamp?

PS The way your conditions are written right now, it seems you want phase1 to happen after phase2, which is quite confusing.

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.