Get started with XRPL in Python

XRPL is unusually clean to script. One library, one JSON-RPC client, no gas auction. This guide gets xrpl-py talking to the ledger in a few minutes.

Updated 21 Aug 2026 · Uses xrpl-py on Testnet first

Why Python fits XRPL

Wallets are how most people meet XRPL. Scripts are how you live with it. A new ledger every few seconds, fees you can ignore, and a boring HTTP API — that is what you want if you automate balances, payments, or a small watcher.

Use a Xaman wallet for keys you click. Use Python for the jobs you do not want to click.

1. Install xrpl-py

Python 3.8+ in a virtualenv. On Windows the activate line is .venv\Scripts\activate.

python -m venv .venv
source .venv/bin/activate
pip install xrpl-py

2. Connect

JSON-RPC is the default. WebSockets exist if you later subscribe to streams. For a first script, HTTP is enough.

from xrpl.clients import JsonRpcClient

# Testnet — fake XRP, reset occasionally. Use this while you learn.
client = JsonRpcClient("https://s.altnet.rippletest.net:51234/")

When you only read Mainnet, a public cluster is fine, for example https://s2.ripple.com:51234/ or https://xrplcluster.com/. Pixelverse holders can point the same client at the holder rippled URL from the dashboard.

3. Get a Testnet account

The faucet creates a wallet and funds the reserve. Testnet XRP is worthless. Do not reuse Testnet seeds on Mainnet.

from xrpl.wallet import generate_faucet_wallet

wallet = generate_faucet_wallet(client, debug=True)
print(wallet.address)

4. Read the account

Balances come back in drops (1 XRP = 1,000,000 drops). Always ask for the validated ledger so the number will not change under you.

from xrpl.models.requests import AccountInfo
from xrpl.utils import drops_to_xrp

info = client.request(AccountInfo(
    account=wallet.address,
    ledger_index="validated",
    strict=True,
))
data = info.result["account_data"]
print("validated", info.result.get("validated"))
print("XRP", drops_to_xrp(data["Balance"]))
print("sequence", data["Sequence"])

You can also call xrpl.account.get_balance(wallet.address, client) if you only need drops as an integer.

5. Read the live ledger

This is the heartbeat. If this number ticks, you are on XRPL.

from xrpl.models.requests import Ledger

ledger = client.request(Ledger(ledger_index="validated"))
print("ledger_index", ledger.result["ledger_index"])

Mainnet later

  • Generate keys offline. Store the seed in an environment variable, never in git.
  • Fund the account with real XRP for the reserve. There is no Mainnet faucet.
  • Keep reading Testnet until a payment script is boring. Then change the URL.

Next: automate XRPL with Python — poll new ledgers and send a Testnet payment.

Script the ledger. Hold the NFT in a wallet you actually use.

Python automation guide Mint on Pixelverse