I have started learning coding in Solidity and I have written the below contract using the official Oraclize guidelines.

My aim is to:

  • Make the update() function be called on its own on the specified time constraint in order to update the temperature measure.
  • Get a notification of the update every time it is being called (maybe email or by any other means on a text file)

How should I configure my code to achieve this result ?

    pragma solidity ^0.4.18;
    import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

    contract WolframAlpha is usingOraclize { 

    string public temperature;
    mapping(bytes32=>bool) validIds;
    event LogNewOraclizeQuery(string description);
    event newTemperatureMeasure(string temperature);

    function WolframAlpha() {

    function __callback(bytes32 myid, string result) {
        require(validIds[myid] ==true);
        require(msg.sender == oraclize_cbAddress());       
        temperature = result;
        delete validIds[myid];
        // do something with the temperature measure..

    function update() payable {
        if(oraclize_getPrice("WolframAlpha") > this.balance){
            LogNewOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
            LogNewOraclizeQuery("Oraclize query was sent, standing by for the answer..");
            bytes32 queryId = oraclize_query(60,"WolframAlpha","Temperature in London");
            validIds[queryId] =true;


  • I am using the online solidity compiler "Remix"
  • Deploying the contract to ropsten testnet

1 Answer 1


You can schedule the execution of query as follows.

From the Oraclize documentation : -

The execution of a query can be scheduled in a future date. The function oraclize_query accepts as a parameter the delay in seconds from the current time or the timestamp in the future as first argument.

 // Relative time: get the result from the given URL 60 seconds from now
 oraclize_query(60, "URL","json(https://api.kraken.com/0/public/Ticker?pair=ETHXBT).result.XETHXXBT.c.0")

 // Absolute time: get the result from the given datasource at the specified UTC timestamp in the future
 oraclize_query(scheduled_arrivaltime+3*3600,"WolframAlpha", strConcat("flight ", flight_number, " landed"));

From your question,you have to call the update function for specific timeperiods.For this ,you have to schedule the call using JS. On each call ,it will emit the event LogNewOraclizeQuery.You can do the watch on the event for notify about the latest update.

 var num=contractInstance.Result({},{fromBlock: 0, toBlock: 'latest' });
  • So if I understand correctly, I am calling the update function after 60 seconds it has been deployed, but only once. How can I schedule it to run the update() function every 60 seconds ?
    – kosnet2
    Commented Mar 9, 2018 at 15:19
  • EDIT :I dont care if i spend all eth of my account
    – kosnet2
    Commented Mar 9, 2018 at 17:30
  • You have to schedule the function call in JS. And on each call callback do the code to emit event.It can be used as notification using event watching. Commented Mar 10, 2018 at 2:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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