I need a function in my contract to be executed daily by itself. I know that Ethereum Alarm Clock and Oraclize do it but none of them worked for me.
For example this code using Oraclize
pragma solidity ^0.4.2;
import "http://github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol";
contract MyContract is usingOraclize {
uint public tmp = 0;
function callThisToStart() {
oraclize_query(60, "URL", "");
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize_cbAddress()) throw;
doSomething();
callThisToStart();
}
function doSomething() {
tmp++;
}
}
I do not really know why it does not work (tmp is not increased) I do not care about using EAC or Oraclize, but I really want to get that for example every minute the value of a variable increases
Thank you.
callThisToStart();
call from within the__callback
function and check if that works: in order for this to work, you need to have funds available in the contract as the first oraclize call is the only free one - alternatively just comment the last line of your callback function!