Skip to content

Repository files navigation

XRPL Connect

A framework-agnostic wallet connection toolkit for the XRP Ledger

License: MIT npm version TypeScript

✨ Features

  • Framework Agnostic - Works with Vanilla JS, React, Vue, and any other framework
  • Multiple Wallets - Support for Xaman, Crossmark, GemWallet, WalletConnect, Ledger, Xyra, Otsu, and MetaMask Snap
  • Modular Architecture - Install only what you need
  • Type Safe - Full TypeScript support with comprehensive type definitions
  • Event Driven - Reactive architecture for connection state changes
  • Persistent Sessions - Auto-reconnect with localStorage support
  • Developer Friendly - Simple API, extensive documentation, great DX

πŸ“¦ What's Included

The xrpl-connect package includes everything you need:

  • Core: Wallet management, event system, and state persistence
  • UI: Beautiful pre-built web component with QR codes and wallet selection
  • Adapters: All eight XRPL wallet adapters (Xaman, Crossmark, GemWallet, WalletConnect, Ledger, Xyra, Otsu, and MetaMask Snap)

Documentation

Please read the documentation here DOCS as it is way more detailed than the README.

πŸš€ Quick Start

Installation

npm install xrpl-connect@rc xrpl@^4

That's it! Everything you need in one package.

Basic Usage

The easiest way to use XRPL Connect is with the plug-and-play web component:

HTML:

<!-- Add the web component to your HTML -->
<button id="connect-btn">Connect Wallet</button>

<xrpl-wallet-connector id="wallet-connector" background-color="#1a202c" primary-wallet="xaman">
</xrpl-wallet-connector>

JavaScript:

Create a Xaman application at apps.xumm.dev and replace the placeholder below with its API key.

import { WalletManager, XamanAdapter, CrossmarkAdapter } from 'xrpl-connect';

// Initialize wallet manager
const walletManager = new WalletManager({
  adapters: [new XamanAdapter({ apiKey: 'YOUR_XAMAN_API_KEY' }), new CrossmarkAdapter()],
  network: 'testnet',
  // When true, the WalletManager attempts to restore the previous session
  // from localStorage on page load (the user is not prompted again). Set to
  // false if you want users to explicitly reconnect every time.
  autoConnect: true,
});

// Connect the UI component to the wallet manager
const connector = document.getElementById('wallet-connector');
connector.setWalletManager(walletManager);

// Open the modal when button is clicked
document.getElementById('connect-btn').addEventListener('click', () => {
  connector.open();
});

// Listen to connection events
walletManager.on('connect', (account) => {
  console.log('Connected:', account.address);
});

// Always handle disconnects so your UI can reset
walletManager.on('disconnect', () => {
  console.log('Disconnected');
});

// Sign transactions after connection. Always wrap in try/catch β€” the promise
// rejects when the user cancels the request in their wallet (SIGN_REJECTED).
try {
  const signed = await walletManager.sign({
    TransactionType: 'Payment',
    Account: walletManager.account.address,
    Destination: 'rN7n7otQDd6FczFgLdlqtyMVrn3HMfXoQT',
    Amount: '1000000',
  });
} catch (error) {
  if (error.code === 'SIGN_REJECTED') {
    console.log('User rejected the transaction');
  } else {
    console.error('Sign failed:', error);
  }
}

That's it! The web component provides a beautiful, pre-built UI for wallet selection, QR codes, and connection states.

Heads up on autoConnect: with autoConnect: true, the WalletManager silently restores the previous session from localStorage when your page loads and emits a connect event before any user interaction. Register your connect and disconnect listeners immediately after constructing the manager so you don't miss that initial event. Handle operation failures through their rejected promises or the web component's error event.

Direct wallet SDK access

The meta-package also exposes the complete upstream wallet APIs under namespaces, so applications do not need to add the transitive SDKs as direct dependencies:

import { CrossmarkSDK, GemWalletAPI, XamanOAuth2, XamanSDK } from 'xrpl-connect';

const xaman = new XamanSDK.Xumm('YOUR_API_KEY');
const oauth = new XamanOAuth2.XummPkce('YOUR_API_KEY');
const installed = CrossmarkSDK.default.sync.isInstalled();
const address = await GemWalletAPI.getAddress();

πŸ“š Documentation

πŸ—οΈ Architecture

XRPL Connect is built with a modular, adapter-based architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Your Application                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      @xrpl-connect/core                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚     WalletManager               β”‚   β”‚
β”‚  β”‚  - Event system                 β”‚   β”‚
β”‚  β”‚  - State management             β”‚   β”‚
β”‚  β”‚  - Storage layer                β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                   β”‚         β”‚         β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”‚         β”‚
β”‚ Xaman Adapter  β”‚  β”‚  Crossmark  β”‚  β”‚   ...   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚         β”‚
                                     β”‚         β”‚
                              β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”  β”‚
                              β”‚ GemWallet   β”‚  β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
                                               β”‚
                                        β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                                        β”‚WalletConnectβ”‚
                                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Development

# Install dependencies
pnpm exec vp install

# Build all packages
pnpm exec vp run build

# Run tests
pnpm exec vp run test

# Lint
pnpm exec vp lint

# Format
pnpm exec vp fmt

# Development mode (watch)
pnpm exec vp run dev

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide for development setup, branch/PR conventions, and the release process. To author a new wallet adapter specifically, see the Adapter Integration Guide.

A summary of notable changes in each release lives in CHANGELOG.md.

πŸ“„ License

MIT License - see the LICENSE file for details

πŸ™ Acknowledgments

Inspired by:

Built for the XRPL community with ❀️

About

A framework-agnostic wallet connection toolkit for the XRP Ledger

Resources

Contributing

Stars

24 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages