Add improvements to walkthrough

This commit is contained in:
Maria Shodunke
2025-08-19 13:04:46 +01:00
parent 06b3c80ac7
commit dff3298d60
6 changed files with 334 additions and 154 deletions

View File

@@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>XRPL.js Base Example</title>
<!-- @chunk {"steps": ["import-web-tag"]} -->
<script src="https://unpkg.com/xrpl/build/xrpl-latest-min.js"></script>
<!-- @chunk-end -->
</head>
<body>
<h1>XRPL.js Example</h1>
<!-- @chunk {"steps": ["import-web-tag"]} -->
<script>
const xrpl = require("xrpl")
</script>
<!-- @chunk-end -->
</body>
</html>

View File

@@ -1,17 +1,11 @@
// In browsers, use a <script> tag. In Node.js, uncomment the following line: // In browsers, use a <script> tag. In Node.js, uncomment the following line:
const xrpl = require('xrpl') import xrpl from 'xrpl'
// Wrap code in an async function so we can use await // Define the network client
async function main() { const client = new xrpl.Client("wss://s.altnet.rippletest.net:51233")
await client.connect()
// Define the network client // ... custom code goes here
const client = new xrpl.Client("wss://s.altnet.rippletest.net:51233")
await client.connect()
// ... custom code goes here // Disconnect when done (If you omit this, Node.js won't end the process)
client.disconnect()
// Disconnect when done (If you omit this, Node.js won't end the process)
await client.disconnect()
}
main()

View File

@@ -1,61 +1,63 @@
// Import the library // Import the library
// @chunk {"steps": ["import-node-tag"]} // @chunk {"steps": ["connect-tag"]}
const xrpl = require("xrpl") import xrpl from "xrpl"
// Define the network client
const SERVER_URL = "wss://s.altnet.rippletest.net:51233/"
const client = new xrpl.Client(SERVER_URL)
await client.connect()
console.log("Connected to Testnet")
// @chunk-end // @chunk-end
// Wrap code in an async function so we can use await // @chunk {"steps": ["get-account-create-wallet-tag"]}
async function main() { // Create a wallet and fund it with the Testnet faucet:
console.log("\nCreating a new wallet and funding it with Testnet XRP...")
const fund_result = await client.fundWallet()
const test_wallet = fund_result.wallet
console.log(`Wallet: ${test_wallet.address}`)
console.log(`Balance: ${fund_result.balance}`)
console.log(`\nAccount Testnet Explorer URL:\nhttps://testnet.xrpl.org/accounts/${test_wallet.address}`)
// @chunk-end
// @chunk {"steps": ["connect-tag"]} // To generate a wallet without funding it, uncomment the code below
// Define the network client // @chunk {"steps": ["get-account-create-wallet-b-tag"]}
const SERVER_URL = "wss://s.altnet.rippletest.net:51233/" // const test_wallet = xrpl.Wallet.generate()
const client = new xrpl.Client(SERVER_URL) // @chunk-end
await client.connect()
// @chunk-end
// @chunk {"steps": ["get-account-create-wallet-tag"]} // To provide your own seed, replace the test_wallet value with the below
// Create a wallet and fund it with the Testnet faucet: // @chunk {"steps": ["get-account-create-wallet-c-tag"]}
const fund_result = await client.fundWallet() // const test_wallet = xrpl.Wallet.fromSeed("your-seed-key")
const test_wallet = fund_result.wallet // @chunk-end
console.log(fund_result)
// @chunk-end
// To generate keys only, uncomment the code below // @chunk {"steps": ["query-xrpl-tag"]}
// @chunk {"steps": ["get-account-create-wallet-b-tag"]} // Get info from the ledger about the address we just funded
// const test_wallet = xrpl.Wallet.generate() console.log("\nGetting account info...")
// @chunk-end const response = await client.request({
"command": "account_info",
"account": test_wallet.address,
"ledger_index": "validated"
})
console.log(JSON.stringify(response, null, 2))
// @chunk-end
// To provide your own seed, replace the test_wallet value with the below // @chunk {"steps": ["listen-for-events-tag"]}
// @chunk {"steps": ["get-account-create-wallet-c-tag"], "inputs": ["wallet-input"]} // Listen to ledger close events
// const test_wallet = xrpl.Wallet.fromSeed({{wallet-input}}) console.log("\nListening for ledger close events...")
// @chunk-end client.request({
"command": "subscribe",
"streams": ["ledger"]
})
client.on("ledgerClosed", async (ledger) => {
console.log(`Ledger #${ledger.ledger_index} validated with ${ledger.txn_count} transactions!`)
})
// @chunk-end
// @chunk {"steps": ["query-xrpl-tag"]} // @chunk {"steps": ["disconnect-node-tag"]}
// Get info from the ledger about the address we just funded // Disconnect when done so Node.js can end the process.
const response = await client.request({ // Delay this by 10 seconds to give the ledger event listener time to receive
"command": "account_info", // and display some ledger events.
"account": test_wallet.address, setTimeout(async () => {
"ledger_index": "validated" await client.disconnect();
}) console.log('\nDisconnected');
console.log(response) }, 10000);
// @chunk-end // @chunk-end
// @chunk {"steps": ["listen-for-events-tag"]}
// Listen to ledger close events
client.request({
"command": "subscribe",
"streams": ["ledger"]
})
client.on("ledgerClosed", async (ledger) => {
console.log(`Ledger #${ledger.ledger_index} validated with ${ledger.txn_count} transactions!`)
})
// @chunk-end
// @chunk {"steps": ["disconnect-tag"]}
// Disconnect when done so Node.js can end the process
await client.disconnect()
// @chunk-end
}
// call the async function
main()

View File

@@ -0,0 +1,79 @@
<!DOCTYPE html>
<html>
<head>
<title>XRPL.js Base Example</title>
<!-- @chunk {"steps": ["import-web-tag"]} -->
<script src="https://unpkg.com/xrpl/build/xrpl-latest-min.js"></script>
<!-- @chunk-end -->
</head>
<body>
<h1>XRPL.js Get Started</h1>
<div id="output"></div>
<script>
(async () => {
const output = document.getElementById('output');
// @chunk {"steps": ["connect-tag"]}
// Define the network client
const SERVER_URL = "wss://s.altnet.rippletest.net:51233/"
const client = new xrpl.Client(SERVER_URL)
await client.connect()
output.innerHTML = '<p>Connected to Testnet</p>';
// @chunk-end
// @chunk {"steps": ["get-account-create-wallet-tag"]}
// Create a wallet and fund it with the Testnet faucet:
output.innerHTML += '<p>Creating a new wallet and funding it with Testnet XRP...</p>';
const fund_result = await client.fundWallet()
const test_wallet = fund_result.wallet
output.innerHTML += `<p>Wallet: ${test_wallet.address}</p>`;
output.innerHTML += `<p>Balance: ${fund_result.balance}</p>`;
output.innerHTML += `<p>View account on XRPL Testnet Explorer: <a href="https://testnet.xrpl.org/accounts/${test_wallet.address}" target="_blank">${test_wallet.address}</a></p>`;
// @chunk-end
// To generate a wallet without funding it, uncomment the code below
// @chunk {"steps": ["get-account-create-wallet-b-tag"]}
// const test_wallet = xrpl.Wallet.generate()
// @chunk-end
// To provide your own seed, replace the test_wallet value with the below
// @chunk {"steps": ["get-account-create-wallet-c-tag"]}
// const test_wallet = xrpl.Wallet.fromSeed("your-seed-key")
// @chunk-end
// @chunk {"steps": ["query-xrpl-tag"]}
// Get info from the ledger about the address we just funded
output.innerHTML += `<p>Getting account info...</p>`;
const response = await client.request({
"command": "account_info",
"account": test_wallet.address,
"ledger_index": "validated"
})
output.innerHTML += `<pre>${JSON.stringify(response, null, 2)}</pre>`;
// @chunk-end
// @chunk {"steps": ["listen-for-events-tag"]}
// Listen to ledger close events
output.innerHTML += '<p>Listening for ledger close events...</p>';
client.request({
"command": "subscribe",
"streams": ["ledger"]
})
client.on("ledgerClosed", async (ledger) => {
output.innerHTML += `<p>Ledger #${ledger.ledger_index} validated with ${ledger.txn_count} transactions</p>`;
})
// @chunk-end
// @chunk {"steps": ["disconnect-web-tag"]}
// Disconnect when done. Delay this by 10 seconds to give the ledger event listener time to
// receive and display some ledger events.
setTimeout(async () => {
await client.disconnect();
output.innerHTML += '<p>Disconnected</p>';
}, 10000);
// @chunk-end
})();
</script>
</body>
</html>

View File

@@ -1,5 +1,6 @@
{ {
"dependencies": { "dependencies": {
"xrpl": "^4.0.0" "xrpl": "^4.4.0"
} },
"type": "module"
} }

View File

@@ -1,6 +1,4 @@
--- ---
html: get-started-using-javascript-library.html
parent: javascript.html
seo: seo:
description: Build an entry-level JavaScript application for querying the XRP Ledger. description: Build an entry-level JavaScript application for querying the XRP Ledger.
top_nav_name: JavaScript top_nav_name: JavaScript
@@ -13,95 +11,102 @@ showcase_icon: assets/img/logos/javascript.svg
{% code-walkthrough {% code-walkthrough
filesets=[ filesets=[
{ {
"files": [ "/_code-samples/get-started/js/base.html", "/_code-samples/get-started/js/get-acct-info.js"], "files": ["/_code-samples/get-started/js/get-acct-info.js"],
"downloadAssociatedFiles": ["/_code-samples/get-started/js/*"], "downloadAssociatedFiles": ["/_code-samples/get-started/js/package.json", "/_code-samples/get-started/js/get-acct-info.js"],
"when": { "environment": "Node" }
},
{
"files": ["/_code-samples/get-started/js/index.html"],
"downloadAssociatedFiles": ["/_code-samples/get-started/js/index.html"],
"when": { "environment": "Web" }
} }
] ]
filters={
"environment": {
"label": "Environment",
"items": [
{ "value": "Node" },
{ "value": "Web" },
]
}
}
%} %}
# Get Started Using JavaScript Library # Get Started Using JavaScript Library
This tutorial guides you through the basics of building an XRP Ledger-connected application in JavaScript or TypeScript using the [`xrpl.js`](https://github.com/XRPLF/xrpl.js/) client library in either Node.js or web browsers. This tutorial guides you through the basics of building an XRP Ledger-connected application in JavaScript using the [`xrpl.js`](https://github.com/XRPLF/xrpl.js/) client library in either Node.js or web browsers.
The scripts and config files used in this guide are {% repo-link path="_code-samples/get-started/js/" %}available in this website's GitHub Repository{% /repo-link %}. ## Goals
## Learning Goals
In this tutorial, you'll learn: In this tutorial, you'll learn:
* The basic building blocks of XRP Ledger-based applications. - The basic building blocks of XRP Ledger-based applications.
* How to connect to the XRP Ledger using `xrpl.js`. - How to connect to the XRP Ledger using `xrpl.js`.
* How to get an account on the [Testnet](/resources/dev-tools/xrp-faucets) using `xrpl.js`. - How to get an account on the [Testnet](/resources/dev-tools/xrp-faucets) using `xrpl.js`.
* How to use the `xrpl.js` library to look up information about an account on the XRP Ledger. - How to use the `xrpl.js` library to look up information about an account on the XRP Ledger.
* How to put these steps together to create a JavaScript app or web-app. - How to put these steps together to create a JavaScript app or web-app.
## Prerequisites
## Requirements To complete this tutorial, you should meet the following guidelines:
To follow this tutorial, you should have some familiarity with writing code in JavaScript and managing small JavaScript projects. In browsers, any modern web browser with JavaScript support should work fine. In Node.js, **version 14** is recommended. Node.js versions 12 and 16 are also regularly tested. - Have some familiarity with writing code in JavaScript.
- Have installed Node.js **version 20** or later in your development environment.
- If you want to build a web application, any modern web browser with JavaScript support should work fine.
## Source Code
## Start Building Click **Download** on the top right of the code preview panel to download the source code.
When you're working with the XRP Ledger, there are a few things you'll need to manage, whether you're adding XRP to your [account](../../../concepts/accounts/index.md), integrating with the [decentralized exchange](../../../concepts/tokens/decentralized-exchange/index.md), or [issuing tokens](../../../concepts/tokens/index.md). This tutorial walks you through basic patterns common to getting started with all of these use cases and provides sample code for implementing them. ## Steps
Here are some steps you use in many XRP Ledger projects: Follow the steps to create a simple application with `xrpl.js`.
1. [Import the library.](#1-import-the-library) ### 1. Install Dependencies
1. [Connect to the XRP Ledger.](#2-connect-to-the-xrp-ledger)
1. [Get an account.](#3-get-account)
1. [Query the XRP Ledger.](#4-query-the-xrp-ledger)
1. [Listen for Events.](#5-listen-for-events)
### 1. Import the Library <!-- Web steps -->
{% step id="import-web-tag" when={ "environment": "Web" } %}
How you load `xrpl.js` into your project depends on your development environment: To load `xrpl.js` into your project, add a `<script>` tag such as the following to your HTML.
{% step id="import-web-tag" %}
#### Web Browsers
Add a `<script>` tag such as the following to your HTML.
<!-- ```html
<script src="https://unpkg.com/xrpl/build/xrpl-latest-min.js"></script>
``` -->
You can load the library from a CDN as in the example, or download a release and host it on your own website. You can load the library from a CDN as in the example, or download a release and host it on your own website.
This loads the module into the top level as `xrpl`. This loads the module into the top level as `xrpl`.
{% /step %} {% /step %}
{% step id="import-node-tag" %} <!-- Node.js steps -->
#### Node.js {% step id="install-node-tag" when={ "environment": "Node" } %}
Start a new project by creating an empty folder, then move into that folder and use [NPM](https://www.npmjs.com/) to install the latest version of xrpl.js: Start a new project by creating an empty folder, then move into that folder and use [NPM](https://www.npmjs.com/) to install the latest version of xrpl.js:
```sh ```sh
npm install xrpl npm install xrpl
``` ```
This updates your `package.json` file, or creates a new one if it didn't already exist. This updates your `package.json` file, or creates a new one if it didn't already exist.
Then, import the library in your code. Your `package.json` file should look something like this:
<!-- ```js
const xrpl = require("xrpl") {% code-snippet file="/_code-samples/get-started/js/package.json" language="json" /%}
``` -->
{% /step %} {% /step %}
### 2. Connect to the XRP Ledger ### 2. Connect to the XRP Ledger
{% step id="connect-tag" %} {% step id="connect-tag" %}
#### Connect to the XRP Ledger Testnet
To make queries and submit transactions, you need to connect to the XRP Ledger. To do this with `xrpl.js`, you create an instance of the `Client` class and use the `connect()` method. To make queries and submit transactions, you need to connect to the XRP Ledger. To do this with `xrpl.js`, you create an instance of the `Client` class and use the `connect()` method.
{% admonition type="success" name="Tip" %}Many network functions in `xrpl.js` use [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to return values asynchronously. The code samples here use the [`async/await` pattern](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await) to wait for the actual result of the Promises.{% /admonition %} {% admonition type="success" name="Tip" %}Many network functions in `xrpl.js` use [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) to return values asynchronously. The code samples here use the [`async/await` pattern](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await) to wait for the actual result of the Promises.{% /admonition %}
<!-- {% code-snippet file="/_code-samples/get-started/js/base.js" language="js" /%} --> The sample code shows you how to connect to the Testnet, which is one of the available [parallel networks](../../../concepts/networks-and-servers/parallel-networks.md).
{% /step %}
{% step id="connect-mainnet-tag"%}
#### Connect to the XRP Ledger Mainnet #### Connect to the XRP Ledger Mainnet
The sample code shows you how to connect to the Testnet, which is one of the available [parallel networks](../../../concepts/networks-and-servers/parallel-networks.md). When you're ready to move to production, you'll need to connect to the XRP Ledger Mainnet. You can do that in two ways: When you're ready to move to production, you'll need to connect to the XRP Ledger Mainnet. You can do that in two ways:
* By [installing the core server](../../../infrastructure/installation/index.md) (`rippled`) and running a node yourself. The core server connects to the Mainnet by default, but you can [change the configuration to use Testnet or Devnet](../../../infrastructure/configuration/connect-your-rippled-to-the-xrp-test-net.md). [There are good reasons to run your own core server](../../../concepts/networks-and-servers/index.md#reasons-to-run-your-own-server). If you run your own server, you can connect to it like so: - By [installing the core server](../../../infrastructure/installation/index.md) (`rippled`) and running a node yourself. The core server connects to the Mainnet by default, but you can [change the configuration to use Testnet or Devnet](../../../infrastructure/configuration/connect-your-rippled-to-the-xrp-test-net.md). [There are good reasons to run your own core server](../../../concepts/networks-and-servers/index.md#reasons-to-run-your-own-server). If you run your own server, you can connect to it like so:
```javascript ```javascript
const MY_SERVER = "ws://localhost:6006/" const MY_SERVER = "ws://localhost:6006/"
@@ -111,7 +116,7 @@ The sample code shows you how to connect to the Testnet, which is one of the ava
See the example [core server config file](https://github.com/XRPLF/rippled/blob/c0a0b79d2d483b318ce1d82e526bd53df83a4a2c/cfg/rippled-example.cfg#L1562) for more information about default values. See the example [core server config file](https://github.com/XRPLF/rippled/blob/c0a0b79d2d483b318ce1d82e526bd53df83a4a2c/cfg/rippled-example.cfg#L1562) for more information about default values.
* By using one of the available [public servers][]: - By using one of the available [public servers][]:
```javascript ```javascript
const PUBLIC_SERVER = "wss://xrplcluster.com/" const PUBLIC_SERVER = "wss://xrplcluster.com/"
@@ -123,59 +128,173 @@ The sample code shows you how to connect to the Testnet, which is one of the ava
### 3. Get Account ### 3. Get Account
{% step id="get-account-create-wallet-tag" %} {% step id="get-account-create-wallet-tag" %}
The `xrpl.js` library has a `Wallet` class for handling the keys and address of an XRP Ledger account. On Testnet, you can fund a new account as shown in the example. #### Create and Fund a Wallet
<!-- {% code-snippet file="/_code-samples/get-started/js/get-acct-info.js" from="// Create a wallet" before="// Get info" language="js" /%} --> The `xrpl.js` library has a `Wallet` class for handling the keys and address of an XRP Ledger account. On Testnet, you can fund a new account as shown in the example.
{% /step %} {% /step %}
{% step id="get-account-create-wallet-b-tag" %} {% step id="get-account-create-wallet-b-tag" %}
If you only want to generate keys, you can alternatively create a new `Wallet` instance. #### (Optional) Generate a Wallet Only
<!-- ```js If you want to generate a wallet without funding it, you can create a new `Wallet` instance. Keep in mind that you need to send XRP to the wallet for it to be a valid account on the ledger.
const test_wallet = xrpl.Wallet.generate()
``` -->
{% /step %} {% /step %}
{% step id="get-account-create-wallet-c-tag" %} {% step id="get-account-create-wallet-c-tag" %}
Or, if you already have a seed encoded in [base58][], you can make a `Wallet` instance from it. #### (Optional) Use Your Own Wallet Seed
{% input id="wallet-input" label="Your Testnet seed key" placeholder="Enter seed key" /%} To use an existing wallet seed encoded in [base58][], you can create a `Wallet` instance from it.
<!-- ```js
const test_wallet = xrpl.Wallet.fromSeed("sn3nxiW7v8KXzPzAqzyHXbSSKNuN9") // Test secret; don't use for real
``` -->
{% /step %} {% /step %}
### 4. Query the XRP Ledger ### 4. Query the XRP Ledger
{% step id="query-xrpl-tag" %} {% step id="query-xrpl-tag" %}
Use the Client's `request()` method to access the XRP Ledger's [WebSocket API](../../../references/http-websocket-apis/api-conventions/request-formatting.md). Use the Client's `request()` method to access the XRP Ledger's [WebSocket API](../../../references/http-websocket-apis/api-conventions/request-formatting.md).
<!-- {% code-snippet file="/_code-samples/get-started/js/get-acct-info.js" from="// Get info" before="// Listen to ledger close events" language="js" /%} -->
{% /step %} {% /step %}
### 5. Listen for Events ### 5. Listen for Events
{% step id="listen-for-events-tag" %} {% step id="listen-for-events-tag" %}
You can set up handlers for various types of events in `xrpl.js`, such as whenever the XRP Ledger's [consensus process](../../../concepts/consensus-protocol/index.md) produces a new [ledger version](../../../concepts/ledgers/index.md). To do that, first call the [subscribe method][] to get the type of events you want, then attach an event handler using the `on(eventType, callback)` method of the client. You can set up handlers for various types of events in `xrpl.js`, such as whenever the XRP Ledger's [consensus process](../../../concepts/consensus-protocol/index.md) produces a new [ledger version](../../../concepts/ledgers/index.md). To do that, first call the [subscribe method][] to get the type of events you want, then attach an event handler using the `on(eventType, callback)` method of the client.
<!-- {% code-snippet file="/_code-samples/get-started/js/get-acct-info.js" from="// Listen to ledger close events" before="// Disconnect when done" language="js" /%} -->
{% /step %} {% /step %}
### 6. Disconnect ### 6. Disconnect
{% step id="disconnect-tag" %} {% step id="disconnect-node-tag" when={ "environment": "Node" } %}
Disconnect when done so Node.js can end the process. Disconnect when done so Node.js can end the process. The example code waits 10 seconds before disconnecting to allow time for the ledger event listener to receive and display events.
{% /step %} {% /step %}
## Keep on Building {% step id="disconnect-web-tag" when={ "environment": "Web" } %}
Disconnect from the ledger when done. The example code waits 10 seconds before disconnecting to allow time for the ledger event listener to receive and display events.
{% /step %}
Now that you know how to use `xrpl.js` to connect to the XRP Ledger, get an account, and look up information about it, you can also: ### 7. Run the Application
* [Send XRP](../../how-tos/send-xrp.md). {% step id="run-app-node-tag" when={ "environment": "Node" } %}
* [Issue a Fungible Token](../../how-tos/use-tokens/issue-a-fungible-token.md) Finally, in your terminal, run the application like so:
* [Set up secure signing](../../../concepts/transactions/secure-signing.md) for your account.
```sh
node get-acct-info.js
```
You should see output similar to the following:
```sh
Connected to Testnet
Creating a new wallet and funding it with Testnet XRP...
Wallet: rMnXR9p2sZT9iZ6ew3iEqvBMyPts1ADc4i
Balance: 10
Account Testnet Explorer URL:
https://testnet.xrpl.org/accounts/rMnXR9p2sZT9iZ6ew3iEqvBMyPts1ADc4i
Getting account info...
{
"api_version": 2,
"id": 4,
"result": {
"account_data": {
"Account": "rMnXR9p2sZT9iZ6ew3iEqvBMyPts1ADc4i",
"Balance": "10000000",
"Flags": 0,
"LedgerEntryType": "AccountRoot",
"OwnerCount": 0,
"PreviousTxnID": "0FF9DB2FE141DD0DF82566A171B6AF70BB2C6EB6A53D496E65D42FC062C91A78",
"PreviousTxnLgrSeq": 9949268,
"Sequence": 9949268,
"index": "4A9C9220AE778DC38C004B2B17A08E218416D90E01456AFCF844C18838B36D01"
},
"account_flags": {
"allowTrustLineClawback": false,
"defaultRipple": false,
"depositAuth": false,
"disableMasterKey": false,
"disallowIncomingCheck": false,
"disallowIncomingNFTokenOffer": false,
"disallowIncomingPayChan": false,
"disallowIncomingTrustline": false,
"disallowIncomingXRP": false,
"globalFreeze": false,
"noFreeze": false,
"passwordSpent": false,
"requireAuthorization": false,
"requireDestinationTag": false
},
"ledger_hash": "304C7CC2A33B712BE43EB398B399E290C191A71FCB71784F584544DFB7C441B0",
"ledger_index": 9949268,
"validated": true
},
"type": "response"
}
Listening for ledger close events...
Ledger #9949269 validated with 0 transactions!
Ledger #9949270 validated with 0 transactions!
Ledger #9949271 validated with 0 transactions!
Disconnected
```
{% /step %}
{% step id="run-app-web-tag" when={ "environment": "Web" } %}
Open the `index.html` file in a web browser.
You should see output similar to the following:
```text
Connected to Testnet
Creating a new wallet and funding it with Testnet XRP...
Wallet: rf7CWJdNssSzQk2GtypYLVhyvGe8oHS3S
Balance: 10
View account on XRPL Testnet Explorer: rf7CWJdNssSzQk2GtypYLVhyvGe8oHS3S
Getting account info...
{
"api_version": 2,
"id": 5,
"result": {
"account_data": {
"Account": "rf7CWJdNssSzQk2GtypYLVhyvGe8oHS3S",
"Balance": "10000000",
"Flags": 0,
"LedgerEntryType": "AccountRoot",
"OwnerCount": 0,
"PreviousTxnID": "96E4B44F93EC0399B7ADD75489630C6A8DCFC922F20F6810D25490CC0D3AA12E",
"PreviousTxnLgrSeq": 9949610,
"Sequence": 9949610,
"index": "B5D2865DD4BF8EEDFEE2FD95DE37FC28D624548E9BBC42F9FBF61B618E98FAC8"
},
"account_flags": {
"allowTrustLineClawback": false,
"defaultRipple": false,
"depositAuth": false,
"disableMasterKey": false,
"disallowIncomingCheck": false,
"disallowIncomingNFTokenOffer": false,
"disallowIncomingPayChan": false,
"disallowIncomingTrustline": false,
"disallowIncomingXRP": false,
"globalFreeze": false,
"noFreeze": false,
"passwordSpent": false,
"requireAuthorization": false,
"requireDestinationTag": false
},
"ledger_hash": "7692673B8091899C3EEE6807F66B65851D3563F483A49A5F03A83608658473D6",
"ledger_index": 9949610,
"validated": true
},
"type": "response"
}
Listening for ledger close events...
Ledger #9949611 validated with 0 transactions
Ledger #9949612 validated with 1 transactions
Ledger #9949613 validated with 0 transactions
Disconnected
```
{% /step %}
## See Also ## See Also
@@ -184,6 +303,8 @@ Now that you know how to use `xrpl.js` to connect to the XRP Ledger, get an acco
- [Client Libraries](../../../references/client-libraries.md) - [Client Libraries](../../../references/client-libraries.md)
- **Tutorials:** - **Tutorials:**
- [Send XRP](../../how-tos/send-xrp.md) - [Send XRP](../../how-tos/send-xrp.md)
- [Issue a Fungible Token](../../how-tos/use-tokens/issue-a-fungible-token.md)
- [Set up Secure Signing](../../../concepts/transactions/secure-signing.md)
- **References:** - **References:**
- [`xrpl.js` Reference](https://js.xrpl.org/) - [`xrpl.js` Reference](https://js.xrpl.org/)
- [Public API Methods](../../../references/http-websocket-apis/public-api-methods/index.md) - [Public API Methods](../../../references/http-websocket-apis/public-api-methods/index.md)