Whitelist array limits

Any idea what is the safe (because of gas limits) amount of addresses that can be added with this function, a for loop and an array:


function addToPresale(address[] calldata addresses) external onlyOwner {

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

            require(addresses[i] != address(0), "Cannot add null address");

            _presaleEligible[addresses[i]] = true;

            _totalClaimed[addresses[i]] > 0 ? _totalClaimed[addresses[i]] : 0;

        }

    }

I've seen an array of 500 values can be passed into a function like this. Check out this contract.

And if you want to have, for example, a whitelist of 2000 addresses, then you would add them 500 by 500?

That's what was done in that contract. They used 50+ transactions to mint 25000+ NFTs.

1 Like

But I don't mean minting, I mean setting addresses into an array.

In nature, they are the same, both using sstore opcode to write into the blockchain storage.

1 Like

I think you should look closer to merkleTree !
This allow you to make a whitelist with no limit address and the unique thing store in blockchain is one hash !

Can you elaborate on that?

I suggest you to look a this post

That can save a loooooot of money !
I have tested this and approve :slight_smile:

1 Like