How to Set Up a Trust Line | XRPL Development in JavaScript Level 1
What is a Trust Line?
The trust line feature of XRPL (XRP Ledger) allows users to show their intention to accept specific currencies. This is used to handle assets other than XRP on XRPL. For example, if a user wants to accept another currency or a token from another issuer, they need to set a trust line for that currency or token.
The trust line feature allows users to hold and trade assets issued by other users or issuers in their accounts. For example, Alice can receive tokens issued by Charlie by setting a trust line for Charlie’s tokens.
One benefit is that it prevents unauthorized tokens from being sent to a user’s address, maintaining order among users.
Prerequisites
This guide proceeds with the following characters:
Charlie (Token Issuer)
Alice (Token Recipient)
Create the Script
The following is a script to set a trust line for Charlie’s tokens from Alice.
Create a new file named trust_set.js in your project directory.
Paste the following code into trust_set.js.
Enter Charlie’s testnet address in charlie_wallet_address_here.
Enter Alice’s testnet secret key in alice_wallet_secret_here.
Run the Script
Run the following command in the command line to execute the script.
If successful, the console will display the following.
Now Alice can receive the DOJ tokens issued by Charlie.