Skip to content

Instantly share code, notes, and snippets.

Last active July 29, 2020 11:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
struct Query
uint id;
function(uint, bytes memory) external callback;
contract Oracle
event Queried(bytes,function(uint, bytes memory) external);
Query[] public queries;
uint public price;
address immutable owner = msg.sender;
modifier onlyowner { require(msg.sender == owner); _; }
function query(bytes calldata q, function(uint, bytes memory) external callback) public payable returns (uint id) {
require(msg.value == price);
id = queries.length;
queries.push(Query(id, callback));
emit Queried(q, callback);
function resolve(uint id, bytes calldata response) onlyowner public {
Query memory q = queries[id];
delete queries[id];
q.callback(id, response);
function withdraw() onlyowner public {
function setPrice(uint _price) onlyowner public {
price = _price;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment