Last active
November 11, 2017 14:51
-
-
Save austintgriffith/0ef176bc1878407917eb958588833089 to your computer and use it in GitHub Desktop.
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
pragma solidity ^0.4.11; | |
/* | |
A simple 'request oracle client' that needs to know the price of Eth and Bch | |
*/ | |
contract EthVsBch { | |
//string to hold source address of oracle | |
address public source; | |
function EthVsBch(address _source) { | |
source = _source; | |
} | |
//anyone can get any price by symbol | |
function whoIsWinning() constant returns (string,uint) { | |
Store store = Store(source); | |
uint priceOfEth = store.getPrice("ETH"); | |
uint priceOfBch = store.getPrice("BCH"); | |
if( priceOfEth > priceOfBch ){ | |
return ("ETH",priceOfEth); | |
}else if ( priceOfEth < priceOfBch ){ | |
return ("BCH",priceOfBch); | |
}else{ | |
return ("TIE!",priceOfEth); | |
} | |
} | |
} | |
//simple Store interface with just the function we need | |
contract Store{function getPrice(bytes32 _symbol) constant returns (uint) {}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment