Can you make an ERC1155 contract receive an ERC721 token?

522 Views Asked by At

I've got an ERC1155 contract and I want it to receive an ERC721 token and give other tokens in exchange for that. Can I somehow add ERC721 Receiver interface?

1

There are 1 best solutions below

0
On

Yes you can do that. It would be best to start looking here at OpenZeppelins documentation on it: https://docs.openzeppelin.com/contracts/2.x/api/token/erc721#IERC721Receiver

In your method that accepts ERC721 tokens, you will need to make sure that the sender approves your contract to transfer tokens on their behalf or else the transaction will fail.

In conjunction with IERC721Receiver you have to use the safeTransferFrom method for this to work properly.

hope this helps.