When we call a function on an external contract, the EVM computes a bytes buffer which contains the function signature and arguments.
There are two ways to serialize arguments:
abi.encode()
abi.encodePacked()
The differences between the two functions are well documented and I have understood them.
What I want to understand is why there are two functions in the first place. It is not clear when we should use the first and when - the second.
How can I see which function is used internally when I execute the following calls?
Call 1:
(success, ) = address(c).call(abi.encodeWithSignature("myfunction(uint256,uint256)", 400,500));
Call 2:
(success, ) = address(c).call(abi.encodeWithSelector(bytes4(keccak256("myfunction(uint256,uint256)")), 400,500) )
Call 3:
(success, ) = address(c).call( bytes4(keccak256("myfunction(uint256,uint256)")), 400, 500);
Call 4:
contract_instance.myfunction(400,500);
Thanks a lot!