How does one specify gas or value making a call this way:
contract AbstractB {
function getX() returns(uint);
}
contract A {
function makeCall(address addressB){
AbstractB(addressB).getX();
}
}
The following doesn't work(Error: Member "gas" not found…):
AbstractB(addressB).gas(0).getX();
Best Answer
EDIT: I upvoted and recommend @Xavier's answer (@BokkyPooBah's answer is missing
()
at the end).It's more type-safe and here's an example showing the return value of
getX
. You do need to provide non-zero gas:OLD: Use
call.gas(g).value(v)(methodId, args)
syntax. Not recommended because not type-safe and you don't get the return value ofgetX
.Example:
addressB.call.gas(0).value(1 ether)(bytes4(sha3("getX()")));
Complete example, which should always checks the return value of
call
: