I have this contract.

pragma solidity >= 0.4.0;
import "./oraclizeApi.sol";

contract USDPrice is usingOraclize {

    string public price;
    address public owner;
    event Log(string text);

    function USDPrice() {
        Log("Contract created.");
        owner = msg.sender;
        OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
        oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
        oraclize_setCustomGasPrice(20000000000 wei);

    function getPrice() constant returns (string) {
       return price;

    function __callback(bytes32 _myid, string _result){
        require (owner == oraclize_cbAddress()); revert();
        Log("Intra in callback");
        price = _result; // let's save it as $ cents

    function update() payable {
         if (oraclize_getPrice("URL") > this.balance) {
            Log("Not working");
            // "Oraclize query was NOT sent, please add some ETH to cover for the query fee
        } else {
            // Oraclize can be queried
            oraclize_query(0,"URL", "https://www.random.org/integers/?num=1&min=1&max=6&col=1&base=10&format=plain&rnd=new");

To deploy it i am using Remix IDE and web3 provider ( localhost:8545 where i have my geth connection and accounts). When i want to execute update function, it is working , the query is sent , but the callback function is not transacting / triggering and i didnt get any result.Also in Remix console i have no errors. I have no idea what to do. Can anyone help me?

2 Answers 2


User Rick Park is very close with his answer, in that there is a problem is in the first line of your __callback function. You appear to have both a require that checks the wrong variabel, & it's followed immediately by a revert. So even if the requirement passes, it immediately hits a revert statement, hence you getting no callback.

You need either:

function __callback(...) public {
    require(msg.sender == oraclize_cbAddress());
    // ...


function __callback(...) public {
    if(msg.sender != oraclize_cbAddress()) revert();
    // ...

Note: The former is the more standard/idiomatic method you'll see used in Solidty.



Second thing to note is that if you're using Remix, you'll need to load the Oraclize plugin via the settings tab on the top right hand side. This loads the infastrucutre behind the scenes that Oraclize uses to correctly make callbacks in a local-network environment, such as you're using.

If you want to go fully local, you could always start using Truffle to manage and test your contracts, and Oraclize have Truffle versions of their contracts for you to peruse here.


Your callback shall never work this way. Watch here:

    require (owner == oraclize_cbAddress());

The first line apparently shall be ever triggered because owner (a public variable in your contract, nothing more!) is ever empty or different from oraclize_... because nobody write oraclize_... to it. So the require trigger immediately a revert.

But, in the strange case someone not shown here shall write oraclize_... in owner, you have an explicit “revert” which shall be ever triggered.

It seems you are interpreting the require like an ‘if’, but require is not that.

Begin correcting this.

BTW there are some other errors in the code. F.i. any event trigger is to be written as

emit Log(“Hi!”);

without the emit it should not compile at all! How did you test it?

Hope this helps!

  • The compiler version in OP's code is 0.4.0 or greater, & so can easily compile without the emit keyword if they've used any compiler between 0.4.0 and 0.4.20.
    – gskapka
    Commented Dec 23, 2018 at 9:32
  • 1
    You are not right in my opinion: your require use “owner”, not msg.sender. So it cannot be ever true. On the second point: if you write pragma solidity >= 4.0 you should be compliant with it. If it cannot compile if it is, let’s say, 0.4.22, your code is poorly written and substantially wrong.
    – Rick Park
    Commented Dec 23, 2018 at 11:10
  • Oops - yes, the owner in the require is wrong - you're correct Rick! The format in my answer below is correct though and is what is idiomatic of the Oraclize examples in their API. Re the not-compiling. You asked how the user was able to test it, and looking at their code it's clear they selected a compiler in the range 0.4.0 <= compilerVersion < 0.4.21 and ∴ didn't receive any compiler errors despite the lack of the emit keyword.
    – gskapka
    Commented Dec 23, 2018 at 11:19

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.