How to Check Offers | XRPL Development with JavaScript Level 2
Introduction
The XRPL (XRP Ledger) provides native Decentralized Exchange (DEX) functionality, allowing users to create offers (orders) to buy and sell assets. In this article, we will explain how to check offers created on XRPL.
Preparation
Please prepare the wallet address used in the previous section when creating offers.
Create the Script
-
Create a new file named
check_offers.js
in your project directory. -
Paste the following code into
check_offers.js
.
Run the Script
-
Run the following command in the command line to execute the script.
-
If successful, the console will display the following.
The offer check was successful.
In practice, the person who accepts this offer will receive
20 XRP
and pay200 USD
.Note the
seq
number output in this section, as it will be used in the next section.Explanation of Each Field
- flags: Indicates flags related to the offer. Used to set specific conditions or options. Here it is 0, so no special flags are set.
- quality: Indicates the quality of the offer. This is the ratio of “amount of currency to pay” to “amount of currency to receive.” Here, a value of 0.00001 is set, which means a ratio of 1 USD = 100,000 drops.
- seq: The transaction sequence number. This number is unique for each account and indicates the order of transactions.
- taker_gets: Indicates the amount of assets the taker will receive. Here, 20000000 drops (20 XRP) is set. XRP is specified in drops (1 XRP = 1,000,000 drops).
- taker_pays: Indicates the assets the taker will pay.