1

I want to run an Oracle query periodically and my idea was to call getUTCTimestamp(0) for the first query where getUTCTimestamp is:

function getUTCTimestamp(uint256 delay) payable {
   oraclize_query(delay,"WolframAlpha", "Timestamp now");
}

and then inside the callback call getUTCTimestamp(60) to have a call every 60 seconds. The thing is that the call inside callback is never executed and I imagine that happens because no ether is supplied. Is this correct? Is there any way to achieve what I want?

1

Is there any way to achieve what I want?

Yes, recursive queries are very possible using Oraclize.

From the Oraclize documentation at recursive queries:

Smart contracts using Oraclize can be effectively autonomous by implementing a new call to Oraclize into their __callback method. This can be useful for implementing periodic updates of some on-chain reference data, as with price feeds, or to periodically check for some off-chain conditions.

Oraclize recommend to use this kind of queries with particular attention.

The thing is that the call inside callback is never executed and I imagine that happens because no ether is supplied. Is this correct?

Correct. Remember that with Oraclize only the first query is free. After the first you need to pay.You can find at this link more information about the prices: Oraclize pricing.

What you need to do perform recursive queries is just provide your smart contract enough ether to pay for the Oraclize Query multiple times.

  • I have been using remix.ethereum.org to test oraclize in my smart contract which has some ether, but from your answer it seems that I would need to use real ether to achieve what I want. My understanding was that remix was just simulating everything and I could use "fake" ether. – David Feb 20 at 10:32
  • Yes, remix is using fake ethers. – Riccardo Persiani Feb 20 at 10:33
  • To clarify, Remix is mainly a testing tool, so use "fake" ethers. For recursive queries - you can copy and paste this recursive example in Remix, and test it: github.com/oraclize/ethereum-examples/blob/master/solidity/…. If you use the JVM environment - which you can select under the "Run" section from the menu on the right - Remix will use only fake ethers, and provide you a fast way for testing smart contracts. Remember to launch the Oraclize plugin before deploying your contract and using its functions, under the "Settings" section from the menu on the right. – Riccardo Persiani Feb 20 at 10:38
  • I tried to run that example but it is not working even though I supplied some ether to the smart contract. What happens is that only the first call is made and not the recursive ones. What could be the problem? – David Feb 20 at 11:05
  • Have you run the plugin from the "Settings" tab on the menu? It is the only way to make the Oraclize example work with the JavaScript Vm environment.You should see a window showing that the plugin is open. Please, remember to not close it when you perform the query, and to not open it multiple times – Riccardo Persiani Feb 20 at 12:44

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.