How to Airdrop NFTs (Guide)

Last Updated:
January 11, 2023
Airdrop NFTs Feature Image

When you run an airdrop with Metacommerce, you benefit from three major gas saving techniques that allow creators to run cost-effective airdrop campaigns based on previous token-holdings.

Intro: How to Airdrop NFT

An airdrop is the process by which creators send NFTs, currency or tokens directly to wallets. 

Why airdrop NFTs?

There are many reasons a creator might run an airdrop:

  • As part of an initial coin offering (ICO)
  • As part of a bounty campaign
  • To run a free token giveaway 
  • As a reward or perk for holders of NFTs from a certain collection.

In this article we will be focusing on the final point - creators airdropping to existing holders of an NFT collection.

What is the difference between airdropping and dropping NFTs with an allowlist?

There are 2 primary ways in which creators can give wallet owners access to an NFT collection:

NFT drop with allowlist

Owner pays gas

Creators will often give wallet owners on an allowlist exclusive access to mint NFTs. This seems like an attractive option as it pushes the gas costs onto the buyer since they are responsible for writing their ownership of the token to the blockchain.

Considerations:
  • These kinds of drops can lead to a prolonged minting process as it takes some time for members of the allowlist to mint all of the NFTs. This means it takes a longer time for the market to stabilise and determine the value of the collection.
  • The hype generated by an allowlist is less concentrated than in an airdrop.
  • If the aim is to reward NFT holders, getting them to pay the cost of minting detracts for the feeling of winning.

Airdrop 

Creator pays gas

In an airdrop, the creator writes the ownership of NFTs onto the blockchain, meaning they cover the cost of the gas to do so. Airdrops are often a batch transfer executed using ERC-1155, which allows an array of NFTs to be transferred to an array of wallets.

Considerations:
  • Airdropped NFTs appear directly in an owner’s wallet - no action or cost is required from them in order to access the token.
  • Airdropping can cost $$$ for each NFT minted; for large collections an airdrop can cost many tens of thousands of dollars.
Overall, airdrops provide a better user experience for NFT holders;

They are free to receive and appear in all owners’ wallets automatically and simultaneously. However, up until now they have been prohibitively expensive to run. 

Could you airdrop on a cheaper platform, like Polygon, rather than Ethereum?

Yes, it is possible, but we would always recommend Ethereum.

ETH is regarded as the final settlement layer. There is social consensus that it is the authentic version of a digital asset. In addition, a lot of the biggest name NFTs are on the platform, creators can interoperate with other contracts and run owner cohorts on the biggest brands. It also has the largest NFT liquidity. 

Is there a way to reduce the costs of airdrops?

Yes, with Metacommerce Airdrop creators can send drops to current token holders for a fraction of the cost, by leverage Phantom Airdropping technology. Read more about it below

Metacommerce NFT Airdrops

When you run an airdrop with Metacommerce, you benefit from three major gas saving techniques that allow creators to run cost-effective airdrop campaigns based on previous token-holdings.

Building on the shoulders of giants

Many thanks to innovators in the space, most notably CHANCE and 0xInuarashi, whose findings provided a backbone for the development of the Metacommerce Airdrop. 

In this article we will walk through the gas saving techniques employed by the Metacommerce Airdrop.

1. Clone Factory Proxy-Standard


In the traditional method of creating airdrops, the creator needs to deploy both the implementation and storage of every new token. This is expensive if the creator seeks to run a series of airdrops. 

However, we notice that the specifications in each airdrop contract all have the same base functionality but different storage states. In order to save gas costs, the Metacommerce Airdrop deploys an airdrop template implementation with all the base functions and the creator just initialises a storage instance that points to that template through the clone factory. 

Metacommerce deploys a single template contract with all the required function implementations at a cost of around 2,829,008 units of gas. This is a cost that is covered, in advance, by Metacommerce and there are no recurring costs until the template contract needs an upgrade. This will never be a cost that the creator pays.

The creator, on the other hand, only needs to spend around 351817 units of gas to initialise the contract storage. That is ~ 8x less than what they would normally need to spend to deploy a contract.

2. Phantom Airdrop w/ EIP2309

MerkleTree Airdropping is one of the popular standards for allowing loyal token-holders to mint tokens out of a newly deployed airdrop-contract (aka write their ownership to storage). To give some benchmarks, the costs total to around 1,351,155 + N * 73,904 units of gas for contract deployment and minting. Where N Is the total number of token-holders that are permissioned to receive the airdrop. This cost can accumulate quickly with larger token-owner cohorts. In addition, the cost of receiving tokens is levied on the loyal token holder.

We can do better. 

Upon the initial drop, the parent-token ownership mapping is exactly the same as the child-token ownership mapping. The mappings diverge when owners in the child-token start transferring away their airdropped tokens. We take advantage of this fact and change the ownerOf(tokenId) function in the EIP721-standard to redirect the ownerOf(tokenId) call in the child to read the parent mapping only if that tokenId has not been moved yet (through the transferFrom function). If it has been moved then we know that the ownership states have diverged and the ownership of a specific tokenId has been written to the child-contract’s local storage.

A consequence of this method is that if an owner in the parent-token contract decides to transfer their asset elsewhere without explicitly writing to storage in the child-contract through the transferFrom function, they subsequently also transfer away their airdropped token.

To notify marketplaces that an airdrop has occurred and have the NFT show-up in owners’ wallets, we leverage EIP2309 by emitting the ConsecutiveTransfer event over all the tokenIds that the child-contract references in the parent-contract. 

Heavy credit goes to CHANCE’s article on mimetic airdrops which you can read here.

3. ERC721A and Bitmaps

Inspired by ERC721A written by Azuki, we can reduce the cost of writing to storage significantly by representing NFT metadata structs with bitmaps.

We can represent the ownership mapping as (uint256 => uint256) instead of (uint256 => address).This allows us to pack any other relevant metadata into the bitmap mapping, instead of having to initialise another mapping for things like i.e  isBurned (uint256 => bool), or any other metadata that needs to be associated with the tokenId.

The same goes for any additional metadata with regards to the owner, like their balance, the number of tokens minted, burned, etc.  We can pack all that information in one (address => uint256) mapping. 

Representing data through bitmaps allows us to achieve significant gas savings on writes. Through this, we were able to include the feature of running airdrop campaigns on a subset of token-holders instead of the entire collection, in a cost-effective manner.

The naive implementation for this feature would be to pass in a list of uint256 tokenIds that are a subset of parent tokenIds. Then perform a check in the ownerOf function to see if the queried tokenId belongs in that list. However, if we have a subset of hundreds of tokens to airdrop out of a collection of thousands, performing hundreds of uint256 writes to set the whitelist would negate the gas-savings from the previous sections.

Instead, we can represent the list of tokenIds as bit positions on a uint256 data-type, where each bit position corresponds to a tokenId; a 0 means that tokenId should not be airdropped, and 1 means it should. To illustrate an example, if the parent collection has a size of 10,000 tokenIds, and assuming they are enumerated, we can encode selection data on all 10,000 tokens with just 10,000 / 256  = ~39 uint256 data-types. 

To create a selection of tokenIds: [1,5,100], we flip the bits of each corresponding tokenId, and represent that as a uint256.

In this case the bitmask list will be just 1, but if we were to include tokenId 1000. We need to append 3 more uint256 that correspond to tokenIds ranges:

[256 to 511, 512 to 767, 768 to 1023], then flip bit 232 in the 768 to 1023 uint256.

setAidropBitmask

     * This function creates a whitelist of tokenIds to be airdropped to

     */

    function setAirdropBitmask(uint256[] memory _bitmask) public onlyOwner {

        require(isSelectiveAirdrop, "Contract is not selective airdrop mode.");

        for (uint256 i = 0; i < _bitmask.length; i++) {

            _airdropBitmask[i] = _bitmask[i];

        }

    }

This function will set the whitelist. Notice, we can pass any sized bitmap, however this can get costly with extremely large tokenIds. However, most collections are under-enumerated and have less than 10,000 tokenIds.

isValidTokenId

function isValidTokenId(uint256 tokenId) public view returns (bool) {

        require(isSelectiveAirdrop, "Contract is not selective airdrop mode.");

        uint256 depth = tokenId / 256;

        uint256 layerBitmask = _airdropBitmask[depth];

        uint256 bitMask = 1 << (tokenId % 256);

        return ((layerBitmask | bitMask) == layerBitmask);

    }

A check to validate that a tokenId bit has been set to 1.

ownerOf

function ownerOf(uint256 tokenId) public view virtual returns (address) {

        require(_startTokenId() <= tokenId && tokenId < ERC721AStorage.layout()._currentIndex, "ERC721: approved query for nonexistent token");

        // If the address has been written to storage use the stored address

        if (isSelectiveAirdrop) {

            require(isSelectiveAirdrop && isValidTokenId(tokenId), "ERC721: approved query for nonexistent token");

        }

Adding this require will revert all calls that query for a tokenId that is not whitelisted, masking out the tokenId’s ownership from the parent contract.

How Airdrop NFTs with Metacommerce

Metacommerce’s platform provides a seamless airdropping experience allowing creators to drop a collection to their community in a matter of minutes.

Airdrop overview

In the Airdrop dashboard you are able to view the details of your Airdrops - both those that you are drafting and those already sent to owners. You can toggle between All Airdrops and Sent Airdrops.

The search bar helps you to find the airdrop you are looking for.

Create a new Airdrop

When creating a new Airdrop, the first thing you need to do is name it.

Select recipients

Next up, you will select a cohort of owners to whom the Airdrop will be sent. 

It is possible to create these cohorts via Metacommerce’s ORM (Owner Relationship Management platform) based on [...]

Select NFTs to Airdrop

Once you have chosen the cohort, the next thing is to select the NFTs you want to send to them. 

This can be done in 2 ways:

  • Selecting an existing collection of NFT artwork from your Metacommerce Studio
  • Creating new NFT artwork in the Metacommerce Studio

Screen 4

Create your contract

When setting up your contract you will need to set the following attributes:

  • Contract title
  • Contract description 
  • External collection URL
  • Contract ticker
  • Maximum contract supply
  • Network

Optionally, you can also set your NFTs to have a delayed reveal, in which case you need to upload an image as a pre-reveal placeholder.

  • Delayed reveal (yes/no)
  • Pre-reveal image

Verify and send

Prior to sending your Airdrop, you will have a final chance to review the details. You will also get an estimate of the cost of the drop.

The Airdrop will appear in the Sent Airdrops section

And it’s as simple as that! Your airdrop will now appear in the Sent Airdrops section of your dashboard.

Ready to airdrop at a fraction of the cost?

Sign up to the Metacommerce ORM beta to get access to our gas saving airdrop technology.