Skip to content

Instantly share code, notes, and snippets.

@bertani
Created May 4, 2016 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertani/78f0718a152d31c3744deef9bedd471f to your computer and use it in GitHub Desktop.
Save bertani/78f0718a152d31c3744deef9bedd471f to your computer and use it in GitHub Desktop.
CryptoComparePriceTicker
import "dev.oraclize.it/api.sol";
contract CryptoComparePriceTicker is usingOraclize {
address owner;
uint public ETHUSD;
function CryptoComparePriceTicker() {
owner = msg.sender;
oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
update();
}
function __callback(bytes32 myid, string result, bytes proof) {
if (msg.sender != oraclize_cbAddress()) throw;
ETHUSD = parseInt(result, 2);
update();
}
function update() {
oraclize_query(60, "URL", "json(https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD).USD");
}
function kill(){
if (msg.sender == owner) suicide(msg.sender);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment