-
-
Save bertani/78f0718a152d31c3744deef9bedd471f to your computer and use it in GitHub Desktop.
CryptoComparePriceTicker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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