Trade in the Decentralized Exchange
This guide shows how to buy and sell tokens in the decentralized exchange (DEX) of the XRP Ledger. Its example buys a token by selling XRP on a test network.
- Section
- Tutorials
What you need
You need a connection to the XRP Ledger network, and public servers work for testing. The examples use xrpl.js for JavaScript and xrpl-py for Python. You can also follow the steps in your browser without any setup. To transact you need an address, a secret key and some XRP, which you can get on the Testnet for development.
Look up offers
Before you trade, you usually look at what others are buying and selling for. The book_offers method lists the existing offers for any currency pair. The guide compares them with your planned offer to estimate how it would go. Other users can trade at any time, so this is only an estimate.
Send the offer
Send an OfferCreate transaction. TakerPays says how much of which currency you want to buy in total. TakerGets says how much you offer to pay in total, here XRP in drops, and one drop is the smallest unit of XRP. Most transactions are accepted into the next ledger version, so the outcome may take 4 to 7 seconds to be final.
See what happened
Read the metadata of the validated transaction to see exactly what it did. Some or all of the offer may have been filled by matching existing offers. Any remainder is placed in the ledger to wait for new matching offers. Then look up your balances with the account_lines method and your outstanding offers with the account_offers method.
Good to know
Test networks are for testing only, and their state is sometimes reset along with all balances. Do not use the same addresses on the test networks and on Mainnet. For production software, use an existing account and manage your keys with a secure signing setup.
Source: xrpl.org. Read 6 December 2026.
Zerpedia states what the source says, in plain words, and gives no opinion. How Zerpedia is made