xrpl-rust 
[!WARNING] This repository is under active development.
A Rust library to interact with the XRPL. Based off of the xrpl-py library.
A pure Rust implementation for interacting with the XRP Ledger. The xrpl-rust crate simplifies the hardest parts of XRP Ledger interaction including serialization and transaction signing while providing idiomatic Rust functionality for XRP Ledger transactions and core server API (rippled) objects.
Interactions with this crate occur using data structures from this crate or core alloc types with the exception of serde for JSON handling and indexmap for dictionaries. The goal is to ensure this library can be used on devices without the ability to use a std environment.
Table of Contents
- Installation
- Documentation
- Quickstart
- Feature Flags
- no_std Support
- Command Line Interface
- Examples
- Contributing
- License
🛠Installation 
To install, add the following to your project's Cargo.toml
:
[]
= "1.0.0"
Documentation 
Documentation is available here.
Quickstart
Basic Wallet Operations
use Wallet;
// Generate a new wallet
let wallet = create?;
println!;
// Create wallet from seed
let wallet = from_seed?;
Making Requests
use XRPLSyncClient;
use AccountInfo;
let client = new?;
let req = new;
let response = client.request?;
Feature Flags
Default Features
std
- Standard library supportcore
- Core XRPL functionalitymodels
- XRPL data modelswallet
- Wallet operationsutils
- Utility functionswebsocket
- WebSocket clientjson-rpc
- JSON-RPC clienthelpers
- Helper functions (requires runtime)tokio-rt
- Tokio async runtime
Optional Features
cli
- Command line interfaceembassy-rt
- Embassy async runtime (for no_std)serde
- Serialization support
Runtime Requirements
When using helpers
, you must specify a runtime:
tokio-rt
- For std environmentsembassy-rt
- For no_std environments
#![no_std]
This library aims to be #![no_std]
compliant.
no_std
Usage
[]
= "*"
= false
= ["core", "models", "wallet", "utils", "websocket", "json-rpc", "helpers", "embassy-rt"]
Command Line Interface
The XRPL Rust library provides a powerful CLI tool for interacting with the XRP Ledger directly from your terminal. This makes it easy to perform common XRPL operations without writing code.
Installation
To install the CLI tool, you can add the cli
feature to your dependencies:
[]
= "0.5.0"
= ["cli"]
Or install it directly using Cargo:
Basic Usage
After installation, you can use the CLI with the xrpl
command:
For help with available commands:
For help with a specific command:
Available Commands
The CLI offers commands in several categories:
Wallet Commands
Command | Subcommand | Description |
---|---|---|
wallet |
generate |
Generate a new XRPL wallet |
wallet |
from-seed |
Create a wallet from an existing seed |
wallet |
faucet |
Generate a wallet funded by the testnet faucet |
wallet |
validate |
Validate an XRPL address (classic or X-address) |
Account Commands
Command | Subcommand | Description |
---|---|---|
account |
info |
Get basic account information |
account |
tx |
Get account transactions |
account |
objects |
Get account objects (trust lines, offers, etc.) |
account |
channels |
Get account payment channels |
account |
currencies |
Get currencies an account can send/receive |
account |
lines |
Get account trust lines |
Transaction Commands
Command | Subcommand | Description |
---|---|---|
transaction |
sign |
Sign a transaction using your seed |
transaction |
submit |
Submit a signed transaction to the network |
transaction |
get |
Get transaction details by hash |
transaction |
nft-mint |
Create and sign an NFT mint transaction |
transaction |
nft-burn |
Create and sign an NFT burn transaction |
transaction |
payment |
Create and sign a payment transaction |
Server and Ledger Commands
Command | Subcommand | Description |
---|---|---|
server |
fee |
Get the current network fee |
server |
info |
Get information about a rippled server |
ledger |
data |
Get data about a specific ledger |
server |
subscribe |
Subscribe to ledger events via WebSocket |
2. Advanced Query Commands
Command | Subcommand | Description |
---|---|---|
ledger |
entry |
Get a specific ledger entry by index |
transaction |
get |
Get transaction details by hash |
ledger entry
Get a specific ledger entry by its index.
3. Account NFTs Command
account nfts
Get NFTs owned by an account.
Command Details
Wallet Operations
wallet generate
Generate a new XRPL wallet (keypair).
# Generate a new wallet
# Generate and save wallet (functionality not yet implemented)
wallet from-seed
Derive a wallet from an existing seed.
Parameters:
--seed
: The seed to use (required)--sequence
: The key sequence number (default: 0)
wallet faucet
Generate a new wallet and fund it using the testnet faucet.
Parameters:
--url
: The testnet URL (default: https://s.altnet.rippletest.net:51234)
wallet validate
Validate an XRPL address (works with both classic and X-addresses).
Parameters:
--address
: The address to validate (required)
wallet generate --mnemonic
Generate a new wallet with a BIP39 mnemonic phrase.
# Generate with 12 words (default)
# Generate with 24 words
Account Information
account info
Get basic account information.
Parameters:
--address
: The account address (required)--url
: The XRPL node URL (default: https://xrplcluster.com/)
account tx
Get account transactions.
Parameters:
--address
: The account address (required)--limit
: Maximum number of transactions to return (default: 10)--url
: The XRPL node URL (default: https://xrplcluster.com/)
account objects
Get account objects (trust lines, offers, etc.)
Parameters:
--address
: The account address (required)--type-filter
: Type of objects to return (e.g., "offer", "state")--limit
: Maximum number of objects to return (default: 10)--url
: The XRPL node URL (default: https://xrplcluster.com/)
account channels
Get information about an account's payment channels.
Parameters:
--address
: The account address (required)--destination-account
: Filter channels by destination account--limit
: Maximum number of channels to return (default: 10)--url
: The XRPL node URL (default: https://xrplcluster.com/)
account currencies
Get a list of currencies that an account can send or receive.
Parameters:
--address
: The account address (required)--url
: The XRPL node URL (default: https://xrplcluster.com/)
account lines
Get information about an account's trust lines.
Parameters:
--address
: The account address (required)--peer
: Filter trust lines by peer account--limit
: Maximum number of trust lines to return (default: 10)--url
: The XRPL node URL (default: https://xrplcluster.com/)
account set-flag
Set an account flag.
Parameters:
--seed
,-s
(required): The seed to use for signing--flag
,-f
(required): The flag to set (e.g., asfRequireAuth, asfDisableMaster, etc.)--url
,-u
(optional, default: https://xrplcluster.com/): The XRPL node URL
Example Output:
Signed transaction blob: ...
To submit, use: xrpl transaction submit --tx-blob ... --url ...
account clear-flag
Clear an account flag.
Parameters:
--seed
,-s
(required): The seed to use for signing--flag
,-f
(required): The flag to clear (e.g., asfRequireAuth, asfDisableMaster, etc.)--url
,-u
(optional, default: https://xrplcluster.com/): The XRPL node URL
Example Output:
Signed transaction blob: ...
To submit, use: xrpl transaction submit --tx-blob ... --url ...
Library Usage
Basic Wallet Operations
use Wallet;
// Generate a new wallet
let wallet = create?;
println!;
println!;
// Create wallet from seed
let seed = "sEdV19BLfeQeKdEXyYA4NhjPJe6XBfG";
let wallet = from_seed?;
println!;
Making API Requests
use XRPLSyncClient;
use ;
use ;
let client = new?;
// Get account information
let account_info_req = new;
let response = client.request?;
// Get account trust lines
let account_lines_req = new;
let lines_response = client.request?;
// Get order book offers
let taker_gets = xrp;
let taker_pays = issued;
let book_offers_req = new;
let offers_response = client.request?;
Working with Transactions (New Builder Pattern)
use ;
use ;
use Wallet;
use XRPLSyncClient;
// Create a simple XRP payment using the new builder pattern
let payment = Payment
.with_fee
.with_sequence
.with_destination_tag
.with_memo;
// Create a cross-currency payment with path finding
let cross_currency_payment = Payment
.with_send_max // Max 110 XRP
.with_flag
.with_fee
.with_sequence;
// Set up an account with deposit authorization
let account_setup = AccountSet
.with_set_flag
.with_transfer_rate // 2% transfer fee
.with_fee
.with_sequence;
// Delete an account
let account_deletion = AccountDelete
.with_destination_tag
.with_fee // 2 XRP minimum fee for account deletion
.with_sequence
.with_memo;
// Sign and submit transactions
let wallet = from_seed?;
let client = new?;
let signed_payment = wallet.sign?;
let submit_response = client.submit?;
Working with AMM Transactions
use ;
use ;
use XRP;
// Create an AMM pool
let amm_create = AMMCreate
.with_fee
.with_sequence
.with_memo;
// Bid on AMM auction slot
let amm_bid = AMMBid
.with_bid_min
.with_bid_max
.with_fee
.with_sequence;
// Delete empty AMM
let amm_delete = AMMDelete
.with_fee
.with_sequence;
Address Conversion
use ;
// Convert classic address to X-address
let classic_address = "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh";
let xaddress = classic_address_to_xaddress?;
println!;
// Convert X-address back to classic address
let = xaddress_to_classic_address?;
println!;
// Validate addresses
let is_valid = is_valid_classic_address;
println!;
Working with NFTs
use ;
use Amount;
// Mint an NFT
let nft_mint = NFTokenMint
.with_fee
.with_sequence
.with_memo;
// Create an NFT sell offer
let nft_sell_offer = NFTokenCreateOffer
.with_amount // 1 XRP
.with_fee
.with_sequence;
Binary Codec Usage
use ;
use json;
// Encode transaction to binary
let tx_json = json!;
let encoded = encode?; // true for signing
println!;
// Decode binary back to JSON
let decoded = decode?;
println!;
Utility Functions
use ;
// XRP conversion
let xrp_amount = "1.5";
let drops = xrp_to_drops?;
println!;
let xrp_back = drops_to_xrp?;
println!;
// Time conversion
let posix_time = 1660187459;
let ripple_time = posix_to_ripple_time?;
println!;
let posix_back = ripple_time_to_posix?;
println!;
Error Handling
use XRPLModelException;
use XRPLCoreException;
use XRPLWalletException;
// Proper error handling example
match from_seed
// Transaction validation
let payment = Payment
.with_fee
.with_sequence;
match payment.validate
Contributing 
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
# Clone the repository
# Run tests
# Run CLI tests
# Build with all features
License 
This project is licensed under the ISC License.