Get User Vouchers
Retrieve all vouchers for a specific user with filtering and sorting options.
import { getUserVouchers } from '@verxioprotocol/core' import { publicKey } from '@metaplex-foundation/umi' const vouchers = await getUserVouchers(context, { userAddress: publicKey('USER_ADDRESS'), filters: { status: 'active', // 'active' | 'expired' | 'fully_used' type: 'percentage_off', // Optional: filter by voucher type minValue: 10, // Optional: minimum value }, sortBy: 'expiryDate', // 'expiryDate' | 'value' | 'createdAt' sortOrder: 'asc', // 'asc' | 'desc' limit: 10, // Optional: limit results })
Return Value
{ vouchers: Array<{ address: string, type: string, value: number, currentUses: number, maxUses: number, expiryDate: number, status: string, description: string, conditions: string[], collection: string }>, total: number, expiringSoon: Array<string>, // Voucher addresses expiring in 7 days redeemable: Array<string> // Voucher addresses that can be redeemed }