XRP Ledger Apex is back in Amsterdam Register Now
arrow-left Course Hub
Lesson 3: Send and receive tokens (beyond XRP) with React.js
Estimated reading time:

25 minutes

Difficulty:

Intermediate

Concepts covered:
  • Direct XRP Payments
  • Non-fungible Tokens
  • Send Currency
  • Tokens

Key takeaway:

Send tokens (beyond XRP) to other accounts and configure your account to receive tokens using trustlines.

Lesson 3

Send and receive tokens (beyond XRP) with React.js

Transfer value beyond XRP using the XRPL’s trustline feature.

Receive tokens beyond XRP by creating a trust line

On the XRPL, you can create tokens to represent valuable things beyond XRP. For example, someone could create a stablecoin token representing a fiat currency on-ledger.

On other chains you are allowed to send any token to anyone. Metaphorically, that’s like saying anyone can put any coin into your wallet, even if you would never use it.

Instead, on the XRPL, you have to explicitly indicate that you are willing to accept a token. You do this by establishing a “trust line” to a specific account for a particular token up to a max amount. You need to specify the particular account you trust because token names are not unique. A digital representation of a dollar is more credible if it was created by a bank than if a random stranger created it.

If you have a trust line established, other people with that token can send it to you, and vice versa. So, this lesson will show you how to establish a trust line and send tokens afterward.

Seeing this in action

  1. Open the sandbox below which will demonstrate how trust lines work.
  2. Wait for the test accounts to finish being created.
  3. Copy the address of the source wallet.
  4. Paste that address into the first blank field of the destination wallet.
  5. Set a limit for the maximum amount of currency you want to receive from the source wallet. (We set the currency to USD in this example, but you can change it to whatever you want).
    – This indicates the destination wallet is willing to receive tokens with the specified name (USD by default) from the source wallet.
  6. Click Send to create the trust line.
    – Behind the scenes this sends a “TrustSet” transaction with the information you provided.
  7. Now, send some tokens from the source wallet to the destination wallet.
    – Note: If you try to send more than the maximum you set in your trust line, it will fail!
END OF LESSON

Now that you've learned a bit about sending and receiving tokens with React on the XRP Ledger, test your knowledge with a quiz.

Why is a trust line necessary for transactions with tokens and currency?
Which of the following statements best summarizes how we use trust lines?
Which hook in the nice-xrpl library creates a trust line?
To change the currency of a transaction in the example code sandbox, which file should be edited?