0

This question already has an answer here:

I need to create a contract that will make recurring payments as per user's request, the contract will ask the user to tell the sender and receiver address and it'll transfer some amount of erc20 tokens from sender to receiver in a recurring manner - maybe every month, or daily.

I was reading through ethereum alarm clock, what I understand till now is that it'll schedule the transaction to be run later, but can it be made recurring? like every 2 months?

A quick start link or suggestions would be appreciated, Many Thanks !

marked as duplicate by Ismael, Achala Dissanayake, mirg, mafrasi2, CPereez19 May 29 '18 at 7:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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:

  1. The sender might be willing to do this if, for example, they will stop receiving some service if payment is not sent.
  2. The recipient might be willing to do this so they get paid.
  3. A third-party might be willing to do this if they're compensated. (This is how the Ethereum Alarm Clock works.)

If I were you, I would just make the function callable by anyone and set up the expectation that the recipient must call that function to get paid. For recipients that are unwilling, the sender can do it themselves or incentivize a third-party to do it.

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 is not returned if you don't use it completely.

Note that ETH-Tempus has only the functionality of scheduling calls at any time in the future, while oraclize have many other functions.

In ETH-Tempus:

  1. The payment is done when your contract is called.

  2. Cheaper in gas consumption.

  3. The gas consumption is estimated online and you are only asked to pay for what was calculated plus a fee of about 5 cents of dólar.

  4. Is simple to use (look at the example on GitHub)

Disclaimer: I wrote the code for ETH-Tempus and is free to test in the test network (rinkeby). I created it because I saw a lot of people looking for this and the solutions I found were either complicated or too expensive to be actually considered in cases where you need a lot of calls. ( like repeated calls every certain time)

Hope this helps

  • can we use ETH-Tempus on main net? – Fariha Abbasi May 29 '18 at 18:35
  • Right now is only on Rinkeby, By June 10 it will be on the main net. – Jaime May 30 '18 at 8:11
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 enough Ether to pay processes fees in advance for the convenience of having the service send a transaction in the future. Since we always try to align payment of fees with the interests of the person paying the fees, it might make sense for a user to pay, say, 6 months worth of fees to cover the next 6 monthly transfers. Then, they would need to "top up" for continued convenience.

A less obvious way is to reverse the flow and have the users claim their funds. This is actually preferable in my opinion as it is more closely aligned with best practices. In the withdrawal-style, users simply inquire about their account status/history, and the contract computes payments owed since their last withdrawal. Easy.

Then, the user submits a transaction (push the button) to request funds owed and the contract is solely concerned with validating the request is acceptable, and doing the accounting. Also easy. The user pays for the gas necessary to process the transaction. That's proper.

Neither pattern uses looping over any lists or batch processing on specific days as might be the case in a server-centric approach. It's important not to do that.

Hope it helps.

  • what is the average cost to pay per transaction using ethereum alarm clock? – Fariha Abbasi May 29 '18 at 18:37

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