Award Loyalty Points
Grant loyalty points to users based on their actions. Points are automatically calculated based on your program's point allocation rules and can trigger tier upgrades.
Overview
The awardLoyaltyPoints
function adds points to a user's loyalty pass based on a specific action type. The system automatically calculates tier progression and updates the user's status.
import { awardLoyaltyPoints } from '@verxioprotocol/core' const result = await awardLoyaltyPoints(context, { passAddress: publicKey('USER_PASS_ADDRESS'), action: 'purchase', signer: programAuthority, multiplier: 2 // Optional: 2x points for this action })
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
context | VerxioContext | ✅ | The initialized Verxio context object |
passAddress | PublicKey | ✅ | The loyalty pass address to award points to |
action | string | ✅ | Action type (must be defined in program's pointsPerAction) |
signer | Signer | ✅ | Program authority required for awarding points |
multiplier | number | ❌ | Point multiplier (default: 1) |
Return Value
{ points: number, // New total points signature: string, // Transaction signature newTier?: LoyaltyProgramTier // New tier if user was upgraded }
Common Actions
🛒 Purchase
Award points when users make purchases
action: 'purchase'
⭐ Review
Reward users for leaving product reviews
action: 'review'
👥 Referral
Bonus points for referring new customers
action: 'referral'
📱 Social Share
Points for social media engagement
action: 'socialShare'