Encoding function call data from upgradeable contract itself

Hello @sharma66mahesh! You can use Solidity’s native ABI Encoding and Decoding Functions.

Here is an example from OpenZeppelin Contracts:

    bytes memory returndata = to.functionCall(abi.encodeWithSelector(
        IERC721Receiver(to).onERC721Received.selector,
        _msgSender(),
        from,
        tokenId,
        _data
    ), "ERC721: transfer to non ERC721Receiver implementer");

I’m closing Is there a way to encode/decode the initializer function with its arguments as a duplicate.

2 Likes