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:

  1. Browser Mode: Traditional QR code signing flow for desktop/mobile web users

  2. xApp Mode: Native in-app experience with auto-connect and auto-sign when opened within Xaman wallet

Components

  1. Backend Routes (server/routes.ts)

    • Xaman payload creation endpoints

    • Payload status checking

    • Transaction hash retrieval

  2. Frontend Modal (client/src/components/XamanSigningModal.tsx)

    • QR code display (browser mode)

    • Polling mechanism

    • Transaction status updates

  3. 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

Feature
Browser Mode
xApp Mode

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

  1. Switch to testnet in app

  2. Get test XRP from faucet

  3. Create test transactions

  4. Verify on testnet explorer

Mainnet Testing

⚠️ Use small amounts for initial testing

  1. Switch to mainnet

  2. Connect real wallet

  3. Test with minimal amounts

  4. 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