For Developers
API Overview
description: Complete reference for the window.xrpl API object
API Overview
🌐 The window.xrpl Object
DropFi injects a global window.xrpl
object into every webpage, providing a standardized interface for XRPL interactions.
javascriptwindow.xrpl = { // Wallet Detection isDropFi: true, // Current State selectedAddress: string | null, selectedNetwork: string | null, connectedAccounts: string[], network: string | null, endpoint: string | null, // Core Methods connect(data?: object): Promise<string>, disconnect(address?: string): Promise<void>, signMessage(message: string): Promise<string>, sendTransaction(tx: object): Promise<object>, switchNetwork(network: string): Promise<object>, changeAccount(account: string): Promise<string>, initialize(): Promise<object>, // Utilities isConnected(): boolean, on(event: string, callback: function): void, off(event: string, callback: function): void }
🔍 Property Reference
Detection Properties
isDropFi
- Type:
boolean
- Value: Always
true
- Usage: Detect DropFi wallet
javascriptif (window.xrpl && window.xrpl.isDropFi) { console.log('DropFi wallet detected!'); }
State Properties
selectedAddress
- Type:
string | null
- Description: Currently connected wallet address
- Example:
"rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH"
selectedNetwork
- Type:
string | null
- Description: Current network name
- Values:
"mainnet"
,"testnet"
,"devnet"
connectedAccounts
- Type:
string[]
- Description: All accounts connected to this DApp
- Example:
["rAddr1...", "rAddr2..."]
network
- Type:
string | null
- Description: Active network identifier
- Example:
"mainnet"
endpoint
- Type:
string | null
- Description: Current XRPL node endpoint
- Example:
"wss://xrplcluster.com"
🔧 Method Categories
Connection Management
connect()
- Request wallet connectiondisconnect()
- Disconnect walletchangeAccount()
- Switch active accountisConnected()
- Check connection status
Transaction Operations
sendTransaction()
- Sign and submit transactionssignMessage()
- Sign arbitrary messages
Network Operations
switchNetwork()
- Change XRPL networkinitialize()
- Get current wallet state
Event Management
on()
- Subscribe to eventsoff()
- Unsubscribe from events
🎯 Common Patterns
Initial Setup
javascript// Wait for page load window.addEventListener('load', async () => { // Check for DropFi if (!window.xrpl || !window.xrpl.isDropFi) { showInstallPrompt(); return; } // Initialize state const state = await window.xrpl.initialize(); if (state.selectedAddress) { updateUIAsConnected(state.selectedAddress); } });
Connection Flow
javascriptasync function connectWallet() { try { // Request connection const address = await window.xrpl.connect(); // Update UI showConnectedState(address); // Listen for changes window.xrpl.on('xrpl_disconnect', handleDisconnect); window.xrpl.on('xrpl_selectedAddress', handleAccountChange); } catch (error) { if (error.code === 4001) { showUserRejectedMessage(); } else { showErrorMessage(error); } } }
Transaction Pattern
javascriptasync function sendPayment(destination, amount) { // Build transaction const tx = { TransactionType: 'Payment', Account: window.xrpl.selectedAddress, Destination: destination, Amount: amount }; try { // Request signature const result = await window.xrpl.sendTransaction(tx); // Handle success showSuccessMessage(result.hash); } catch (error) { // Handle rejection or error handleTransactionError(error); } }
🔐 Security Model
Permission System
- Connection requires user approval
- Each transaction needs confirmation
- Users control connected sites
- Permissions persist across sessions
Data Access
- ✅ Public address
- ✅ Network information
- ✅ Connected accounts list
- ❌ Private keys (never exposed)
- ❌ Recovery phrases (never accessible)
Origin Isolation
- Each website has isolated permissions
- No cross-origin data sharing
- Users can revoke access anytime
⚡ Performance Tip: Cache the connection state locally to avoid unnecessary
initialize()
calls. Use events to stay synchronized with wallet state changes.