I have two Solidity contracts, where contract Caller
depends on a second contract Callee
. Contract Callee
provides a public view function which checks the validity of a string (e.g. an password), according to some internal rules. Caller
needs to check a string in its own function by calling Callee
, before he can further process. Furthermore Caller
needs to call the function of Callee
by using delegatecall
, because the internal validity check considers the calling address.
contract Caller {
function doSomething(string _text, address _callee) public {
bool valid = bool(_callee.delegatecall(
bytes4(keccak256("check(string _text)")), _text)
);
require(valid == true);
/* further process if text is valid */
}
}
contract Callee {
function check(string _text) public view returns(bool){
/* validity check */
return true;
}
}
The problem with this code is, that the call of function check
seems to be asynchronous and therefore the require
statement in function doSomething
will always fail. Is this a problem of delegatecall
? Is there a way to call the external function synchronously?