Xaman (XUMM) Integration Technical Details
This document covers the technical implementation of Xaman integration in Shield Yield Vaults, including the native xApp experience.
Architecture Overview
Shield Finance supports two modes of Xaman integration:
Browser Mode: Traditional QR code signing flow for desktop/mobile web users
xApp Mode: Native in-app experience with auto-connect and auto-sign when opened within Xaman wallet
Components
Backend Routes (
server/routes.ts)Xaman payload creation endpoints
Payload status checking
Transaction hash retrieval
Frontend Modal (
client/src/components/XamanSigningModal.tsx)QR code display (browser mode)
Polling mechanism
Transaction status updates
Wallet Context (
client/src/lib/walletContext.tsx)Wallet connection state
Balance management
Network configuration
xApp context detection
Auto-connect for xApp users
Direct sign request opening via
xumm.xapp.openSignRequest()
xApp Integration (Native Xaman Experience)
When Shield Finance is opened as an xApp within Xaman wallet, users get a seamless experience:
Features
Wallet Connection
QR scan required
Auto-connect (instant)
Deposit Signing
QR modal
Auto-sign modal (native)
Claim/Withdraw Signing
QR modal
QR modal (fallback)
User Account
Manual entry
SDK-provided
Session Persistence
LocalStorage
JWT-based
Note: Currently, deposit transactions use native xApp signing via
openSignRequest(). Claim and withdrawal flows still use the QR modal pending backend endpoint updates.
xApp Detection
The SDK automatically detects xApp context through multiple methods:
Auto-Sign (Direct Sign Request)
When in xApp context, signing requests open natively without QR codes:
xApp Flow Diagram
Future Enhancement: Claim and withdraw endpoints can be updated to return payload UUIDs, enabling native xApp signing for all transaction types.
Backend Implementation
Dependencies
Environment Variables
Payload Creation Endpoints
Create SignIn Payload
Create Deposit Payload
Check Payload Status
Network Configuration
The backend configures vault addresses and issuers based on network:
Frontend Implementation
XamanSigningModal Component
Props:
Key Features:
Displays Xaman's native QR code PNG
Polls for transaction status every 2 seconds
Timeout after 5 minutes (150 attempts)
Shows loading states and success/error messages
Polling Logic:
Usage Example
Transaction Flow Diagram
Error Handling
Backend Errors
Frontend Errors
Testing
Demo Mode Testing
Set environment variables to empty to trigger demo mode:
Testnet Testing
Switch to testnet in app
Get test XRP from faucet
Create test transactions
Verify on testnet explorer
Mainnet Testing
⚠️ Use small amounts for initial testing
Switch to mainnet
Connect real wallet
Test with minimal amounts
Verify transactions on mainnet explorer
Security Considerations
API Keys: Never expose in frontend code
Transaction Validation: Backend validates all transaction parameters
Network Isolation: Testnet and mainnet are completely separated
User Approval: All transactions require explicit user approval in Xaman
Hash Verification: Every transaction hash is verifiable on-chain
Resources
Last updated