Skip to content

Instantly share code, notes, and snippets.

@christoph2806
Created January 21, 2017 09:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save christoph2806/0686dffe99792a9bcdf7d6de123a33b3 to your computer and use it in GitHub Desktop.
Save christoph2806/0686dffe99792a9bcdf7d6de123a33b3 to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.7;
contract usingCallback {
function __callback(uint id, string s) {}
}
contract A {
usingCallback C;
uint queryId;
function A () {}
function getString() returns(uint _queryId) {
C = usingCallback(msg.sender);
C.__callback(queryId++, 'hello World');
_queryId = queryId;
}
}
contract B is usingCallback {
A a;
string s;
uint queryId;
function B (address _a) {
a = A(_a);
}
function test () {
queryId = a.getString();
}
function __callback(uint id, string _s) {
if (id != queryId) {
throw;
}
s = _s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment