Integrate DropFi Wallet into your DApps with the XRPL Injection API. Seamlessly connect to the XRP Ledger without exposing private keys.
Connect your DApp to DropFi Wallet seamlessly
Automatically initializes the injected window.xrpl provider
Full suite of methods for DApp integration
Built-in React context and hooks for easy development
Works with both browser extension and mobile webview
Add the DropFi XRPL React package to your project
Use npm or yarn to install the official DropFi XRPL React package
Import the XrplProvider and useXrplReact hook
These components provide the React context for accessing DropFi Wallet
Wrap your application with the XrplProvider component
This enables the XRPL injection API throughout your app
Access wallet functionality using the useXrplReact hook
Connect, disconnect, and interact with the XRP Ledger seamlessly
npm install @dropfi/xrpl-react
# or
yarn add @dropfi/xrpl-react
import { XrplProvider, useXrplReact } from '@dropfi/xrpl-react';
export default function App() {
return (
<XrplProvider>
<SomeComponent />
</XrplProvider>
);
}
function SomeComponent() {
const { address, connect, disconnect } = useXrplReact();
return (
<div>
<p>Address: {address ?? 'Not connected'}</p>
<button onClick={connect}>Connect Wallet</button>
<button onClick={disconnect}>Disconnect</button>
</div>
);
}
connect()
Initiates connection to DropFi Wallet
Parameters: None - returns Promise<boolean>
disconnect()
Disconnects from DropFi Wallet
Parameters: None - returns Promise<void>
sendTransaction(transaction)
Sends a transaction to the XRP Ledger
Parameters: transaction: XRPLTransaction - returns Promise<string>
signMessage(message)
Signs a message using the connected wallet
Parameters: message: string - returns Promise<string>
getAddress()
Returns the connected wallet address
Parameters: None - returns string | null
isConnected()
Checks if wallet is connected
Parameters: None - returns boolean
Main hook for accessing wallet state and methods
Hook for accessing account-specific information
Hook for network configuration and status
Hook for transaction history and management
Always handle cases where the wallet extension is not installed or the user rejects the connection.
Implement proper error handling for failed transactions, including network issues and insufficient funds.
Handle cases where users reject transaction signing or connection requests gracefully.
const { connect, sendTransaction } = useXrplReact();
const handleConnect = async () => {
try {
const connected = await connect();
if (connected) {
console.log('Wallet connected successfully');
}
} catch (error) {
console.error('Connection failed:', error);
// Handle connection error
}
};
import React, { useState } from 'react';
import { useXrplReact } from '@dropfi/xrpl-react';
function WalletConnect() {
const { address, connect, disconnect, isConnected } = useXrplReact();
const [isLoading, setIsLoading] = useState(false);
const handleConnect = async () => {
setIsLoading(true);
try {
await connect();
} catch (error) {
console.error('Connection failed:', error);
} finally {
setIsLoading(false);
}
};
const handleDisconnect = async () => {
try {
await disconnect();
} catch (error) {
console.error('Disconnection failed:', error);
}
};
if (isConnected) {
return (
<div>
<p>Connected: {address}</p>
<button onClick={handleDisconnect}>Disconnect</button>
</div>
);
}
return (
<button onClick={handleConnect} disabled={isLoading}>
{isLoading ? 'Connecting...' : 'Connect Wallet'}
</button>
);
}
export default WalletConnect;
import React, { useState } from 'react';
import { useXrplReact } from '@dropfi/xrpl-react';
function SendTransaction() {
const { sendTransaction, isConnected } = useXrplReact();
const [amount, setAmount] = useState('');
const [recipient, setRecipient] = useState('');
const [isLoading, setIsLoading] = useState(false);
const handleSend = async (e: React.FormEvent) => {
e.preventDefault();
if (!isConnected) return;
setIsLoading(true);
try {
const transaction = {
TransactionType: 'Payment',
Account: 'sender-address',
Destination: recipient,
Amount: amount
};
const hash = await sendTransaction(transaction);
console.log('Transaction sent:', hash);
// Handle success
} catch (error) {
console.error('Transaction failed:', error);
// Handle error
} finally {
setIsLoading(false);
}
};
return (
<form onSubmit={handleSend}>
<input
type="text"
placeholder="Recipient Address"
value={recipient}
onChange={(e) => setRecipient(e.target.value)}
/>
<input
type="text"
placeholder="Amount"
value={amount}
onChange={(e) => setAmount(e.target.value)}
/>
<button type="submit" disabled={!isConnected || isLoading}>
{isLoading ? 'Sending...' : 'Send Transaction'}
</button>
</form>
);
}
export default SendTransaction;
Ensure the DropFi extension is installed and the page is refreshed after installation.
Check if the user has the DropFi extension open and is not blocking connection requests.
Verify you're using the latest version of the @dropfi/xrpl-react package.
Now that you understand the XRPL Injection API, start building your DApp integration with DropFi Wallet.