-
-
Save Mobelis/8934bd1f72b59f00b5ce1e5f01ab8c91 to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.4+commit.4633f3de.js&optimize=undefined&gist=
This file contains hidden or 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
| /* | |
| Kraken-based ETH/XBT price ticker | |
| This contract keeps in storage an updated ETH/XBT price, | |
| which is updated every ~60 seconds. | |
| */ | |
| pragma solidity ^0.4.0; | |
| import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; | |
| contract KrakenPriceTicker is usingOraclize { | |
| uint8 public ETHXBT; | |
| event newOraclizeQuery(string description); | |
| event newKrakenPriceTicker(uint8 price); | |
| function KrakenPriceTicker() public { | |
| oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS); | |
| ETHXBT = 0; | |
| update(); | |
| } | |
| function __callback(bytes32 myid, string result, bytes proof) public { | |
| if (msg.sender != oraclize_cbAddress()) throw; | |
| ETHXBT = ETHXBT + 1; | |
| newKrakenPriceTicker(ETHXBT); | |
| update(); | |
| } | |
| function update() payable public { | |
| 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 counter"); | |
| oraclize_query(60, "URL", ""); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment