4

If using 'now' or 'block.timestamp' is considering security risks (miner manipulation) how should I go about current timestamp in my code? Isn't it safe to use either of the two as long as it is not used for randomness?

2
  • What is the use case for the timestamp? It's guaranteed to be roughly accurate, on the order of hours, but certainly don't use it for precise timings Dec 9 '17 at 3:06
  • For example in an ICO, where you would want to check and adjust bonuses based on specifc timestamps.
    – NowsyMe
    Dec 9 '17 at 14:17
3

As long as you are not basing some critical/time-sensitive logic on block.timestamp you should be ok.

For an ICO that adjusts the bonuses on different timestamps, it shouldn't be a problem. The worst case scenario would be someone investing a few hours after some deadline getting the bonus of the previous tier.

Using now / block.timestamp is a concern when the logic is based on perfectly timing an action.

1
  • One could manipulate the block.timestamp to get all bonuses earlier than at a right time. Why do you think this is not a concern? Like in the tip model when user is allowed to withdraw money only in tranches. Apr 11 '18 at 5:49

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.