0
votes

I have a problem about handle function value.

likes the title ..

I already know contract's function call other contract's function depend on:

addr.call(abi.encodeWithSignature("function(parameter_type)", parameter ));

but what if I want to handle the function's value(ex:bool) temporarily (memory) for condition .

I had seen abi.encodePacked() , but I don't even know what parameter feedback to me (compile error , different parameter type), that I can't even storage it .

Some articles write it only for bytes, uint , but I only want to do condition(bool).

1

1 Answers

0
votes

You don't need to do that .call unless you want to preserve the msg.sender.

If the msg.sender does not matter for you, I recommend you to look at interfaces. Now, what you have to do, is to create an interface with the functionB definition of that you want to call, and then call it.

Example:

(some deployed contract)

contract MySecondContract {
  function functionB() public returns(bool) {
    return true;
  }
}

(get the deployed contract address and use it in your code like)

interface IMySecondContract {
  function functionB() external returns(bool);
}

contract MyFirstContract {
  function functionA() public returns(bool) {
      bool result = IMySecondContract(MySecondContract-address-here).functionB();
      return result;
  }
}

If you do want to keep using .call, here you can see that the .call method returns two values.

Something like

(bool success, bytes myReturn) = addr.call(...);

and then this, might work.

Something else that might help is this new way of debugging.