0

i am trying to make lottery contract, and expected applicants will be about 2~30,000.

i want to set those applicants by this code.

function setApplicants(address[] memory _applicants) public onlyRole(DEFAULT_ADMIN_ROLE) {
        applicants = _applicants;
    }

but it seems i can't store thousands of addresses at once, even the limit of array size is 2^256-1 in solidity.

so i am wondering if there is a way to set applicants about 30,000. it doesn't have to be set at once. but i wish the used gas be minimum.

any ideas?

rrrrssss
  • 43
  • 3

1 Answers1

0

You upload applicants in batches.

Each batch has a range like 0....1000, 1001...2000.

Also use a Merkle tree instead of a naive array.

Mikko Ohtamaa
  • 22,269
  • 6
  • 62
  • 127