Regarding the behavior of trust lines | XRPL Development in JavaScript - Level 3
Next, we will explain the behavior of trust lines when making an offer.
Let’s try a scenario where Bob sells B.EUR
issued by Issuer B and buys A.USD
issued by Issuer A, and this B.EUR
eventually is delivered to Daniel.
Prerequisites
Charlie needs to make a payment to Daniel, who wants to receive B.EUR
. However, at this point, Charlie does not hold B.EUR
and only has XRP
and A.USD
issued by Issuer A. Therefore, Charlie considers whether he can exchange his A.USD
.
- Bob will create an offer to sell
B.EUR
issued by Issuer B and buyA.USD
issued by Issuer A to provide liquidity. - Charlie will initiate the process to send
A.USD
asB.EUR
to Daniel.
Creating the Script
-
Use the existing
createOffers.js
to create an offer from Bob. -
Use the existing
crossCurrencyPayment.js
to make a payment from Charlie.
Running the Script
-
Run the following commands in the command line to execute the script.
-
If the following log appears as a result of
crossCurrencyPayment.js
, it is successful.At this point, please check the explorer to confirm the following:
- Bob’s balance of
B.EUR
decreased to900
, and his balance ofA.USD
increased to100
. - Charlie’s balance of
A.USD
increased to1,000
(returned to the initial state). - Daniel’s balance of
B.EUR
increased to1,000
(returned to the initial state).
- Bob’s balance of
About Trust Lines
Bob is able to hold A.USD
even though he did not explicitly set a trust line for it.
This is the behavior triggered by the OfferCreate
transaction, and you can interpret it as “placing an order for A.USD
= trusting A.USD
”.
In the next chapter, we will explain cross-currency payment patterns and more.