Guarantee a contract can only receive one type of ERC721 nft
Creating a contract for a privateSale fo ERC721 NFTs, first I mint some inventory to the privateSale contract address implementing onErc721Received(...) what I want to guarantee is that this privateSaleContract does only receive ERC721 tokens from one given NFT type (by its contract address)
How can I guarantee that?
Solution 1:
The ERC721 standard defines two types of transfer functions:
-
safeTransferFrom()
that checks if the receiver is a contract - and if it is, tries to execute theonERC721Received()
function on the receiver. - But also a non-safe transfer function (
transferFrom()
) that is not supposed to call theonERC721Received()
.
So anyone can send you NFTs using the non-safe transfer function without invoking any function on your contract. Which makes these transfers unblockable.