What are the benefits of ERC721Holder.sol?

@naszam asked:

Hi @naszam,

ERC721Holder is a convenience contract to inherit if you have a contract that allows receiving (and hence holding an ERC721) when safeTransferFrom is being used

See the Rationale section of the EIP for further details: https://eips.ethereum.org/EIPS/eip-721

1 Like

Thanks! In my case, the contract won’t hold any NFTs, cause they will be minted by external accounts. So I don’t need to include it right?

1 Like

Hi @naszam,

You shouldn’t inherit from ERC721Holder as you don’t want to hold ERC721 tokens in your contract.

If you wanted to, you could implement IERC721Receiver to reject any ERC721 transfers to your contract when made with safeTransferFrom. The opposite of ERC721Holder.

1 Like

Hi @abcoathup !

Sorry I'm a little confused by your answer above:

If you wanted to, you could implement IERC721Receiver to reject any ERC721 transfers

What I don't understand is why should I? I mean, if I don't implement erc721receiver, safeTransferFrom will revert anyway, won't it? So why bother, what is the advantage in explicitly implementing this interface?

Thank you in advance

@frangio help please :pray: :pray:

You're right, it's not necessary to manually implement IERC721Receiver in order to reject ERC721 safeTransfer.

1 Like