Agentic Payments with X402 on the XRP Ledger
X402 is an open protocol that lets software pay for a web service as part of an ordinary web request. This guide shows how to accept and make such payments on the XRP Ledger, in XRP or RLUSD, using Python.
- Section
- Agentic Transactions
How the flow works
HTTP is the language web clients and servers speak, and 402 is its status code for Payment Required. An agent, a program that acts on its own, calls a protected address. The merchant answers 402 with the price, the payment address and the facilitator. The agent sends a signed Payment transaction on the XRP Ledger, and the facilitator verifies it and issues a signed receipt. The agent retries with the receipt in the X-PAYMENT header, and the merchant delivers. The agent knows within 3 to 5 seconds whether the payment confirmed.
What you need
You need Python 3.11 or later, a wallet with a testnet balance and basic familiarity with HTTP APIs. The guide uses the x402-xrpl package, which is maintained by T54 and is the reference implementation of X402 for the XRP Ledger. T54 also operates the facilitators. The testnet facilitator is intended for development only.
The steps in short
As a merchant, you install the packages and set your wallet address and your price in a configuration file. Then you write a small server that protects one address with require_payment, and run it. A request without a valid receipt gets a 402 response. As a payer, you store your wallet seed, the secret that controls the wallet, in an environment file and never in version control. Your client uses x402_requests, which wraps the standard requests library. It signs the payment, retries and returns the final response without manual steps.
Prices and Mainnet
Prices are expressed in drops, the smallest unit of XRP: 1 XRP is 1,000,000 drops. For pricing in dollars, the package supports RLUSD. Moving from testnet to Mainnet takes three changes: the network parameter, the facilitator address and a Mainnet wallet funded with real XRP.
Good to know
The merchant chooses the SourceTag, a number stamped on each payment. It tells you which service was paid, not which agent paid. To audit everything an agent spent, filter by the agent's account. The guide currently includes Python examples only.
Source: xrpl.org. Read 6 December 2026.
Zerpedia states what the source says, in plain words, and gives no opinion. How Zerpedia is made