> loading_
# MPT on the DEX — Developer Walkthrough
# Tested against rippled with MPT amendment enabled (devnet)
# Using xrpl.js (ensure you're on a version that supports MPT serialization)
# -------------------------------------------------------
# Step 1: Understand the MPT asset identifier
# Unlike issued currencies (currency + issuer), MPTs are
# identified by a MPTokenIssuanceID — a 256-bit hash.
# You'll reference this ID wherever you'd normally put
# a currency/issuer pair.
# -------------------------------------------------------
# const mptAsset = {
# mpt_issuance_id: "00000001A407AF5856CFE...", // 64-char hex
# value: "100" // amount as string
# };
# -------------------------------------------------------
# Step 2: Create an offer — selling XRP for an MPT
# The OfferCreate transaction now accepts MPT amounts
# in TakerPays or TakerGets fields.
# -------------------------------------------------------
# const offerTx = {
# TransactionType: "OfferCreate",
# Account: wallet.classicAddress,
# TakerPays: { // What you want to receive
# mpt_issuance_id: "00000001A407AF5856CFE...",
# value: "50"
# },
# TakerGets: xrpl.xrpToDrops("25"), // What you're giving up (25 XRP)
# };
# const result = await client.submitAndWait(offerTx, { wallet });
# console.log("Offer result:", result.result.meta.TransactionResult);
# -------------------------------------------------------
# Step 3: Query the orderbook for an MPT/XRP pair
# book_offers now supports MPT on either side of the book.
# -------------------------------------------------------
# const orderbook = await client.request({
# command: "book_offers",
# taker_pays: {
# mpt_issuance_id: "00000001A407AF5856CFE..."
# },
# taker_gets: {
# currency: "XRP"
# },
# limit: 10
# });
# console.log("MPT/XRP offers:", orderbook.result.offers);
# -------------------------------------------------------
# Step 4: Payment pathfinding through MPT books
# The path_find engine can now route through MPT liquidity.
# If Alice holds USD and Bob wants MPT-X, the engine can
# chain USD -> XRP -> MPT-X via the DEX.
# -------------------------------------------------------
# const pathResult = await client.request({
# command: "ripple_path_find",
# source_account: aliceAddress,
# destination_account: bobAddress,
# destination_amount: {
# mpt_issuance_id: "00000001A407AF5856CFE...",
# value: "10"
# }
# });
# console.log("Available paths:", pathResult.result.alternatives);
# -------------------------------------------------------
# Key things to update in your codebase:
# 1. Amount parsing — detect mpt_issuance_id field
# 2. Orderbook subscriptions — handle MPT pairs in streams
# 3. Offer tracking — MPT offers have same lifecycle (create/cancel/cross)
# 4. Balance checks — use account_objects or MPToken ledger entries
# 5. Watch the amendment vote — this is gated on mainnet
# -------------------------------------------------------