I am using Remix with compiler 0.8.9. In the following codes, if contract BBB is deployed, using function aasenderaddr() in BBB with two addresses as function input would result in a "decoded input -" in the console.
However, delete any variable or the other function in the BBB, (or add a third function input), then use aasenderaddr() with two addresses input (or with the third function input) again, the console would decode the input without problems. Why?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Logstuff {
function senderaddr() public view returns (address) {
return msg.sender;
}
}
contract AAA {
function asenderaddr(address _contract) public returns (bytes memory) {
(bool success, bytes memory data) = _contract.delegatecall(
abi.encodeWithSignature("senderaddr()")
);
return data;
}
}
contract BBB {
uint public num;
address public sender;
function aasenderaddr(address _contract, address _contract2) public returns (bytes memory) {
(bool success, bytes memory data) = _contract.delegatecall(
abi.encodeWithSignature("asenderaddr()", _contract2)
);
return data;
}
function basenderaddr(address _contract, address _contract2) public returns (bytes memory) {
(bool success, bytes memory data) = _contract.call(
abi.encodeWithSignature("asenderaddr()", _contract2)
);
return data;
}
}