Skip to content

Checking Trust Line Information Linked to an Issuer | XRPL Development in JavaScript Level 1

In the previous chapter, even though Rippling was enabled, the token transfer from Alice to Bob failed.

To identify why this happened, let’s check the trust line information linked to Charlie.

To retrieve trust line account information, use the account_lines command, a public method of rippled.

Prerequisites

This guide proceeds with the following characters:

  • Charlie (Token Issuer)
  • Alice (Token Recipient)

Create the Script

To check the list of trust lines, use the account_lines command.

  1. Create a new file named check_account_lines.js in your project directory.

  2. Paste the following code into check_account_lines.js.

    const xrpl = require('xrpl');
    async function checkAccountLines(accountAddress) {
    // Connect to the Testnet
    const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233');
    await client.connect();
    try {
    // Check using the account_lines command
    const response = await client.request({
    command: 'account_lines', // Command
    account: accountAddress, // Address to check
    ledger_index: 'validated', // Retrieve from a validated ledger
    });
    // Output the result to the console
    console.log('Account Lines:', response.result.lines);
    } catch (error) {
    console.error('Error retrieving account lines:', error);
    }
    // Call the client.disconnect() method to disconnect from the server
    client.disconnect();
    }
    // Pass the account address as an argument to the function
    const charlieAddress = 'charlie_wallet_address_here'; // Charlie's address
    checkAccountLines(charlieAddress);

    Please enter the testnet address of Charlie in charlie_wallet_address_here.

Run the Script

  1. Run the following command in the command line to execute the script.

    Terminal window
    node check_account_lines.js
  2. If successful, the console will display the following.

    Terminal window
    Account Lines: [
    { // Alice
    account: 'rQr8KfkCQcpqvFwmRspDoaL36reZhcdaeA',
    balance: '-1000', // Debt to Alice
    currency: 'DOJ',
    limit: '0',
    limit_peer: '10000',
    no_ripple: true, // No Ripple flag
    no_ripple_peer: false,
    quality_in: 0,
    quality_out: 0
    },
    { // Bob
    account: 'rDNVaJJSp9iQmHC8YAAwHytnLP9aXEPhDw',
    balance: '0',
    currency: 'DOJ',
    limit: '0',
    limit_peer: '10000',
    no_ripple: true, // No Ripple flag
    no_ripple_peer: false,
    quality_in: 0,
    quality_out: 0
    }
    ]

    From the Charlie’s perspective, the issuer, the trust lines linked to the accounts are shown as no_ripple: true.

    Additionally, the -1000 indicates that from Charlie’s perspective, there is a debt of 1000 DOJ tokens to Alice. This concept is similar to a government bond held by citizens.

About Rippling and Trust Line Relationships

Alice and Bob have set up trust lines and have the right to receive tokens from Charlie, but the NoRipple flag was enabled.

This was caused because the trust line was set before enabling the Rippling flag on Charlie’s account, the issuer of the DOJ token.

To generally allow token transfers between users, you need to enable the issuer’s account Rippling first, and then have users set up their trust lines.

In the next chapter, we will explain how to disable the NoRipple flag using the TrustSet transaction.