How to determine which tickets are owned by each address?
chrishol opened this issue · comments
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.
MultiRaffle/src/MultiRaffle.sol
Line 195 in a468d00
Yeah I'm looking for that to
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;
}