-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Closed
Labels
breaking changeChanges that break backwards compatibility of the public API.Changes that break backwards compatibility of the public API.
Milestone
Description
🧐 Motivation
Since 0.8.11, abi.encodeCall
provide type-safe encode utility comparing with abi.encodeWithSelector
.
📝 Details
Example below and detail are from DevTools Summit | Topics in Solidity - Harikrishnan Mulackal.
abi.encodeWithSelector
can use with interface.<function>.selector
to prevent typo error, but it doesn't provide type checking.
interface miniERC20 {
function transfer(address to, uint256 value) external;
}
// works successfully
function transferData(uint256 to, uint256 value)
public
pure
returns (bytes memory)
{
return abi.encodeWithSelector(miniERC20.transfer.selector, to, value);
}
abi.encodeCall
provide type checking during compile time.
function transferData(uint256 to, uint256 value)
public
pure
returns (bytes memory)
{
return abi.encodeCall(miniERC20.transfer, (to, value));
}
result
error[5407]: TypeError: Cannot implicitly convert component at position 0 from "uint256" to "address".
gruz0, CJ42 and Skyge
Metadata
Metadata
Assignees
Labels
breaking changeChanges that break backwards compatibility of the public API.Changes that break backwards compatibility of the public API.