# Encoding function call data from upgradeable contract itself

**URL:** <https://forum.openzeppelin.com/t/encoding-function-call-data-from-upgradeable-contract-itself/3285>\
**Category:** Contracts\
**Tags:** upgrades\
**Created:** [July 10, 2020, 6:11am UTC](https://forum.openzeppelin.com/t/encoding-function-call-data-from-upgradeable-contract-itself/3285 "2020-07-10T06:11:01Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![martriay](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/martriay/32/20_2.png) [@martriay](https://forum.openzeppelin.com/u/martriay)\
**Post date:** [July 10, 2020, 6:33pm UTC](https://forum.openzeppelin.com/t/encoding-function-call-data-from-upgradeable-contract-itself/3285/2 "2020-07-10T18:33:39Z")

</div>

Hello @sharma66mahesh! You can use [Solidity’s native ABI Encoding and Decoding Functions](https://solidity.readthedocs.io/en/v0.6.11/units-and-global-variables.html?highlight=encodewithselector#abi-encoding-and-decoding-functions).

[Here is an example](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol#L441-L447) 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](https://forum.openzeppelin.com/t/is-there-a-way-to-encode-decode-the-initializer-function-with-its-arguments/3260) as a duplicate.

---

_[View the full topic](https://forum.openzeppelin.com/t/encoding-function-call-data-from-upgradeable-contract-itself/3285)._
