0

I need to create an ERC20 token which transfer and reception is restricted by a membership, indicated by an NFT (ERC721) in the sender's and receiver's address/wallet.

How can I check in the ERC20 transfer() function whether the sender and receiver are owner of that particular NFT (ERC721, membership)?

1 Answer 1

0

If you use Open Zeppelin's ERC20 implementation you can reference their guide for extending contract functionality.

Alternatively, you can implement the ERC20 functions by hand and add any custom logic you need.

2
  • Thank you very much BrvarG for your advice. How do I technically implement the check in the ERC20 transfer() function, i.e. checking whether the msg.sender owns a particular ERC721 (or any other tokens) in his address?
    – user66732
    Feb 3, 2021 at 12:50
  • Use the function function _validRecipient(address to, address from) private view returns (bool) { // e.g. return myNftContract.ownerOf(tokenId) == to; } that is shown in the guide I linked. You also need to have a reference to an ERC721 contract and a tokenId.
    – BrvarG
    Feb 3, 2021 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.