0

I have the following contract to get a random number from 1 to 6 from random.org:

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

contract RandomOrg is usingOraclize {
    string public res;

    event Log(string text);

    function RandomOrg() {

        Log("Created!");
    }


    function __callback(bytes32 myId, string _result) {
        if (msg.sender != oraclize_cbAddress()) revert();


        res = _result; // 'result' is the random number generated by random.org
        Log(res);
        updateNumber();

    }

    function updateNumber() payable {
        string memory query = "https://www.random.org/integers/?num=1&min=1&max=6&col=1&base=10&format=plain&rnd=new";
        oraclize_query(0, "URL", query);
    }

}

When using MetaMask and Oraclize dev IDE, the contract is successfully created, however, when calling the updateNumber() function (with or without msg.value, result is the same), I'm getting the following error:

callback contain no result Error: JsonRpcEngine - response has no error or result for request:
{
  "jsonrpc": "2.0",
  "id": 255617697,
  "method": "eth_estimateGas",
  "params": [
    {
      "from": "0x3768372d20afe96dde0c27677b916046cd32002d",
      "to": "0xe931380cb4389dce98227e095e41c9927433504e",
      "data": "0x1b6a2481",
      "value": "0xde0b6b3a7640000"
    }
  ]
}

What could be the reason of this?

1

Riccardo from Oraclize here.

I used:

  1. Metamask on Rinkeby testnet;
  2. Value for the updateNumber(): 1ETH;
  3. Gas price: 20gwei

I just tried this contract from REMIX and worked:

pragma solidity ^0.4.0;
import "./oraclizeAPI_0.5.sol"; //API copied from the oraclize github folder

contract RandomOrg is usingOraclize {
    string public res;

    event Log(string text);

    function RandomOrg() {

        Log("Created!");
    }


    function __callback(bytes32 myId, string _result) {
        if (msg.sender != oraclize_cbAddress()) revert();


        res = _result; // 'result' is the random number generated by random.org
        Log(res);
        updateNumber();

    }

    function updateNumber() payable {
        string memory query = "https://www.random.org/integers/?num=1&min=1&max=6&col=1&base=10&format=plain&rnd=new";
        oraclize_query(0, "URL", query);
    }

}
  • Thanks, it did work, although I'm not sure why I was getting the JSON error. – Ruham Jun 27 '18 at 19:50

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.