Created
August 17, 2018 15:13
-
-
Save k5trismegistus/ed0cb54fa9fddeb7c4d99b65c6105b70 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.23; | |
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; | |
contract OracleTest is usingOraclize { | |
bool public isTrue; | |
event NewOraclizeQuery(string _description); | |
event NewOracleResultCount(bool _isTrue); | |
function OracleTest() public { | |
update(); | |
} | |
function __callback(bytes32 myid, string result) public { | |
if (msg.sender != oraclize_cbAddress()) revert(); | |
isTrue = (keccak256(result) == keccak256("true")); | |
NewOracleResultCount(isTrue); | |
} | |
function update() public payable { | |
NewOraclizeQuery("Oraclize query was sent, standing by for the answer.."); | |
oraclize_query("URL", 'json(https://hogehoge.com/api).isTrue'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment