I have a contract that uses Oraclize to query some bits of data. Basically, I have the following three functions:
getData()
- calls Oraclize contract to query data,__callback()
- called automatically by Oraclize, when data received.setData()
- function to get the queried value and do smth.contract functionChain is usingOraclize { string public globalKey; function getData() public payable { string memory query = 'json(http://QUERY_LINK)'; //returns string oraclize_query(0, "URL", query, 250000); } function setData(string text) internal { text = globalKey; } function __callback(bytes32 myId, string result) { if (msg.sender != oraclize_cbAddress()) revert(); setData(result); } }
The logic I have now is the following:
1. getData()
is called
2. __callback() { setData() }
- setData()
is called by the __callback()
function.
The problem is, that even though I can successfully query the data via Oraclize, setData()
function is never being called. I am getting the logs of success only for the getData()
function.
Is this even a legit way to use Oraclize query result in a third function? If not, what would be the best way of linking those functions together, so that SetData()
is called after the __callback()
?
text = globalKey
toglobalKey = text
.