1

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).

1

It looks like the query is working on the Oraclize Test site. You can see it working here. It has a request like:

json(https://api.kraken.com/0/public/Ticker?pair=ETHXBT).result.XETHXXBT.c[0]

with a response of 0.068000

It seems your syntax is incorrect when you use .result.XETHXXBT.c.0 instead of .result.XETHXXBT.c[0] since the result is an array and not a key named 0

0

The issue was that the ropsten test network I was using was having issues. I believe the code I posted should normally run fine.

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.