Created
January 3, 2019 08:31
-
-
Save 0x3bfc/1f5c0e82c03a0bdb1d1dda2955ed854d to your computer and use it in GitHub Desktop.
Oraclize.sol
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 "github.com/oraclize/ethereum-api/oraclizeAPI_0.5.sol"; | |
contract OracleExample is usingOraclize { | |
string public EURUSD; | |
function updatePrice() public payable { | |
if (oraclize_getPrice("URL") > address(this).balance) { | |
//Handle out of funds error | |
} else { | |
oraclize_query("URL", "json(http://api.fixer.io/latest?symbols=USD).rates.USD"); | |
} | |
} | |
function __callback(bytes32 myid, string memory result) public { | |
require(msg.sender == oraclize_cbAddress()); | |
EURUSD = result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment