For Developers
XRPL Injection API
description: Integrate DropFi into your DApp with the window.xrpl API
XRPL Injection API
DropFi injects a powerful window.xrpl
object
into web
pages, enabling seamless DApp integration with the XRP Ledger.
🚀 Quick Start
javascript// Check if DropFi is installed if (typeof window.xrpl !== 'undefined' && window.xrpl.isDropFi) { console.log('DropFi detected!'); // Connect to wallet const address = await window.xrpl.connect(); console.log('Connected:', address); }
📚 API Reference
💻 Integration Guide
🎯 Common Use Cases
E-Commerce Integration
javascript// Request payment const payment = { TransactionType: 'Payment', Destination: 'rMerchantAddress...', Amount: '1000000' // 1 XRP }; const result = await window.xrpl.sendTransaction(payment);
DeFi Application
javascript// Add liquidity to AMM const ammDeposit = { TransactionType: 'AMMDeposit', Asset: {currency: 'XRP'}, Asset2: {currency: 'USD', issuer: 'rIssuer...'}, Amount: '10000000' // 10 XRP }; await window.xrpl.sendTransaction(ammDeposit);
NFT Marketplace
javascript// Create NFT offer const nftOffer = { TransactionType: 'NFTokenCreateOffer', NFTokenID: 'EA85F2...', Amount: '5000000' // 5 XRP }; await window.xrpl.sendTransaction(nftOffer);
🛡️ Security Considerations
- ✅ Always request connection on user action
- ✅ Display clear transaction details
- ✅ Handle rejections gracefully
- ✅ Never store sensitive data
- ✅ Use HTTPS always
💡 Developer Tip: Use our event system to keep your UI in sync with wallet state changes. This creates a seamless experience for users!