88

Lazy vs Eager Execution There are two fundamental ways of designing a contract to be called at a later time: lazy evaluation or eager evaluation. Lazy evaluation means that the contract's state will be updated only when needed. This often makes sense for contracts that naturally incentivise users to call them at a future date. An example of this might be ...


20

You could use the Ethereum Alarm Clock as previously mentioned, but you could also change your programming style to a "must call to execute" paradigm. For instance, if you want to lock up money for a month until it gets returned, instead of actually having the money be sent after a month, you could have the user call a function that then returns the money.


17

As others have mentioned already, you can use the Alarm-clock or change the flow of your contract. Another option is to use Oraclize with an empty query: /* Simple Alarm code. This contract will be called back automatically 1 day after its birth */ import "dev.oraclize.it/api.sol"; contract Alarm is usingOraclize { function Alarm() { ...


15

Yes, you can guarantee long run time accuracy. Miners can't cheat that much to change the timestamp over days. Blocktime is adjusted to be constant within certain error margins, and timestamps is guaranteed to be rejected if they are excessive. Serenity and PoS 'proven' until core team decides otherwise. It is very very unlikely to happen, what reason could ...


15

You could run the following function : function f( blocknumber, to_address, value_) { var filter = web3.eth.filter('latest').watch(function(err, blockHash) { var target=blocknumber; if(web3.eth.blockNumber==target) { filter.stopWatching(); //your function here web3.eth.sendTransaction({to:to_address, from:web3.eth.coinbase, ...


11

Just schedule it with the wallet user interface. Create any transaction you like, make sure you select "advanced settings" and determine the condition to be either: send after block number send after date and time Parity will hold this transaction back until the condition is met. Note, for this your node needs to keep running.


5

The miner could cheat in the timestamp by a tolerance of 900 seconds. so if you check outside this intervall you are safe.


5

I believe this was designed as a feature to minimize the burden on the network and reduce resources. There are several solutions if you want to "call on a contract": http://www.ethereum-alarm-clock.com/ Source: I'm proud to announce the launch of the Ethereum Alarm Clock service. http://www.ethereum-alarm-clock.com/ The Alarm service facilitates ...


5

There is no formal way to schedule events via the protocol itself. However somebody already wrote an Ethereum Alarm Clock-contract that supports scheduling events at a later moment in time. It's decentralized as well as far as I could tell, anybody can fire scheduled events and get paid for doing so.


4

If your question is about how to send a transaction yourself at any point after a certain block height is reached, then you can run an ever-running daemon on a host you control, that will do it in a programmatic way – like the answer from @BadrBelaj. If on the other hand what you want is to send a transaction to the network now and have it executed ...


2

Currently There are several options for this. The top answer is old and Ethereum Alarm Clock was down for a long time until a few weeks ago and now is managed (looks like) by the Chronologic team. I am copying an answer here as the community sends any other answer about scheduling to this one. I am including also a code example of how to do this with the ...


2

In a recent post by Vitalik Buterin on Reddit he mentions several proposals that were considered in the protocol design but didn't make the cut. One of the proposals called delayed calls would introduce an opcode ALARM that allow a contract to execute in a future block. The proposal has several use cases but it was discarded due to time constraints.


2

Contracts can only execute when something outside the blockchain calls them. I can think of three entities that might be willing to call the contract every 2 months: The sender might be willing to do this if, for example, they will stop receiving some service if payment is not sent. The recipient might be willing to do this so they get paid. A third-party ...


2

If you want to get your transaction into the block n, you would have to broadcast it at block n - 1. Here is what roughly happens, I use block 100 as an example: You schedule a transaction to be sent at block 100 with Parity. Parity waits until it receives block 99 and broadcasts your transaction. Miners are already working on block 100 and now receive and ...


2

Solution The protocol changed since the question was posted. It is possible to do recursive calls by building a service that for example takes advantage of Proxy wallet (to fund following calls). Ethereum Alarm Clock has RecurringPayment example in its repository. This is the contract: pragma solidity 0.4.24; import "contracts/Interface/...


2

You can not do this natively. ETH-Tempus Oraclize Ethereum Alarm Clock (this has been inactive for a long time and "Chrono-Logic" is building over this) ETH-Tempus is the simplest and cheaper. The difference with oraclize is that the gas consumption of ETH-Tempus is lower, more important, in oraclize you pay in advance and the gas that you pass to them ...


2

No, Oraclize does not allow you to cancel your request. Other options allow this, for instance Aion Scheduling System allows you to cancel the request and get back the fee if you cancel at least 20 blocks before the scheduled time. Ethereum clock Alarm also allows you to cancel scheduled transactions. Hope this helps.


1

They have a video how to setup a time node https://blog.chronologic.network/how-to-prove-day-ownership-to-be-a-timenode-3dc1333c74ef. A timenode is a separate application from regular ethereum clients (geth, parity, besu, etc). A timenode is configured with an account that will be used to send transactions.


1

The contract doesn't execute anything. You (or others) may execute any of the functions exposed in the contract (public and external) at any time, by submitting a transaction which contains the encoded function-call. When you submit such transaction, it will go into one of the next blocks (the higher the gas-price you state, the faster it will be selected ...


1

In the case of Aion, you have the smart contract available on the Aion's GitHub page, so you can just deploy it in your private network. However, you will need to develop the script that executes the transactions as this has not been made available in the Aion page. But this basically read the logs of the ScheduleCallEvent, the parameters of this event are ...


1

No. An externally owned account has to kick it off with a signed transaction. You can use your own server, farm it out to an Oracle or even incentivize users by paying them to initiate the process. Hope it helps.


1

It should be possible to save an id when the call is scheduled and revert when the oracle call and you do not want to process that id. But since the call was done the system may charge for it anyway.


1

You can execute recurrent calls using Ethereum alarm clock. The gracePeriod that is described in the links that you provide indicates how many blocks you will allow the executor to be delayed (maximum). That is, assume you want something to be executed in block x, the gracePeriod indicates that you are Ok with your call being executed at any block between x ...


1

The "Ethereum Alarm Clock" is not really meant to fire multiple times. It's meant for one job - 1 call. You can however "recursively" link multiple executions automatically, by having the "clock contract" execute a method in one of your contracts that "does the job you need" then "queries the clock and queues another job" until it runs out of "gas". But ...


1

There is no scheduling system in Ethereum itself. Everything starts with someone signing a transaction and sending it with the gas (paid for) to run the transaction. This leads to some new patterns, data and process flows that take some adjustment. The obvious idea is the Ethereum Alarm Clock approach. In this pattern, you would have your users supply ...


1

It got easier to deploy EAC on any network, including local network. Solution In existing or new NPM project run: npm i --save @ethereum-alarm-clock/lib Then when you have running network, run: npx eac-deploy-contracts This is using new @ethereum-alarm-clock/lib. Resources If you would like to see full tutorial, please see: Text tutorial: https://...


1

The version you linked (0.7.0) was released in the 31st of January, 2016. At that time, the latest Solidity release was 0.2.1 (30th of January, 2016). If you switch your compiler version to that Solidity release on the Remix IDE, the contract will compile just fine. You can find a working ETHFiddle snippet here. Keep in mind that the Ethereum Alarm Clock ...


1

Gas assumption issue might be there? I guesstimate as long as "this function capable accepting fund for Gas", this scheduled contract would run forever.


1

You can use an external service to trigger a transaction on-chain, which triggers your contract. You can use the Chainlink Alarm Clock to do this. A full example, showing a delayed start of 5 minutes is shown below. pragma solidity ^0.4.24; import "chainlink/contracts/ChainlinkClient.sol"; contract ChainlinkAlarmClock is ChainlinkClient { ...


Only top voted, non community-wiki answers of a minimum length are eligible