0

I faced a wired behavior on EVM. It's supposed to state-changing external calls between contracts can not bring return value back. Here is the code:

The interface:

    interface MyLogic{
        function ModifyData(uint c, uint256[] memory d) external returns (uint256);
    }

On the proxy contract:

First approach:

    function makeCall(uint command, uint256[] memory _data) public  returns (uint256){
        logic = MyLogic(_logicAddress);
        return logic.ModifyData( command, _data);
    }

Second approach:

    uint256 private _latestValue;
function makeCall(uint command, uint256[] memory _data) public  returns (uint256){
    logic = MyLogic(_logicAddress);
    _latestValue = logic.ModifyData( command, _data);
    return _latestValue ;
}

function getLatestValue() public view returns(uint256) {
    return _latestValue;
} 

Obviously, I don't get any return value in both approaches when I call the "MyCall" function.

But when I call the "getLatestValue" right after that, it has the correct return value of the "MyCall".

Apparently, the return value of "MyCall" somehow comes to and even being saved on the proxy contract's storage by the first call, but I have no idea why it doesn't show up at first.

Any clue?

Matthew
  • 11
  • 2
  • That's not correct. When a function is executed by another contract the return value will be available to the caller contract. The confusion maybe caused by the fact there isn't an api to get the value returned by a function executed in a transaction. The value exists, it isn't stored on the blockchain and the only way to get it is to trace the transaction. – Ismael Feb 12 '22 at 17:08
  • @Ismael well the "interface MyLogic" is the ABI that I provided in the proxy contract which "ModifyData" function is based on that. Also, I tested to provide it as a contract like this link. results was the same. Can you tell me how else I can provide the ABI? – Matthew Feb 13 '22 at 05:35
  • What do you mean by "I don't get any return value"? Also can you clarify the "when I call the "MyCall" function", how are you making the call? Read this to know the difference between a transaction and a call https://ethereum.stackexchange.com/questions/765/what-is-the-difference-between-a-transaction-and-a-call. – Ismael Feb 13 '22 at 20:39

0 Answers0