Guard function to incoming ERC721-ERC1155's

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.

Take a look at ERC1155 receivers.

ERC1155 tokens are transferred using the safeTransferFrom method. If the receiver is a contract, it must implement the onERC1155Received function defined in the standard

   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.

1 Like