{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Place A DEX Order","siteUrl":"https://opensource.ripple.com/","meta":[{"name":"google-site-verification","content":"bLwyBi1imklcIuQxZ7JeI_kRF5Mg7yfr6arpEQV2nsE"}],"llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]},"description":"Place buy and sell orders on the XRP Ledger DEX with the iou vertical, using familiar order types."},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"place-a-dex-order","__idx":0},"children":["Place A DEX Order"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["iou"]}," vertical places orders to buy or sell an issued currency, priced in XRP or another IOU. The order type controls how the offer is worked."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ts","header":{"controls":{"copy":{}}},"source":"/**\n * Place an order on the DEX.\n *\n * The `iou` vertical places orders to buy or sell an issued currency, priced in\n * XRP or another IOU. Order type controls how the offer is worked.\n *\n * MPTs (the `token` vertical) are deliberately absent here: the MPT DEX\n * amendment is not yet live on-chain, so MPTs cannot be traded on the order\n * book and there is no token-offer verb. All DEX offers go through `iou`.\n */\nimport { LocalSigner, SimpleXRPL } from 'simplexrpl'\n\nconst client = await SimpleXRPL.init({\n  xrpldUrl: 'wss://s.altnet.rippletest.net:51233',\n  signers: [LocalSigner.fromEnv()],\n})\n\n// --- Via the IOU vertical: sell 100 USD for 50 XRP -------------------------\n// orderType: 'limit' rests on the book; 'market' = immediate-or-cancel;\n// 'fok' = fill-or-kill; 'passive' = rest without crossing.\nconst sell = await client.iou.sellOffer({\n  ticker: 'USD',\n  amount: '100',\n  orderType: 'limit',\n  price: { currency: 'XRP', amount: '50' },\n})\nconsole.log('sell offer submitted:', sell.txHash)\n\n// Buy 100 USD, paying in another IOU (EUR):\nawait client.iou.buyOffer({\n  ticker: 'USD',\n  amount: '100',\n  orderType: 'fok',\n  price: {\n    ticker: 'EUR',\n    issuer: 'rEurIssuer000000000000000000000000',\n    amount: '90',\n  },\n})\n\n// Read your resting offers back (no signer required) — each is shaped with its\n// sequence, amount, price, and buy/sell type, ready to compose or cancel.\nconst mine = await client.account.listOffers()\nfor (const offer of mine.data) {\n  console.log(offer.type, offer.amount, '@', offer.price)\n}\n\n// Or read the whole USD order book (both sides), regardless of who placed them:\nconst book = await client.iou.listOffers({\n  ticker: 'USD',\n  issuer: 'rIssuer00000000000000000000000000000',\n})\nconsole.log('resting USD offers:', book.data.length)\n\n// Cancel a resting offer by its sequence number — here, the first one read back:\nif (mine.data.length > 0) {\n  await client.iou.cancelOffer({ offerSequence: mine.data[0].offerSequence })\n}\n\nawait client.disconnect()\n","lang":"ts"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"see-also","__idx":1},"children":["See Also"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/docs/simplexrpl/references/verticals/iou/buyoffer"},"children":["iou.buyOffer()"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/docs/simplexrpl/references/verticals/iou/selloffer"},"children":["iou.sellOffer()"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/docs/simplexrpl/references/verticals/iou/canceloffer"},"children":["iou.cancelOffer()"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/docs/simplexrpl/references/verticals/iou/listoffers"},"children":["iou.listOffers()"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"a","attributes":{"href":"/docs/simplexrpl/references/verticals/account/listoffers"},"children":["account.listOffers()"]}]}]}]},"headings":[{"value":"Place A DEX Order","id":"place-a-dex-order","depth":1},{"value":"See Also","id":"see-also","depth":2}],"frontmatter":{"seo":{"description":"Place buy and sell orders on the XRP Ledger DEX with the iou vertical, using familiar order types.","title":"Place A DEX Order"},"labels":["simpleXRPL","SDK"]},"editPage":{"to":"https://github.com/ripple/opensource.ripple.com/tree/main/docs/simpleXRPL/tutorials/place-dex-order.md"},"lastModified":"2026-08-26T05:15:32.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/docs/simplexrpl/tutorials/place-dex-order","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}