### Example Tag Format Source: https://github.com/xrplf/xrpl.js/blob/main/RELEASE.md An example of a GitHub release and git tag following the specified format. ```text xrpl@2.3.1 ``` -------------------------------- ### Install xrpl.js with npm Source: https://github.com/xrplf/xrpl.js/blob/main/README.md Install the xrpl.js library into your project using npm. This is a prerequisite for using the library. ```bash $ npm install --save xrpl ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/xrplf/xrpl.js/blob/main/packages/ripple-binary-codec/CONTRIBUTING.md Install project dependencies and run unit tests. Use `npm test` for Node.js environments and `npm test:browser` for browser environments. ```bash npm i npm test ``` ```bash npm test:browser ``` -------------------------------- ### Stable Release Workflow Trigger Example Source: https://github.com/xrplf/xrpl.js/blob/main/RELEASE.md Example of required inputs for triggering a stable release workflow. ```text release_branch_name=release/xrpl@4.3.8, package_name=xrpl, npmjs_dist_tag=latest ``` -------------------------------- ### Beta Release Workflow Trigger Example Source: https://github.com/xrplf/xrpl.js/blob/main/RELEASE.md Example of required inputs for triggering a beta release workflow. The npmjs_dist_tag will have '-experimental' appended. ```text release_branch_name=feature/xrpl-beta, package_name=xrpl, npmjs_dist_tag=feature-a ``` -------------------------------- ### Install Pods for React Native Source: https://github.com/xrplf/xrpl.js/blob/main/UNIQUE_SETUPS.md After installing dependencies, run this command to compile pods for react-native-get-random-values. Refer to the package's installation guide for more details. ```shell # compile `react-native-get-random-values` pods see https://www.npmjs.com/package/react-native-get-random-values#installation npx pod-install ``` -------------------------------- ### Install xrpl.js using npm or yarn Source: https://github.com/xrplf/xrpl.js/blob/main/docs/index.html Install the xrpl.js library into your project using either npm or yarn package managers. ```bash npm install --save xrpl ``` ```bash yarn add xrpl ``` -------------------------------- ### GatewayBalancesRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/GatewayBalancesRequest.html This example demonstrates how to construct a GatewayBalancesRequest object. It includes the command, account, strict flag, hot wallet addresses, and ledger index. ```typescript const gatewayBalances: GatewayBalanceRequest = { "id": "example_gateway_balances_1", "command": "gateway_balances", "account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q", "strict": true, "hotwallet": ["rKm4uWpg9tfwbVSeATv4KxDe6mpE9yPkgJ","ra7JkEzrgeKHdzKgo4EUUVBnxggY4z37kt"], "ledger_index": "validated" } ``` -------------------------------- ### Run Linter and Build Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Execute these commands to install dependencies, build the project, and then run the linter to check code quality. ```bash npm install npm run build npm run lint ``` -------------------------------- ### Run Unit Tests Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Install dependencies, build the project, and then run the unit tests. This is a crucial step for verifying code changes. ```bash npm install npm run build npm test ``` -------------------------------- ### LedgerDataRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/LedgerDataRequest.html An example of how to construct a LedgerDataRequest object to fetch ledger data. ```APIDOC ## LedgerDataRequest The `ledger_data` method retrieves contents of the specified ledger. You can iterate through several calls to retrieve the entire contents of a single ledger version. ### Example ```json { "id": 2, "ledger_hash": "842B57C1CC0613299A686D3E9F310EC0422C84D3911E5056389AA7E5808A93C8", "command": "ledger_data", "limit": 5, "binary": true } ``` ### Interface Definition ```typescript interface LedgerDataRequest { api_version?: number; binary?: boolean; command: "ledger_data"; id?: string | number; ledger_hash?: string; ledger_index?: LedgerIndex; limit?: number; marker?: unknown; type?: LedgerEntryFilter; [x: string]: unknown; } ``` ### Properties * **api_version** (Optional, number): The API version to use. If omitted, use version 1. * **binary** (Optional, boolean): If set to true, return ledger objects as hashed hex strings instead of JSON. * **command** (Required, string): The name of the API method. Must be "ledger_data". * **id** (Optional, string | number): A unique value to identify this request. The response to this request uses the same id field. This way, even if responses arrive out of order, you know which request prompted which response. * **ledger_hash** (Optional, string): A 20-byte hex string for the ledger version to use. * **ledger_index** (Optional, LedgerIndex): The ledger index to retrieve. * **limit** (Optional, number): The maximum number of entries to return in this response. * **marker** (Optional, unknown): A value from a previous response that indicates the starting point for the next set of results. * **type** (Optional, LedgerEntryFilter): A filter for the types of ledger entries to retrieve. ``` -------------------------------- ### Install xrpl.js with yarn Source: https://github.com/xrplf/xrpl.js/blob/main/README.md Install the xrpl.js library into your project using yarn. This is an alternative to npm for package management. ```bash $ yarn add xrpl ``` -------------------------------- ### Connect to XRP Ledger and submit account_info request Source: https://github.com/xrplf/xrpl.js/blob/main/docs/index.html This example demonstrates how to connect to an XRP Ledger rippled server using the xrpl.js Client, submit an 'account_info' request, and then disconnect. Ensure you have Node.js v18+ installed. ```javascript const xrpl = require("xrpl"); async function main() { const client = new xrpl.Client("wss://s.altnet.rippletest.net:51233"); await client.connect(); const response = await client.request({ command: "account_info", account: "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", ledger_index: "validated", }); console.log(response); await client.disconnect(); } main(); ``` -------------------------------- ### LedgerRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/LedgerRequest.html An example of how to construct a LedgerRequest object to fetch validated ledger data. ```APIDOC ## LedgerRequest Retrieve information about the public ledger. Expects a response in the form of a [LedgerResponse](LedgerResponse.html). ### Example ```typescript const ledger: LedgerRequest = { "id": 14, "command": "ledger", "ledger_index": "validated", "full": false, "accounts": false, "transactions": false, "expand": false, "owner_funds": false} ``` ### Properties * **accounts** (boolean) - Optional. Admin required. If true, return information on accounts in the ledger. Ignored if you did not specify a ledger version. Defaults to false. * **api_version** (number) - Optional. The API version to use. If omitted, use version 1. * **binary** (boolean) - Optional. If true, and transactions and expand are both also true, return transaction information in binary format (hexadecimal string) instead of JSON format. * **command** (string) - Required. The name of the API method. Must be "ledger". * **expand** (boolean) - Optional. Provide full JSON-formatted information for transaction/account information instead of only hashes. Defaults to false. Ignored unless you request transactions, accounts, or both. * **full** (boolean) - Optional. If true, return full ledger information. * **id** (string | number) - Optional. A unique identifier for the request. * **ledger_hash** (string) - Optional. The hash of the ledger to retrieve. * **ledger_index** (LedgerIndex) - Optional. The index of the ledger to retrieve. Can be a number or one of the strings "current", "closed", or "validated". * **owner_funds** (boolean) - Optional. If true, return owner funds information. Defaults to false. * **queue** (boolean) - Optional. If true, return information about the transaction queue. * **transactions** (boolean) - Optional. If true, return information about transactions in the ledger. Defaults to false. * **type** (LedgerEntryFilter) - Optional. Filter for specific ledger entry types. * **[x: string]** (unknown) - Indexable property for any other string key. ``` -------------------------------- ### Build xrpl.js Project Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Run this command to build the project after installing dependencies. This step is often required before linting or testing. ```bash npm run build ``` -------------------------------- ### Set up and Run Integration Tests Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Commands to set up a standalone rippled Docker container and run integration tests. Ensure Docker is installed and running. ```bash npm install docker run \ --detach \ --publish 6006:6006 \ --volume "$PWD/.ci-config:/etc/xrpld/" \ --name xrpld-service \ rippleci/xrpld:develop --standalone npm run build npm run test:integration ``` -------------------------------- ### LedgerCurrentRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/LedgerCurrentRequest.html This example demonstrates how to construct a LedgerCurrentRequest object. It specifies the 'ledger_current' command. ```typescript const ledgerCurrent: LedgerCurrentRequest = { "command": "ledger_current" } ``` -------------------------------- ### ManifestRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/ManifestRequest.html Demonstrates how to construct a ManifestRequest object to retrieve manifest information for a specific validator public key. ```typescript const manifest: ManifestRequest = { "command": "manifest", "public_key": "nHUFE9prPXPrHcG3SkwP1UzAQbSphqyQkQK9ATXLZsfkezhhda3p"} ``` -------------------------------- ### Example LedgerEntryRequest Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/LedgerEntryRequest.html Demonstrates how to construct a LedgerEntryRequest object to fetch a specific ledger entry by its index and ledger index. ```typescript const ledgerEntry: LedgerEntryRequest = { command: "ledger_entry", ledger_index: 60102302, index: "7DB0788C020F02780A673DC74757F23823FA3014C1866E72CC4CD8B226CD6EF4" } ``` -------------------------------- ### Subscribe to XRPL Event Streams Source: https://github.com/xrplf/xrpl.js/blob/main/docs/classes/Client.html Sets up an event handler for subscription streams, specifically for forwarding streams. This example demonstrates subscribing to proposed transactions. ```javascript const { Client } = require('xrpl') const api = new Client('wss://s.altnet.rippletest.net:51233') api.on('transaction', (tx: TransactionStream) => { console.log("Received Transaction") console.log(tx) }) await api.connect() const response = await api.request({ command: 'subscribe', streams: ['transactions_proposed'] }) ``` -------------------------------- ### WebSocket Connection Source: https://github.com/xrplf/xrpl.js/blob/main/packages/isomorphic/README.md Import and instantiate a WebSocket client using the isomorphic WebSocket implementation. The example shows connecting to 'wss://localhost:8080'. ```typescript import WebSocket from '@xrplf/isomorphic/ws' const socket = new WebSocket('wss://localhost:8080') ``` -------------------------------- ### Calculate SHA-256 checksums Source: https://github.com/xrplf/xrpl.js/blob/main/packages/xrpl/HISTORY.md Example command to calculate SHA-256 checksums for the browser version of the ripple-lib release. ```bash % shasum -a 256 * 13021fe3efbdd59faf68597b0b18204b39847b285cca82f84c737e3d19922cc2 ripple-1.2.0-debug.js 0070225e731afd8c2c0a0976111ebf326c19a96ee1549368de9f016abdd53d2f ripple-1.2.0-min.js d440268397c03ad5137a3294e53a07b959ef93cd23b1990d6f82621c4776ba9f ripple-1.2.0.js ``` -------------------------------- ### Publish Beta Release with Lerna Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Publishes packages to npm using the 'beta' dist-tag, allowing installation via 'npm add xrpl@beta'. ```bash npx lerna publish from-package --dist-tag beta --yes ``` -------------------------------- ### Create a FeeRequest Object Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/FeeRequest.html This example shows how to create a FeeRequest object to query the current transaction fee requirements. The 'command' property must be set to 'fee'. ```typescript const feeRequest: FeeRequest = { command: 'fee'} ``` -------------------------------- ### Get ledger with delivered_amount field Source: https://github.com/xrplf/xrpl.js/blob/main/packages/xrpl/HISTORY.md Demonstrates how to retrieve ledger information including the 'delivered_amount' field, available in rippled 1.2.1+. ```javascript api.getLedger({includeTransactions: true, includeAllData: true, ledgerVersion: 17718771}).then(...) ``` ```javascript request('ledger', {...}).then(...) ``` -------------------------------- ### Derive XRP Ledger Address from Secret Source: https://github.com/xrplf/xrpl.js/blob/main/packages/xrpl/HISTORY.md This example demonstrates how to derive an XRP Ledger address from a secret. It involves first deriving the public key from the secret, and then deriving the address from the public key. ```javascript const address = api.deriveAddress(api.deriveKeypair(secret).publicKey) ``` -------------------------------- ### Generate Reference Documentation Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Run this command to generate the complete reference documentation locally. This updates the `docs/` directory. ```bash npm run docgen ``` -------------------------------- ### LedgerClosedRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/LedgerClosedRequest.html This example demonstrates how to construct a LedgerClosedRequest object. It specifies the command as 'ledger_closed'. ```typescript const ledgerClosed: LedgerClosedRequest = { "command": "ledger_closed" } ``` -------------------------------- ### Account Offers Paging with XRPL.js Source: https://github.com/xrplf/xrpl.js/blob/main/packages/xrpl/HISTORY.md Demonstrates how to use paging for account offers, including setting options like limit and ledger, and handling the marker for subsequent requests. ```javascript // A valid `ledger_index` or `ledger_hash` is required to provide a reliable result. // Results can change between ledger closes, so the provided ledger will be used as base. var options = { account: < rippleAccount >, limit: < Number between 10 and 400 >, ledger: < valid ledger_index or ledger_hash > } // The `marker` comes back in an account request if there are more results than are returned // in the current response. The amount of results per response are determined by the `limit`. if (marker) { options.marker = < marker >; } var request = remote.requestAccountOffers(options); ``` -------------------------------- ### NoRippleCheckRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/NoRippleCheckRequest.html An example of how to construct a NoRippleCheckRequest object. This request is used to check the No Ripple status for a given account. ```typescript const noRipple: NoRippleCheckRequest = { "id": 0, "command": "noripple_check", "account": "r9cZA1mLK5R5Am25ArfXFmqgNwjZgnfk59", "role": "gateway", "ledger_index": "current", "limit": 2, "transactions": true} ``` -------------------------------- ### Create a new Client instance Source: https://github.com/xrplf/xrpl.js/blob/main/docs/classes/Client.html Instantiate the Client class with the server URL. Options can be provided for client settings. This establishes a WebSocket connection. ```typescript import { Client } from "xrpl" const client = new Client('wss://s.altnet.rippletest.net:51233') ``` -------------------------------- ### Install Dependencies for React Native Source: https://github.com/xrplf/xrpl.js/blob/main/UNIQUE_SETUPS.md Install the necessary npm packages for using Xrpl.js with React Native. This includes the xrpl library itself, fast-text-encoding, and react-native-get-random-values. ```shell npm install xrpl \ fast-text-encoding \ react-native-get-random-values ``` -------------------------------- ### Run Unit Tests with npm Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Run this command to execute the unit tests for the project. ```bash npm test ``` -------------------------------- ### Build Code with npm Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Execute this command to build the project artifacts. ```bash npm build ``` -------------------------------- ### LedgerDataRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/LedgerDataRequest.html An example of a LedgerDataRequest object used to fetch ledger data. It specifies the command, a ledger hash, a limit for results, and requests binary output. ```typescript const ledgerData: LedgerDataRequest = { "id": 2, "ledger_hash": "842B57C1CC0613299A686D3E9F310EC0422C84D3911E5056389AA7E5808A93C8", "command": "ledger_data", "limit": 5, "binary": true } ``` -------------------------------- ### Run Single Integration Test with npm Source: https://github.com/xrplf/xrpl.js/wiki/Run-a-single-integration-test Use this command to execute a specific integration test file. Navigate to the 'packages/xrpl' directory first. ```bash cd packages/xrpl npm test:integration -- test/integration/integration.test.ts ``` -------------------------------- ### Wallet Constructor Source: https://github.com/xrplf/xrpl.js/blob/main/docs/classes/Wallet.html Creates a new Wallet instance with a public key, private key, and optional master address or seed. ```APIDOC ## constructor Wallet ### Description Creates a new Wallet. ### Parameters * **publicKey** (string) - The public key for the account. * **privateKey** (string) - The private key used for signing transactions for the account. * **opts** (object) - Optional. Options to initialize a Wallet. * **masterAddress** (string) - Optional. Include if a Wallet uses a Regular Key Pair. It must be the master address of the account. * **seed** (string) - Optional. The seed used to derive the account keys. ### Returns * [Wallet] ``` -------------------------------- ### Example RippledError Response Source: https://github.com/xrplf/xrpl.js/wiki/Handling-errors-from-rippled-requests This is an example of an error response from rippled when an account is not found. It shows the structure of the `RippledError` object, including the error code, message, and the original request details. ```json [RippledError(Account not found., { account: 'rQ3fNyLjbvcDaPNS4EAJY8aT9zR3uGk17c', error: 'actNotFound', error_code: 19, error_message: 'Account not found.', id: 1, ledger_current_index: 6468974, request: { account: 'rQ3fNyLjbvcDaPNS4EAJY8aT9zR3uGk17c', command: 'account_info', id: 1, ledger_index: 'current' }, status: 'error', type: 'response', validated: false })] ``` -------------------------------- ### LedgerRequest Example Source: https://github.com/xrplf/xrpl.js/blob/main/docs/interfaces/LedgerRequest.html An example of how to construct a LedgerRequest object to fetch validated ledger data. This specific request asks for the ledger index 'validated' and sets various boolean flags to false. ```typescript const ledger: LedgerRequest = { "id": 14, "command": "ledger", "ledger_index": "validated", "full": false, "accounts": false, "transactions": false, "expand": false, "owner_funds": false} ``` -------------------------------- ### Wallet.address Source: https://github.com/xrplf/xrpl.js/blob/main/docs/classes/Wallet.html Gets the classic address of the wallet. ```APIDOC ## Wallet.address ### Description Alias for wallet.classicAddress. Returns the wallet's classic address. ### Method Signature `get address(): string` ### Returns `string` - The wallet's classic address. ``` -------------------------------- ### ServerInfoRequest Source: https://github.com/xrplf/xrpl.js/blob/main/docs/modules.html Get information about the XRP Ledger server. ```APIDOC ## ServerInfoRequest ### Description Retrieves information about the XRP Ledger server, including its status, uptime, and network information. ### Method GET ### Endpoint /server/info ### Response #### Success Response (200) - **info** (object) - An object containing server information. - **ledger_current_index** (integer) - The index of the current ledger. - **state** (string) - The current state of the server (e.g., 'online', 'offline'). - **peers** (integer) - The number of connected peers. - **complete_ledgers** (string) - The range of ledgers the server has fully processed. - **network_id** (integer) - The ID of the network. #### Response Example ```json { "info": { "ledger_current_index": 12345678, "state": "online", "peers": 50, "complete_ledgers": "12345670-12345678", "network_id": 1 } } ``` ``` -------------------------------- ### Run Browser Tests (CLI) Source: https://github.com/xrplf/xrpl.js/blob/main/CONTRIBUTING.md Commands to set up the rippled Docker container and run browser tests from the command line. This is the method used for CI. ```bash npm run build # sets up the rippled standalone Docker container - you can skip this step if you already have it set up # (see the Integration Tests section above for a breakdown of this command) docker run \ --detach \ --publish 6006:6006 \ --volume "$PWD/.ci-config:/etc/xrpld/" \ --name xrpld-service \ rippleci/xrpld:develop --standalone npm run test:browser ``` -------------------------------- ### Client Constructor Source: https://github.com/xrplf/xrpl.js/blob/main/docs/classes/Client.html Initializes a new Client instance to establish a WebSocket connection to a rippled server. You can specify the server URL and optional client options. ```APIDOC ## constructor Client ### Description Creates a new Client with a websocket connection to a rippled server. ### Parameters #### Parameters - **server** (string) - URL of the server to connect to. - **options** ([ClientOptions](../interfaces/ClientOptions.html)) - Optional. Options for client settings. ### Returns [Client](Client.html) ### Example ```javascript import { Client } from "xrpl" const client = new Client('wss://s.altnet.rippletest.net:51233') ``` ``` -------------------------------- ### ServerStateRequest Source: https://github.com/xrplf/xrpl.js/blob/main/docs/modules.html Get the current state of the XRP Ledger server. ```APIDOC ## ServerStateRequest ### Description Retrieves the current state of the XRP Ledger server, including its connection status and synchronization progress. ### Method GET ### Endpoint /server/state ### Response #### Success Response (200) - **state** (string) - The current state of the server (e.g., 'online', 'offline'). - **ledger_current_index** (integer) - The index of the current ledger. #### Response Example ```json { "state": "online", "ledger_current_index": 12345678 } ``` ``` -------------------------------- ### getXChainClaimID Source: https://github.com/xrplf/xrpl.js/blob/main/docs/functions/getXChainClaimID.html Gets the XChainClaimID value from the metadata of an XChainCreateClaimID transaction. ```APIDOC ## Function getXChainClaimID ### Description Gets the XChainClaimID value from the metadata of an `XChainCreateClaimID` transaction. ### Parameters #### Path Parameters * **meta** (undefined | string | TransactionMetadata) - Required - Metadata from the response to submitting and waiting for an XChainCreateClaimID transaction or from a `tx` method call. ### Returns * undefined | string - The XChainClaimID for the minted NFT. ### Throws * if meta is not TransactionMetadata. ``` -------------------------------- ### Import an XRPL Account with Custom Entropy Source: https://github.com/xrplf/xrpl.js/blob/main/packages/secret-numbers/README.md Import an XRPL account using custom entropy by providing a Buffer of 16 bytes to the Account constructor. ```javascript const {Account} = require('@xrplf/secret-numbers') const entropy = Buffer.from('0123456789ABCDEF0123456789ABCDEF', 'hex') const account = new Account(entropy) ``` -------------------------------- ### Client.url Source: https://github.com/xrplf/xrpl.js/blob/main/docs/classes/Client.html Gets the URL of the rippled server that the client is currently connected to. ```APIDOC ## url ### Description Get the url that the client is connected to. ### Method get url(): string ### Returns string The URL of the server this client is connected to. ``` -------------------------------- ### Wallet Instance Methods Source: https://github.com/xrplf/xrpl.js/blob/main/docs/classes/Wallet.html Methods available on a Wallet instance for signing and verifying transactions, and retrieving account addresses. ```APIDOC ## sign ### Description Signs a JSON transaction. ### Parameters * **txJSON** (object) - The transaction in JSON format. ### Returns * string - The signed transaction in hex format. ## verifyTransaction ### Description Verifies a signed transaction. ### Parameters * **signedTransaction** (string) - The signed transaction in hex format. ### Returns * boolean - True if the transaction is valid, false otherwise. ## getXAddress ### Description Gets the X-address for the wallet. ### Parameters * **classicBaseAddress** (string) - The classic base address. * ** சேஞ்ச்set** (number) - The சேஞ்ச்set. ### Returns * string - The X-address. ```