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?

1 Answer 1

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.

3
  • you mean push to array by 'for' statement?
    – rrrrssss
    Commented Jan 25 at 13:16
  • merkle tree is a good thing, but i have to extract winners from applicants in contract. As far as I know, i can't extract values ​​from a Merkle tree. so i have to use naive array
    – rrrrssss
    Commented Jan 25 at 13:38
  • well it seems this is the best for now. thanks
    – rrrrssss
    Commented Jan 25 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.