# Guard function to incoming ERC721-ERC1155's

**URL:** <https://forum.openzeppelin.com/t/guard-function-to-incoming-erc721-erc1155s/15974>\
**Category:** Smart Contracts\
**Created:** [September 22, 2021, 9:34pm UTC](https://forum.openzeppelin.com/t/guard-function-to-incoming-erc721-erc1155s/15974 "2021-09-22T21:34:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Obji](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/obji/32/9062_2.png) [@Obji](https://forum.openzeppelin.com/u/Obji)\
**Post date:** [September 22, 2021, 9:34pm UTC](https://forum.openzeppelin.com/t/guard-function-to-incoming-erc721-erc1155s/15974/1 "2021-09-22T21:34:07Z")

</div>

I have contract 1 which generate ERC-1155 tokens.  
And I have contract 2 which work with this tokens.

How properly receive and approve my tokens in contract 2, only if they belong to contract 1 creator address? Which function I can use?

Contract 2 need to reject to work with all tokens, if they don't belong to creator contract 1.

---

<div class="post-metadata">

**Author:** ![STYJ](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@STYJ](https://forum.openzeppelin.com/u/STYJ)\
**Post date:** [September 23, 2021, 5:25am UTC](https://forum.openzeppelin.com/t/guard-function-to-incoming-erc721-erc1155s/15974/2 "2021-09-23T05:25:29Z")

</div>

Take a look at ERC1155 receivers.

---

<div class="post-metadata">

**Author:** ![Amxx](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/amxx/32/668_2.png) [@Amxx](https://forum.openzeppelin.com/u/Amxx)\
**Post date:** [September 23, 2021, 9:39am UTC](https://forum.openzeppelin.com/t/guard-function-to-incoming-erc721-erc1155s/15974/3 "2021-09-23T09:39:32Z")

</div>

ERC1155 tokens are transferred using the `safeTransferFrom` method. If the receiver is a contract, it must implement the `onERC1155Received` function defined in [the standard](https://eips.ethereum.org/EIPS/eip-1155)

```auto
   onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns bytes4

```

Your contract 2 should implements it in a way the accepts transfers of you tokens but reject everyhting else.
