Checking Account Information | XRPL Development in JavaScript Level 1
In the previous chapter, Alice set a trust line for the token issued by Charlie.
In this chapter, we aim to confirm if the trust line has been set correctly, and at the same time, learn about the public methods
of rippled
!
To retrieve account information, use the account methods
, which are public methods
of rippled
.
Prerequisites
This guide proceeds with the following characters:
- Charlie (Token Issuer)
- Alice (Token Recipient)
Create the Script
To check the list of currencies an account can send or receive, use the account_currencies command.
-
Create a new file named
check_account_currencies.js
in your project directory. -
Paste the following code into
check_account_currencies.js
.This example creates a reusable method. The
checkAccountCurrencies()
method retrieves information based on theaccountAddress
passed in as an argument.- Enter Charlie’s testnet address in
charlie_wallet_address_here
. - Enter Alice’s testnet address in
alice_wallet_address_here
.
- Enter Charlie’s testnet address in
Run the Script
-
Run the following command in the command line to execute the script.
-
If successful, the console will display the following.
From Charlie’s account information, which is the issuer of the DOJ token,
DOJ
is included in send_currencies, and from Alice’s account information,DOJ
is included in the receive_currencies array, confirming that Alice can receive theDOJ
token.This shows that XRPL maintains account information (state) for each wallet and transactions are strictly verified based on this information.
What are ledger_index and ledger_hash?
The ledger_hash displayed in the console log is a unique hash value for the ledger. In this sample, data was retrieved from the 441812th validated ledger.
Let’s check the ledger validated at the 441812th position on the testnet.
The ledger hash value for this ledger (441812
) is D05315702B8617B192FB1666BF05F588A457C30D0F493C4FA802BAABDE34209E
, which matches the console log above.
In order to understand the overall big picture of XRPL, it is very important to confirm using your eyes and understand each of these meanings along the way.
Additionally, XRPL Explorer offers a testnet version as well, which is one of the necessary tools for development, so make sure you bookmark it.