I am trying to use the example Oraclize contracts at https://github.com/oraclize/ethereum-examples/tree/master/solidity, including KrakenPriceTicker.sol
. Here's my contract (modified very slightly):
pragma solidity ^0.4.0;
import "github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol";
contract KrakenPriceTicker is usingOraclize {
string public ETHXBT;
uint public timesCalled;
uint public timesFailed;
event newOraclizeQuery(string description);
event newKrakenPriceTicker(string price);
function KrakenPriceTicker() payable {
oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
}
function __callback(bytes32 myid, string result, bytes proof) {
ETHXBT = result;
newKrakenPriceTicker(ETHXBT);
update();
}
function update() payable {
if (oraclize_getPrice("URL") > this.balance) {
newOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
timesFailed++;
} else {
newOraclizeQuery("Oraclize query was sent, standing by for the answer..");
oraclize_query(60, "URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHXBT).result.XETHXXBT.c.0");
timesCalled++;
}
}
}
When the update()
function is called and some ether and gas sent with it, it should call the kraken.com api and update the value of ETHXBT
with what's returned. However, the value of ETHXBT
is always blank. I know the oraclize_query
is being called because the timesCalled
variable does increment. So there appears to be an issue with the result returned, though going directly to https://api.kraken.com/0/public/Ticker?pair=ETHXBT shows there shouldn't be any problem.
I've deployed the above contract at https://ropsten.etherscan.io/address/0x2c51daecf702f2afe3abee2cc84570ee17f75650 (I've tried to call update()
several times).