In the design of my dapp I am using Oraclize to get current time. Now from its __Callback function I want to call another function to which I need to pass other parameters as well along with current time returned.

How should I pass these additional parameters so that they reach the function inside the __callback function. One approach that I followed was to pass them first to function executing oraclize_query expecting they will reach the callback function (if I declare those parameters while its invocation) but that didn't work.

I started getting 'InternalCompilerError: Requested type not present' when I passed parameters to function executing oraclize_query.

Please help to guide what is the correct approach to implement such kind of logic. Will appreciate if sample code or references could be provided that attempted same logic

Thanks in advance

  • Can you share a sample of what you tried? Aug 8, 2018 at 19:22

1 Answer 1


One approach that I followed was to pass them first to function executing oraclize_query expecting they will reach the callback function

The callback function takes only two parameters:

function __callback(bytes32 myid, string result) {
  • The ID that was generated when you called oraclize_query()
  • The result of your query in the form of a string

The result being in the form of a string means you'll need to parse it according to your needs (e.g. to an integer or series of bytes, etc.). The arguments you passed to the function that called oraclize_query() aren't passed to the callback: the callback is called by Oraclize, and they don't know what those argument were.

To your actual question...

In short: You'll need to store the arguments you want to pass to the callback as state variables. Further, if you're expecting to run multiple queries, and the arguments might change for those queries, then you'll need a way to map the arguments to a particular Oraclize query ID.

Something along the lines of the below (untested) contract snippet should work.

contract Untested {

    // Set the arguments we want to pass to the callback into state data, 
    // such as a struct...
    struct OracleCallbackDetails {
        uint arg1;
        uint arg2;

    // ... and map a given query ID to a given set of arguments.
    mapping(bytes32 => OracleCallbackDetails) oracleDetails;

    // The callback is passed the query ID, which can then be used to look
    // up the arguments that were set.
    function __callback(bytes32 myid, string result) public {
        require(msg.sender == oraclize_cbAddress());

        OracleCallbackDetails storage details = oracleDetails[myid];
        functionToCall(details.arg1, details.arg2);

    // The function that called oraclize_query() is responsible for setting
    // the arguments that will be used by the callback.
    function doSomethingThatNeedsOraclize (uint arg1, uint arg2) {
        bytes32 queryId = oraclize_query("URL", <URL_string>);
        oracleDetails[queryId] = OracleCallbackDetails(arg1, arg2);

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.