Whitelist minting

I'm trying to write a 2 tier whitelist minting function, where one tier can only mint 2 tokens, where the other allows me to mint 3

1 Like

Hey @khhabib
can you provide more info? Your code etc

I have a list of addresses that I want to have as my whitelist minters, I want half of these addresses to be able to mint 2 nft, and the other half is able to mint 3 nfts. how do i do that in code where the whitelist functon is using merkleTree hashing

1 Like

How about keeping a mint balance for each address?
Like so: Mapping(address=>uint)

If you want different balances for different tiers you can do a mapping inside the first mapping:
Mapping(address=>mapping(uint=>uint))

have you got solution to this???

Hello @khhabib,

I would say you should make a single mapping :

mapping(address => uint256) _addressesMintLimits;

Then you could do a setter method :

function setMintingWhitelistToTwo(address[] addresses, uint256 _mintLimit) external onlyOwner {
  for (uint256 i = 0; i < addresses.length; i++) {
    _addressesMintLimits[addresses[i]] = _mintLimit;
  }
}

And check this mapping during the mint :

function yourMintFunction() ... {
  requires(balanceOf(msg.sender) < _addressesMintLimits[msg.sender], "You cannot mint more NFTs");
  ...
}

After deploying your contract you would call this method twice :

YourContractInstance.setMintingWhitelistToTwo([0x123, 0x456], 2) // allowing 2 mints for those wallets
YourContractInstance.setMintingWhitelistToTwo([0x789, 0x012], 3) // allowing 3 mints for those wallets