0

I am trying to change a variable every 72 hours.

At the moment I got: value=SafeMath.sub(value,SafeMath.div(value,10)) That should happen every 72 hours. Is it possible to let that run without a call for like ever?

NewITGuy
  • 3
  • 1

2 Answers2

2

You can not do this natively. As stated above you can use services.

ETH-Tempus

Oraclize

Ethereum Alarm Clock

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. (by a lot)

  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 (the example in GitHub just what you are asking for)

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

Jaime
  • 8,340
  • 1
  • 12
  • 20
1

Code on Ethereum only runs when a call is made to the contract address. You could set up an external program to call the contract at a desired time interval, but a contract cannot by itself run at specific time intervals.

However, you might want to look at this thread: How can a contract run itself at a later time?

Basically they suggest that http://www.oraclize.it/ can be used as the external program to call your contract at different time intervals.

Shawn Tabrizi
  • 8,008
  • 4
  • 19
  • 38