Can anyone point me in the direction of some more information on how to make solidity functions time dependent? I want to have a function that can only be called on Wednesdays between 18:00-21:00

Nov 9, 2020, 8:37 PM
Also interested in this
Nov 9, 2020, 8:46 PM
Sorry, don't have a link to give you but in the end it's rather straightforward. All you need is the block.timestamp. The tricky part is that you have calculate based on that which day and time it is, but it shouldn't be too hard.
Ah, noticed you double posted this elsewhere as well
Nov 9, 2020, 8:58 PM
Yep. Block.timestamp can be manipulated to around +/- 15 secs though.
Nov 9, 2020, 9:47 PM
Thanks, yeah I'm scratching my head over how to formulate the require() in the solidity function. I have managed to make it so that the function was 'uncallable' for a ~10 min window by using

require(now >= 1604958000 && now <= (1604958000 + 10 minutes), "You are not allowed to call this function outside of the specified hours");
I could probably duplicate that line a couple of times and add +7 days each time but that doesn't really scale well :p
Nov 9, 2020, 10:09 PM
Is the function being called everyday?
Nov 9, 2020, 10:19 PM
I want to allow people to call it, only once, every wednesday between 18:00-22:00 PM
Nov 9, 2020, 10:21 PM
So if you do now % 1 days then you could calculate the seconds between 18 and 21
Nov 9, 2020, 10:21 PM

© 2024 Draquery.com All rights reserved.