Verify: List Contains
This pattern is useful when you maintain a list of eligible principals (e.g., allowlist, winners, early users).
When to Use
- The quest is completed by a specific set of users (e.g., "Is the user in the list of beta testers?").
Motoko Example
let eligiblePrincipals : [Principal] = [
Principal.fromText("aaaaa-aa"),
Principal.fromText("bbbbb-bb"),
// ...
];
public query func verifyAllowlist(principal : Principal) : async Bool {
return Array.find<Principal>(eligiblePrincipals, func x = x == principal) != null;
}
Integration
- ICQuests will call this method and award XP if it returns
true
. - The method must be public and read-only (
query
).
Tip: Keep your list up to date and avoid making it too large for performance reasons.