Oraclize and How-to a Basket of Coins

rhyzomrhyzom Member Posts: 1
Hey lads, maybe somebody can help me out here a little (and no, I'm not looking to be spoon fed, but would be nice to have a few things pointed out to me).

I did go through one introductory book on Solidity, then the official documentation, then Truffle's official documentation, then the Oraclize docs — I get the underlying logic, I can read Solidity code (first fragments that make sense, then on second read begin to tie things together in a comprehensive whole), but when encountered with actually writing much things come to a grinding halt.

And here is what I am trying to do, basically. Here is the Oraclize code to get ETH price from Kraken every 60 seconds, as given in the official site:

pragma solidity ^0.4.0;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

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


What I am trying to do is get the price of a number of.. things (coins, whatever) from coinmarketcap and sum them up in a single uint with which I'd like to work in another contract (or more like the same contract, incorporating that code within it, haven't figured that one out too yet).

So, I use the coinmarketcap API, that much is clear. Specify all the strings. But I can't figure out how to go from there — new events for each ticker? New queries and callbacks for sure, I get that -- but how to adequately structure it? And then, to do the math I assume the SafeMath library must be used, correct?

Any help will be really appreciated.
Sign In or Register to comment.