Assume I have two contracts:

contract A {
    function test1() public view returns(bool) {
        return false;
contract B {
    function testCall(address addr, data) public view returns(bool) {
        return addr.call.value(0)(data);

Then I call testCall in javascript:

const a = await A.new()
const b = await B.new()

const aWeb3 = web3.eth.contract(a.abi)
const aInstance = aWeb3.at(a.address)

const testData = aInstance.test1.getData()

const ans = await bInstance.testCall(aInstance.address, testData)


In this case, ans should be false, but it returns true


The addr.call type call returns true on success and false otherwise. To get the actual return value you need to either use the high-level contract interface system or use assembly like

    let success := call(10000, addr, 0, add(data, 0x20), mload(data), 0, 0x20)
    res := mload(0)
return res

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.