Events Rewards

Reward Lifecycle

  1. Event Creation

    • Rewards are pre-configured using the EventRewardType schema

  2. User Participation

    • Users participate in the event

    • Become eligible for rewards based on criteria (e.g., leaderboard rank)

  3. Reward Allocation

    • Eligible users receive reward allocations

    • Allocations can be fetched via useQuestEventRewardAllocations hook

  4. Reward Claim

    • Users claim rewards after event conclusion

    • Claims processed using claimRewardAllocation mutation

Event Reward Structure

Type Definition

type EventRewardType = {
  eventRewardId: string;                // Unique identifier for the event reward
  name: string;                         // Display name of the reward
  resolutionType: QuestEventRewardResolutionType; // Type of resolution (e.g., based on rank or other criteria)
  resolutionValueRange: ResolutionValueType;      // Range of leaderboard ranks eligible for the reward
  rewardId: string;                     // Unique identifier for the reward entity
  reward: EventGiveResourcesReward | EventGiveAssetsReward; // Reward details (e.g., resources or assets)
  rewardHandlerArgs: EventGiveResourcesRewardHandler | EventGiveAssetsRewardHandler; // Backend handling configuration
  eventId: string;                      // ID of the associated event
  createdAt: Date;                      // Timestamp when the reward was created
  updatedAt: Date;                      // Timestamp when the reward was last updated
};

Key Fields Explained

  • eventRewardId: Unique identifier for this specific reward in the event

  • resolutionType: Specifies the reward's resolution method

  • resolutionValueRange: Defines eligible leaderboard ranks

  • reward: Contains actual reward data (resources or assets)

    • EventGiveResourcesReward: Virtual currencies, tokens, or points

    • EventGiveAssetsReward: In-game items, badges, or other assets

  • rewardHandlerArgs: Configuration for reward distribution logic

  • eventId: Associated event identifier

Example Configuration

Fetching Reward Allocations

Use the useQuestEventRewardAllocations hook to fetch user-specific reward allocations.

Hook Implementation

Allocation Type Definition

Example Allocation Data

Claiming Rewards

Use the useMutateQuestEventReward hook to handle reward claims after event conclusion.

Implementation Example

Best Practices

  1. Type Safety

    • Use TypeScript types for reward and allocation handling

    • Validate reward data structure before display

  2. Error Handling

    • Implement proper error handling for claim operations

    • Show appropriate loading and error states

  3. User Experience

    • Display clear claim status to users

    • Disable claim buttons for already claimed rewards

    • Show loading state during claim operations

Last updated