Testing out oraclize for a smart contract.

function __callback(bytes32 _myid, string result) public {
   if (msg.sender != oraclize_cbAddress()) revert();
    // emit LogOraclizeID(bytes32ToString(_myid));
    // string memory number = result[0].data;
    emit LogQueryEvent("Are we firing here boys?");
    emit LogRandomNumber(result);

// This is NOT truly random. Just a proxy for basic testing.
function random() public payable returns (uint) {
    if (oraclize_getPrice("WolframAlpha") > address(this).balance) {
        emit LogQueryEvent("Please send some ETH along to make transaction.");
    } else {
        // string memory numTokensToString = uint2str(tokens.length);
        // string memory queryString = "random number between 0 and ".toSlice().concat(numTokensToString.toSlice());
        // oraclize_query("WolframAlpha", "random number between 0 and 2"); 
        emit LogQueryEvent("Oraclize query was sent, standing by for the answer..");

        oraclize_query("WolframAlpha", "random number between 0 and 2");

    // return uint(keccak256(abi.encodePacked(block.difficulty, now, tokens.length)));


Trying to improve randomness on a particular contract. The __callback doesn't appear to fire. Testing this in remix.

Is this an issue with how I'm setting up the call, or a limitation of remix?

2 Answers 2


To receive a __callback() you need to have the infrastructure of Oraclize running on the same chain. If you using remix you probably using a memory chain, and everytime you refresh the browser its wiped. You need to use Ropsten for that work, or use a ethereum bridge with oraclize.

The simpliest way is using the IDE provided by Oraclize: http://dapps.oraclize.it/browser-solidity/#gist=9817193e5b05206847ed1fcd1d16bd1d&version=soljson-v0.4.25+commit.59dbf8f1.js that would use a memory chain with oraclize supported.

If you need further, you can use https://github.com/oraclize/ethereum-bridge to enable your private ethereum network interfacing with oraclize.

  • I'm using MetaMask to deploy on Ropsten instead of the JS VM, but I'll try to toss my code into their IDE just in case as a test.
    – Tulun
    Commented Nov 21, 2018 at 5:29
  • If that's the case, you might need to pay the fee. BTW, when I worked with oraclize I experienced this problem sometimes, maybe their ropsten node is down for a while. Commented Nov 21, 2018 at 7:33
  • First call is failing, which is free :) Subsequent are nicely logging I need fees, but that event is in the random function, not the callback. Yeah, fair enough. I'll give the IDE a try, and if that fails, I'll just hack together a basic frontend to see what events are firing. I think I have some rinkeby ETH if that one is a bit more reliable.
    – Tulun
    Commented Nov 21, 2018 at 16:18
  • the link for the IDE is broken. I too am having difficulty getting my callback to fire: eosio.stackexchange.com/questions/5179/…
    – ekkis
    Commented Jan 1, 2020 at 3:38

Looks like this is an issue with remix communicating directly with Oraclize.

I built a basic frontend app to watch events on a Ropsten deployed contract, and they showed up as expected in console.

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.