Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to determine which tickets are owned by each address? #5

Open
chrishol opened this issue Oct 17, 2021 · 2 comments
Open

How to determine which tickets are owned by each address? #5

chrishol opened this issue Oct 17, 2021 · 2 comments

Comments

@chrishol
Copy link

Thanks for sharing this @Anish-Agnihotri - really great ideas and helpful examples.

My question:
The design of the claimRaffle function seems to require the caller to know where their entry lies in the raffleEntries array. Is the idea that the results could be indexed once and then provided to customers via a frontend UI?

Ideally you'd have some way of quickly finding the indices by address, but storing that might get expensive quickly.

function claimRaffle(uint256[] calldata tickets) external {

@thomasdurand98
Copy link

Yeah I'm looking for that to

@pauliax
Copy link

pauliax commented Oct 30, 2021

Probably you need to find them off-chain but that may be a bit daunting. hardhat test example:

  async function getWinningIndices(address) {
    const indices = [];
    for (let i = 0; i < availableSupply; i++) {
      const entryAddress = await raffleContract.raffleEntries(i);
      if (entryAddress === address) {
        indices.push(i);
      }
    }
    return indices;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants