Created
January 21, 2017 09:07
-
-
Save christoph2806/0686dffe99792a9bcdf7d6de123a33b3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.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