NFT whitelist: How to make a variable mint allowance per address

Viewed 83

I have to develop an NFT minting contract with a whitelist system where we can set a variable amount of mint allowance per address.

It would be easy to achieve by setting manually in the contract with something like:

mapping(address => uint) allowancePerAddress

But as it's on Ethereum this solution would not be very cost efficient as we would need to store a couple hundreds of entries manually.

Is there another way, through signature for example to achieve this so it would be cost efficient for both the project and the minter ?

1 Answers

Signatures serve for checking the integrity of a message and also validate the emitter of the message, so Im not sure how would you accomplish using signatures, mainly because you'll need to set a value for each address, and keep track of them in the contract.

What you can do is create a constant that would be the default allowance, and when someone mints their first token you can update their allowance value during that transaction.

Yet, if what you want is to set up a custom value for each address, and you have a high amount of them, you can either do it on deploy, on the constructor or create a function that receives an array of Struct {address, allowance}, and set every address on a loop.

Related