I am wondering - is it possible to schedule or somehow trigger function calls to an Ethereum smart contract based on the current block height or timestamp? This would involve some pre-payment of gas for execution understandably, but it might be beneficial to have something like:

  • If current block height is 1'000'000, send 1000 ether to the block miner
  • If it's 2016-01-01 00:00:00, release funds from escrow

Of course those functions could be triggered by transactions at an appropriate time, but some sort of "execution scheduling" might be a useful automation of the process.

  • why couldn't this be done? this should be super simple to program...
    – user26705
    May 30 '15 at 2:39

It is not, sadly. There was a proposal for an ALARM opcode, but it was marked WONTFIX -


I can see why - timers require that you keep your contract topped up with Ether, and making them too easy to create could litter the blockchain with them and impose an overhead on miners.

You either have to have an external caller for your function (as in chriseth's solution), or use a PHP-style "poor man's cron" function that you call from every function in the contract to check and see which periodic tasks should fire -


This kind of solution can also be seen in LambdaMOO code, where events are triggered periodically only when someone speaks, but that's a bit more esoteric. ;-)


This feature can be easily realised outside the Ethereum virtual machine (and thus keeping the VM simple): Create a (reusable) contract where contracts can register to be called at a certain time (and provide a reward as compensation for the gas costs). A script can poll this contract from outside and call it at the appropriate times. The contract could be similar to the following.

contract CallbackRegistry
  struct Entry { uint time; address addr; bytes data; uint reward; }
  mapping(bytes32 => Entry) entries;
  function register(uint _time, address _addr, bytes _data) external returns (bytes32 _hash)
    _hash = sha3(_time, _addr, _data);
    entries[_hash].time = _time;
    entries[_hash].addr = _addr;
    entries[_hash].data = _data;
    entries[_hash].reward = msg.value;
  function invoke(bytes32 _hash) external
    if (entries[_hash].time > 0 && now >= entries[_hash].time)
      delete entries[_hash];

It is not in "the" ethereum spec, so no. But it is a feature that has been discussed for "ethereum 2.0" or similar. It is possible that there may even be a hard fork that will enable it in the then-existing network, but there are none currently planned.


You can do this using http://www.ethereum-alarm-clock.com/

It's a contract on the network that facilitates call scheduling by providing a financial incentive for independent parties to execute them for you. Disclaimer that I'm the author of the service.


The simplest way to do it is using Ethereum Alarm Clock. It's on mainnet and integrated in MyCrypto wallet. Here's tutorial to accomplish scheduling based on block height / timestamp, as you mentioned in the question: https://medium.com/@MyCrypto/schedule-your-ethereum-transactions-now-on-mycrypto-92a6305f7dcc.

Not the answer you're looking for? Browse other questions tagged or ask your own question.