Approve Transfer
Grant approval for loyalty pass transfers between wallets. This function manages transfer permissions and ensures proper ownership transitions while maintaining program integrity.
Overview
The approveTransfer
function enables program administrators to approve or manage transfers of loyalty passes between users, providing control over pass ownership changes.
import { approveTransfer } from '@verxioprotocol/core' const result = await approveTransfer(context, { passAddress: publicKey('LOYALTY_PASS_ADDRESS'), newOwner: publicKey('NEW_OWNER_WALLET'), approver: programAuthority, signer: updateAuthority })
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
context | VerxioContext | ✅ | The initialized Verxio context object |
passAddress | PublicKey | ✅ | The loyalty pass address to approve for transfer |
newOwner | PublicKey | ✅ | The wallet address of the intended new owner |
approver | PublicKey | ✅ | Public key of the transfer approver |
signer | Signer | ✅ | Program authority required for approving transfers |
transferData | TransferMetadata | ❌ | Additional transfer information (optional) |
Return Value
The function returns a Promise that resolves to an object containing:
{ signature: string, // Transaction signature transferId: string, // Unique transfer identifier approvedAt: number, // Approval timestamp transferStatus: 'approved' // Transfer status }
Property | Type | Description |
---|---|---|
signature | string | The transaction signature confirming the approval |
transferId | string | Unique identifier for tracking this transfer |
approvedAt | number | Unix timestamp when the transfer was approved |
transferStatus | string | Current status of the transfer approval |
Usage Examples
Basic Transfer Approval
// Approve a transfer request const transferApproval = await approveTransfer(context, { passAddress: publicKey('LOYALTY_PASS_ADDRESS'), newOwner: publicKey('NEW_OWNER_WALLET'), approver: programAuthority.publicKey, signer: programAuthority }) console.log('Transfer approved!') console.log('Transfer ID:', transferApproval.transferId) console.log('Transaction:', transferApproval.signature)
Transfer with Metadata
// Approve transfer with additional metadata const transferWithData = await approveTransfer(context, { passAddress: publicKey('LOYALTY_PASS_ADDRESS'), newOwner: publicKey('NEW_OWNER_WALLET'), approver: programAuthority.publicKey, signer: programAuthority, transferData: { reason: 'account_migration', notes: 'User requested account transfer', adminApprover: 'admin@company.com', transferDate: Date.now() } }) console.log('Transfer with metadata approved:', transferWithData)
Batch Transfer Approvals
// Approve multiple transfers const transferRequests = [ { passAddress: 'PASS_1', newOwner: 'OWNER_1' }, { passAddress: 'PASS_2', newOwner: 'OWNER_2' }, { passAddress: 'PASS_3', newOwner: 'OWNER_3' } ] const approvalResults = [] for (const request of transferRequests) { try { const approval = await approveTransfer(context, { passAddress: publicKey(request.passAddress), newOwner: publicKey(request.newOwner), approver: programAuthority.publicKey, signer: programAuthority }) approvalResults.push({ passAddress: request.passAddress, transferId: approval.transferId, status: 'approved', signature: approval.signature }) console.log(`Approved transfer for pass ${request.passAddress}`) } catch (error) { console.error(`Failed to approve transfer for ${request.passAddress}:`, error) approvalResults.push({ passAddress: request.passAddress, status: 'failed', error: error.message }) } } console.log('Batch approval results:', approvalResults)
Transfer Workflow
1️⃣ Transfer Request
User initiates a transfer request through your application or directly
2️⃣ Admin Review
Program administrators review the transfer request for validity
3️⃣ Transfer Approval
Use this function to approve the transfer and enable ownership change
4️⃣ Ownership Transfer
The NFT pass ownership is transferred to the new wallet
Security Considerations
🔒 Authority Control
Only program authorities can approve transfers. Ensure proper access control in your application.
⚠️ Verification Required
Always verify the legitimacy of transfer requests before approving them.
📋 Audit Trail
Maintain logs of all transfer approvals for compliance and auditing purposes.
Common Use Cases
🔄 Account Migration
Users switching to new wallets or consolidating accounts
🎁 Gift Transfers
Transferring loyalty passes as gifts between family/friends
🏢 Corporate Transfers
Business account changes or employee transitions
🔧 Recovery Assistance
Helping users recover access to their loyalty programs
Best Practices
✅ Recommended Practices
- Implement a formal transfer request process
- Verify both source and destination wallets
- Maintain detailed transfer logs
- Notify users of transfer completion
- Set up automated approval workflows where appropriate
❌ Things to Avoid
- Approving transfers without proper verification
- Allowing unauthorized personnel to approve transfers
- Not maintaining audit trails
- Ignoring suspicious transfer patterns
- Lack of user communication during transfers