I wish to use Oraclize to get prices for different ticker symbols. From the example

contract KrakenPriceTicker is usingOraclize {

    string public ETHXBT;

    event newOraclizeQuery(string description);
    event newKrakenPriceTicker(string price);

    function KrakenPriceTicker() {
        oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);

    function __callback(bytes32 myid, string result, bytes proof) {
    if (msg.sender != oraclize_cbAddress()) throw;
        ETHXBT = result;

    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");
    } 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");


I wish to modify this contract to take a symbol as an input, not ETHXBT. I see the oraclize_query to have a fixed string, how can the query be changed to allow this?

oraclize_query(60, "URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHXBT).result.XETHXXBT.c.0");

I also wish to extent this with multiple arguments if requested in input, as an example


How to add this?

1 Answer 1


To use a symbol as an input, you can use the utils present in the oraclizeAPI, such as strConcat, which helps you concatenate strings:

oraclize_query(60, "URL", strConcat("json(https://api.kraken.com/0/public/Ticker?pair=", symbol,").result.", symbol,".c.0"));

If you want to receive multiple pairs prices at the same time via the Krakn API you can use the JSONPath. For example,


will return the current prices of ETH/BTC and ETH/USD as an array (test here).

To parse the result string and convert it to an array you should use the string-utils solidity library.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.