Let's assume I want a contract with function that sends X Ether each month. A user agrees to send a certain amount of Ether to the contract every month, and makes a transaction corresponding to a function call with X as one of the arguments.

The ideal way would be to automatically send the Ether every month, and handle exceptions planned in the contract if the user doesn't have enough Ether.

I don't want to have to send a big number of Ether at once, like a year's worth every year, but that would mean that the contract is allowed to debit Ether by itself.

How would that work in practice, is it possible?


As far as I know, it is not possible to programmatically achieve this. However, it is possible by making use of the ethereum alarm clock which can:

  • Schedule Contract Function Calls
  • An ethereum contract that facilitates scheduling function calls for a specified block in the future.
  • Function calls can be scheduled to be executed against any contract
  • Scheduling can be done by contracts or ethereum account holders. Fully contained within the ethereum network.

(information from the ethereum alarm clock website)

Can also be found at: http://www.ethereum-alarm-clock.com/

  • I'm not sure I understand completely how that works. If I schedule to send X ether next month, I would have to lock the ether right now, wouldn't I? – Teleporting Goat Feb 22 '18 at 16:08
  • I haven't looked into it that much but as far as I know, you do. – Gabe Feb 26 '18 at 15:13

This is one of those situations where not using the Blockchain ‘could’ be the best way of achieving what you want to achieve.

Assuming that your use case does not require decentralised verification that what you say will happen will happen you could simply create a web service to submit an appropriate signed transaction to the blockchain at an appropriate time.

A quick Google showed up this blog post outlining how one can sign a transaction in JavaScript using node and Ganache.

You could write a similar script and then call it from a shell script or cron job as appropriate.


No, this would not work, because smart contracts can't invocate themselves. Someone would have to manually send a transaction to the contract to trigger the release of funds.

Except for the invocation problem, your contract would be possible just as you want it.

  • Couldn't the invocation be done by a higher part of the dapp? (Not directly from the contract but higher in the stack) – Teleporting Goat Feb 22 '18 at 16:03

This is possible using Ethereum Alarm Clock and custom Proxy Wallet implementation.

  1. Create Proxy Wallet with multiple owners possible
  2. Schedule transaction to call method sendEtherFromWallet() on ProxyWallet - this method will attempt to send ETH from ProxyWallet, to whatever address you specified
  3. Make sure sendEtherFromWallet is marked as onlyOwner
  4. Whitelist scheduled transaction address - add it as one of the owners to the ProxyWallet (alternatively you can add method called schedule to ProxyWallet itself, which would automatically whitelist the address after scheduling)
  5. When transaction will be executed, ScheduledTransaction will call sendEtherFromWallet and since it will be whitelisted address, it will proceed with an attempt to send Ether from ProxyWallet - at this time, if Ether will not be present, the internal transaction (of calling sendEtherFromWallet) will revert - but this is something you wanted in your question. If Ether will be present on ProxyWallet, everything will be fine.

We have tested this approach on one of the hackathons and it's working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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