Member-only story
Hardcore Gas Savings in NFT Minting (Part 2): Merkle Trees vs Signatures
Part one of this series is here. If you are seeing a paywall, click this link.
When tokens are airdropped, or private sales are conducted (sales where only selected addresses are allowed to purchase a token or mint an NFT), there are three popular mechanisms for allowing only a selected list of addresses to buy:
- storing the addresses in a mapping
- signing the addresses with a private key and verifying the signature on-chain
- using Merkle proofs
Here is what the alternatives look like in solidity:
In the first function, we check if the caller is a member of the allowList
mapping. In the second two, the caller sends some proof that msg.sender
is permitted to conduct the transaction.
The experiment is simple. Which of these three methods is the best from a gas cost perspective?