Use abi.encodeCall for Low Level Calls
Why Use abi.encodeCall?
abi.encodeCall?Example
pragma solidity ^0.8.0;
contract Example {
// f(uint amount) is changed to f(uint256 amount) after compilation
function f(uint amount) public pure returns (uint256) {
return amount * 2;
}
function unsafeEncode() public pure returns (bytes memory) {
// f(uint) does not exist
return abi.encodeWithSignature("f(uint)", 123);
}
}The Problem Explained:
Solution: Use abi.encodeCall
abi.encodeCallActionable Practices
Last updated

