solidityerc721cryptocurrency-airdrop

How to airdrop NFTs to specific NFT owners?


I want to understand how can we give free ERC721 or ERC20 tokens to specific NFT owner addresses. For example Bored Ape yacht club created an ERC20 coin with a pre-defined amount which can be claimed only from the owners of the BAYC NFTs. I tried to find out an answer in their smart contracts, but I couldn't find their ERC20 coin contract therefore I can't figure out how the restrict the distribution of coins.

In my project I want to create 2 ERC721 smart contracts and all owners of NFTs from the first contract should be able to mint for free NFTs from the second smart contract. If you are an owner of an NFT from smart contract 1 you can claim free NFT from smart contract 2. Can you provide me with some resources or ideas where I can learn how to achieve that


Solution

  • You can, in the second smart contract, check whether the caller of the mint function is a token holder of the first smart contract or not.

    function mint() external {
      require(IERC721(_firstToken).balanceOf(msg.sender) > 0, 'should be a holder of the first token');
    
      _mint();
    }
    

    You can import ERC721 interface from openzeppelin library, or just cut&paste from EIP-721.