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

<p><a href="https://github.com/ethereum/go-ethereum/issues/117" rel="nofollow noreferrer">https://github.com/ethereum/go-ethereum/issues/117</a></p>

<p>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.</p>

<p>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 -</p>

<p><a href="https://stackoverflow.com/questions/1857741/run-php-script-every-5-10-minutes-without-cron-perl-etc">https://stackoverflow.com/questions/1857741/run-php-script-every-5-10-minutes-without-cron-perl-etc</a> </p>

<p>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. ;-)</p>

CC BY-SA 3.0
2015-06-21T00:29:28.527Z
2015-06-21T00:29:28.527Z
2017-05-23T12:34:59.703Z
Rob Myers
<p>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.</p>

<pre><code>contract CallbackRegistry
{
  struct Entry { uint time; address addr; bytes data; uint reward; }
  mapping(bytes32 =&gt; 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 &gt; 0 &amp;&amp; now &gt;= entries[_hash].time)
    {
      msg.sender.send(entries[_hash].reward);
      entries[_hash].addr.call(entries[_hash].data);
      delete entries[_hash];
    }
  }     
}
</code></pre>

CC BY-SA 3.0
2015-05-31T14:56:39.377Z
2015-05-31T14:56:39.377Z
chriseth
<p>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.</p>

CC BY-SA 3.0
2015-05-29T23:04:23.027Z
2015-05-30T12:01:31.127Z
2015-05-30T12:01:31.127Z
Nikolai
<p>You can do this using <a href="http://www.ethereum-alarm-clock.com/" rel="nofollow">http://www.ethereum-alarm-clock.com/</a></p>

<p>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.</p>

CC BY-SA 3.0
2015-09-23T23:41:47.717Z
2015-09-23T23:41:47.717Z
Piper Merriam
<p>The simplest way to do it is using <a href="https://www.ethereum-alarm-clock.com" rel="nofollow noreferrer">Ethereum Alarm Clock</a>. It's on mainnet and integrated in <a href="https://mycrypto.com" rel="nofollow noreferrer">MyCrypto</a> wallet. Here's tutorial to accomplish scheduling based on block height / timestamp, as you mentioned in the question: <a href="https://medium.com/@MyCrypto/schedule-your-ethereum-transactions-now-on-mycrypto-92a6305f7dcc" rel="nofollow noreferrer">https://medium.com/@MyCrypto/schedule-your-ethereum-transactions-now-on-mycrypto-92a6305f7dcc</a>.</p>

CC BY-SA 4.0
2018-11-08T20:35:10.247Z
2018-11-08T20:35:10.247Z
Daniel
<p>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:</p>

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

<p>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.</p>

<development><ethereum><smartcontracts>
Is it possible to schedule function calls to an Ethereum smart contract?
ThePiachu
# Is it possible to schedule function calls to an Ethereum smart contract?

(Asked by: username_0 on 2015-05-29)

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.

**Tags:** development, ethereum, smartcontracts


---

## 5 answers

### Answer by username_1 on 2015-06-21. Score: 3 | Accepted answer

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

<https://github.com/ethereum/go-ethereum/issues/117>

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 username_2'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 -

<https://stackoverflow.com/questions/1857741/run-php-script-every-5-10-minutes-without-cron-perl-etc>

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. ;-)


---

### Answer by username_2 on 2015-05-31. Score: 3

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)
    {
      msg.sender.send(entries[_hash].reward);
      entries[_hash].addr.call(entries[_hash].data);
      delete entries[_hash];
    }
  }     
}

```


---

### Answer by username_3 on 2015-05-29. Score: 2

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.


---

### Answer by username_4 on 2015-09-23. Score: 0

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.


---

### Answer by username_5 on 2018-11-08. Score: 0

The simplest way to do it is using [Ethereum Alarm Clock](https://www.ethereum-alarm-clock.com). It's on mainnet and integrated in [MyCrypto](https://mycrypto.com) 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>.


---

