2

I know there have been quite a few questions surrounding time, and the use of block.timestamp. However, I still have a few questions design-wise.

  1. At what point exactly is it 'dangerous' to use block.timestamp? I'm building a PoC which would use time units as little as 5 minutes. The average blocktime is 15 seconds in ethereum. I also heard miners can manipulate this timestamp by up to 900(!) seconds. This all seems like it would make developing smart contracts which use small time units unfeasible.

  2. Expanding on the previous question, is there an alternative to this construct? I've heard oracles can be used, but this would incur a gas cost for even simple checks. Is there any other way?

  3. How will future protocol developments impact the current way of working with time? For instance the switch to PoS,Plasma,...

I know the problem time gives, being that smart contracts need to be deterministic and time isn't, but it seems as if the current way of doing this severely limits the amount of things you can actually do with Ethereum smart contracts.

  • The average block time in Ethereum is around 15 seconds. – smarx Feb 27 '18 at 8:09
  • Whether the block timestamp is suitable or not depends on what you're actually doing. Could you explain your use case? – smarx Feb 27 '18 at 8:10
  • In some cases, using the block number is better. (5 minutes is around 20 blocks.) The number of blocks cannot be easily manipulated. – smarx Feb 27 '18 at 8:11
  • Thanks for the correction @smarx . I mistyped minutes instead of seconds but got the 10-19 part from medium.facilelogin.com/… . To explain my use case without going into too much detail, it involves renting an asset for short periods of time, working with time units of 5 minutes, so one could rent an asset for example for 35 minutes. – wimdetr Feb 27 '18 at 8:12
  • 1
    I'd say you can either live with the risk of bad timestamps showing up or you can use blocks instead. Blocks will be a little less precise but also not subject to much manipulation. (Miners probably aren't going to manipulate timestamps to attack you specifically, but you could always be collateral damage if manipulation is happening for some other reason.) – smarx Feb 27 '18 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.