Is there a way to add a time specific delay to transactions in your smart contract?
Is there a way to add a time specific delay to transactions in your smart contract?
Loading saved threads...
Samarth · External communityPost link
External question — Ethereum Stack Exchange
Author: Samarth
Original post: https://ethereum.stackexchange.com/questions/113763
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
We're working on a smart contract in which certain transactions are executed every time a certain token price point is crossed. Therefore, if in a given instant the price crosses a set point more than 10 times, we don't wanna execute every transaction and pay transaction and gas fees. It would make sense only to execute the last transaction in every instant of time (say every 4 hours). Is there a way to do this in the smart contract or Metamask integration level so that all the redundant preceding transactions are cancelled and only the latest transaction in a given instant of time is executed?
We also wanna make sure that at the time of execution, the transactions happen with original values and not the new ones that were updated in the timespan following the original transaction creation.
Quote
Report
AvocadoChocolate · External communityPost link
External answer — Ethereum Stack Exchange
Author: AvocadoChocolate
Original post: https://ethereum.stackexchange.com/a/113764
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Yes, there is a Unit Called 'Hours' in solidity. See these docs:
https://docs.soliditylang.org/en/v0.4.21/units-and-global-variables.html
Just add a require statement into the function to check if block.timestamp of now, which gives the current block 'time', is 4 hours more than the previous transaction's block time.
NOTE:
When doing this you will need to store when a transaction is made. So for example in the transaction function have something like: 'uint256 timeSent=block.timestamp as well ")
Quote
Report
Post Reply
Checking account access…