# 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:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharma66mahesh](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/sharma66mahesh/32/2665_2.png) [@sharma66mahesh](https://forum.openzeppelin.com/u/sharma66mahesh)\
**Post date:** [July 10, 2020, 6:11am UTC](https://forum.openzeppelin.com/t/encoding-function-call-data-from-upgradeable-contract-itself/3285/1 "2020-07-10T06:11:01Z")

</div>

[https://docs.openzeppelin.com/upgrades/2.8/creating-upgradeable-from-solidity#encoding\_call\_data](https://docs.openzeppelin.com/upgrades/2.8/creating-upgradeable-from-solidity#encoding_call_data)  
This particular section of the article shows how to encode the function call data from node and then pass it to contract. However, I have a use case where I have to encode the call data from contract itself. Is that possible?

P.S. I had asked about this before here but had no response. So I am just rephrasing my question in a different way.

---

<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.
