or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

accounts.mdclients.mdcore.mdindex.mdledger.mdmodels.mdtransactions.mdutils.mdwallets.md
tile.json

tessl/pypi-xrpl-py

A complete Python library for interacting with the XRP Ledger blockchain, providing transaction creation, account management, and comprehensive XRPL protocol support

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/xrpl-py@4.3.x

To install, run

npx @tessl/cli install tessl/pypi-xrpl-py@4.3.0

index.mddocs/

XRPL-PY

A complete Python library for interacting with the XRP Ledger blockchain, providing transaction creation, account management, cryptographic operations, and comprehensive XRPL protocol support. The library offers both synchronous and asynchronous interfaces for building applications that can send transactions, query ledger data, and interact with the decentralized exchange built into the XRPL.

Package Information

  • Package Name: xrpl-py
  • Language: Python
  • Installation: pip install xrpl-py
  • Requires: Python >=3.8.1

Core Imports

import xrpl

Common imports for working with XRPL:

from xrpl import (
    account, clients, models, transaction, utils, wallet,
    CryptoAlgorithm, XRPLException
)
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions import Payment
from xrpl.models.amounts import IssuedCurrencyAmount
from xrpl.wallet import Wallet

Asynchronous versions:

from xrpl import asyncio as xrpl_asyncio
from xrpl.asyncio.clients import AsyncJsonRpcClient

Basic Usage

from xrpl.clients import JsonRpcClient
from xrpl.wallet import Wallet
from xrpl.models.transactions import Payment
from xrpl import transaction

# Connect to XRPL testnet
client = JsonRpcClient("https://s.altnet.rippletest.net:51234")

# Create or load a wallet
wallet = Wallet.create()
print(f"Wallet address: {wallet.address}")

# Create a payment transaction
payment_tx = Payment(
    account=wallet.address,
    destination="rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
    amount="1000000"  # 1 XRP in drops
)

# Sign and submit the transaction
response = transaction.submit_and_wait(payment_tx, client, wallet)
print(f"Transaction result: {response.result}")

# Query account information
account_info = account.get_balance(wallet.address, client)
print(f"Account balance: {account_info} drops")

Architecture

The xrpl-py library is organized around several key concepts:

  • Clients: Network interfaces for connecting to XRPL nodes via JSON-RPC or WebSocket
  • Models: Type-safe data structures for transactions, requests, amounts, and responses
  • Transactions: Complete lifecycle management including creation, signing, and submission
  • Accounts: Query and manage account state, balances, and transaction history
  • Wallets: Cryptographic key management and address derivation
  • Core: Low-level cryptographic operations, address encoding, and binary serialization
  • Utils: Helper functions for common operations like unit conversions and time formatting

The library provides both synchronous and asynchronous versions of most operations, extensive transaction type support for all XRPL features, robust utility functions, and comprehensive model classes for type-safe XRPL interactions.

Capabilities

Core Cryptographic Operations

Low-level cryptographic functions, address encoding/decoding, binary transaction encoding, and fundamental XRPL constants and types.

from xrpl.core.keypairs import generate_seed, derive_keypair, sign
from xrpl.core.addresscodec import encode_classic_address, decode_classic_address
from xrpl.core.binarycodec import encode, decode
from xrpl import CryptoAlgorithm, XRPLException

Core Operations

Account Management

Query account information, balances, transaction history, and verify account existence on the ledger.

from xrpl import account

def does_account_exist(address: str, client, ledger_index: str = "validated") -> bool: ...
def get_balance(address: str, client, ledger_index: str = "validated") -> int: ...
def get_account_root(address: str, client, ledger_index: str = "validated") -> dict: ...
def get_next_valid_seq_number(address: str, client, ledger_index: str = "current") -> int: ...

Account Management

Transaction Management

Create, sign, submit, and manage XRPL transactions with full support for all transaction types including payments, offers, escrows, NFTs, AMM operations, and cross-chain bridges.

from xrpl import transaction

def sign(transaction, wallet, multisign: bool = False): ...
def submit(transaction, client, fail_hard: bool = False): ...
def sign_and_submit(transaction, client, wallet, autofill: bool = True, check_fee: bool = True): ...
def submit_and_wait(transaction, client, wallet, autofill: bool = True, check_fee: bool = True): ...
def autofill(transaction, client): ...

Transaction Management

Network Clients

Connect to XRPL networks using JSON-RPC or WebSocket protocols with both synchronous and asynchronous interfaces.

from xrpl.clients import JsonRpcClient, WebsocketClient
from xrpl.asyncio.clients import AsyncJsonRpcClient, AsyncWebsocketClient

class JsonRpcClient:
    def __init__(self, url: str): ...
    def request(self, request): ...

class WebsocketClient:
    def __init__(self, url: str): ...
    def send(self, request): ...

Network Clients

Ledger Operations

Query ledger state information including current fees, ledger sequences, and network status.

from xrpl import ledger

def get_fee(client, max_fee_xrp: str = None) -> str:
    """Get current base fee and reserve amounts from the network."""

def get_latest_open_ledger_sequence(client) -> int:
    """Get the latest open (not yet validated) ledger sequence number."""

def get_latest_validated_ledger_sequence(client) -> int:
    """Get the latest validated ledger sequence number."""

Ledger Operations

Data Models and Types

Comprehensive type-safe models for transactions, requests, amounts, currencies, and all XRPL data structures.

from xrpl.models.transactions import Payment, OfferCreate, TrustSet
from xrpl.models.amounts import IssuedCurrencyAmount, Amount
from xrpl.models.currencies import IssuedCurrency, XRP
from xrpl.models.requests import AccountInfo, Ledger, Tx

class Payment(Transaction):
    destination: str
    amount: Amount
    ...

Data Models

Wallet Operations

Create, manage, and operate XRPL wallets including key generation, address derivation, and testnet funding.

from xrpl.wallet import Wallet, generate_faucet_wallet

class Wallet:
    address: str
    public_key: str
    private_key: str
    seed: str
    
    @classmethod
    def create(cls, algorithm: CryptoAlgorithm = CryptoAlgorithm.ED25519) -> "Wallet": ...
    @classmethod
    def from_seed(cls, seed: str, algorithm: CryptoAlgorithm = CryptoAlgorithm.ED25519) -> "Wallet": ...

Wallet Operations

Utility Functions

Helper functions for unit conversions, time formatting, string encoding, NFT operations, and transaction analysis.

from xrpl.utils import (
    xrp_to_drops, drops_to_xrp,
    ripple_time_to_datetime, datetime_to_ripple_time,
    str_to_hex, hex_to_str,
    get_balance_changes, get_nftoken_id
)

def xrp_to_drops(xrp) -> str: ...
def drops_to_xrp(drops) -> Decimal: ...
def ripple_time_to_datetime(ripple_time: int) -> datetime: ...

Utility Functions

Exceptions

# Base exception
class XRPLException(Exception): ...

# Module-specific exceptions
class XRPLRequestFailureException(XRPLException): ...
class XRPLModelException(XRPLException): ...
class XRPLReliableSubmissionException(XRPLException): ...
class XRPLFaucetException(XRPLException): ...
class XRPLAddressCodecException(XRPLException): ...
class XRPLBinaryCodecException(XRPLException): ...
class XRPLKeypairsException(XRPLException): ...
class XRPRangeException(XRPLException): ...
class XRPLTimeRangeException(XRPLException): ...

Constants

from xrpl import CryptoAlgorithm

class CryptoAlgorithm(str, Enum):
    ED25519 = "ed25519"
    SECP256K1 = "secp256k1"