### Install @bithomp/xrpl-api Package Source: https://github.com/bithomp/xrpl-api/blob/master/README.md This snippet shows how to install the @bithomp/xrpl-api package using npm. It's a prerequisite for using the library in an existing project with a package.json file. ```Shell # install package $ npm install --save @bithomp/xrpl-api ``` -------------------------------- ### Get XRP Ledger Account Info Source: https://github.com/bithomp/xrpl-api/blob/master/README.md This JavaScript example demonstrates how to retrieve account information from the XRP Ledger using the Bithomp XRPL API. It involves setting up multiple connections to the ledger, connecting to them, sending a request for account info, and finally disconnecting. Ensure you have the `@bithomp/xrpl-api` package installed. ```JS const BithompXRPL = require("@bithomp/xrpl-api"); // setup connection const config = [ { "url": "wss://xrplcluster.com", "type": "regular,history,gateway_balances,last_close,manifest,payment,submit", "connectionTimeout": 10000 }, { "url": "wss://s1.ripple.com", "type": "regular,history,payment,submit", "connectionTimeout": 10000 }, { "url": "wss://s2.ripple.com", "type": "regular,history,payment,submit", "connectionTimeout": 10000 }, { "url": "wss://s2-clio.ripple.com", "type": "clio,account_objects", "connectionTimeout": 10000 } ]; // Global setup for all connections, if you have multiple connections, like in example, the library will use them by type and(or) by better response time BithompXRPL.Client.setup(config); // connect to all servers await BithompXRPL.Client.connect(); // send request const accountInfo = await BithompXRPL.Client.getAccountInfo("rsuUjfWxrACCAwGQDsNeZUhpzXf1n1NK5Z"); // when complete, disconnect BithompXRPL.Client.disconnect(); ``` -------------------------------- ### Create XRP Ledger Validator List v1 Source: https://github.com/bithomp/xrpl-api/blob/master/README.md This JavaScript example shows how to create a version 1 validator list for the XRP Ledger using the Bithomp XRPL API. It requires setting up a connection to fetch validator details, defining signing and validation keys, and providing a list of validator public addresses, sequence number, and expiration time. The output includes a signed validator list blob and manifest. ```JS const BithompXRPL = require("@bithomp/xrpl-api"); // setup connection const config = [ { // this connection will be used to get validators details from the ledger, use web socket with connection to network you are building list for (mainnet, testnet, devnet, etc.) "url": "wss://xrplcluster.com", "connectionTimeout": 10000 } ]; BithompXRPL.Client.setup(config); // connect await BithompXRPL.Client.connect(); // validator(master) secrets, should not belong to any validators keys. // can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used, // can ne generated with BithompXRPL.Validator.generateSecrets() or by generateSeed from ripple-keypairs const vk = { privateKey: "p__________________________", publicKey: "ED________________________________", }; // signing secrets, should not belong to any validators keys and should be different from vk. // can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used, // can ne generated with BithompXRPL.Validator.generateSecrets() or by generateSeed from ripple-keypairs const sk = { privateKey: "p__________________________", publicKey: "ED_______________________________", }; // validator list, public addresses, they have to be available on the ledger // for accessing to manifest data (it will be stored in a blob), // the address should start with `n` const validators = ["nHB8QMKGt9VB4Vg71VszjBVQnDW3v3QudM4DwFaJfy96bj4Pv9fA"]; const sequence = 1; // sequence number const expiration = 1696508603; // in unixtime (seconds) const vl = await BithompXRPL.Client.createVL(vk, sk, sequence, expiration, validators); // vl will contain the signed validator list with // { // "blob": "...", // "manifest": "...", // signed with vk.privateKey and sk.privateKey // "signature": "...", // signed with sk.privateKey // "version": 1, // "public_key": "..." // vk.publicKey // } // NOTE: to be able rippled to accept the validator list, you have to add validator(master) public key // to [validator_list_keys] in rippled.cfg // disconnect BithompXRPL.Client.disconnect(); ``` -------------------------------- ### Get Account Info Source: https://github.com/bithomp/xrpl-api/blob/master/README.md Retrieves information about a specific XRP Ledger account. ```APIDOC ## GET /account_info ### Description Retrieves detailed information about an XRP Ledger account, including balances, transaction counts, and other relevant data. ### Method GET ### Endpoint /account_info ### Parameters #### Query Parameters - **account** (string) - Required - The XRP Ledger account address for which to retrieve information. ### Request Example ```json { "method": "getAccountInfo", "params": [{"account": "rsuUjfWxrACCAwGQDsNeZUhpzXf1n1NK5Z"}] } ``` ### Response #### Success Response (200) - **account_data** (object) - Contains the account's data, including balance, sequence, owner_count, etc. - **ledger_hash** (string) - The hash of the ledger version used for the response. - **ledger_index** (number) - The ledger index used for the response. #### Response Example ```json { "account_data": { "Account": "rsuUjfWxrACCAwGQDsNeZUhpzXf1n1NK5Z", "Balance": "10000000", "Sequence": 12345, "OwnerCount": 5 }, "ledger_hash": "SOME_LEDGER_HASH", "ledger_index": 12345678 } ``` ``` -------------------------------- ### Create Validator List v2 with XRPL API Source: https://github.com/bithomp/xrpl-api/blob/master/README.md This snippet demonstrates how to set up a connection to the XRPL network and create a signed validator list version 2. It requires connection configuration, validator master and signing secrets, and public validator list details including sequences and expiration times. The generated validator list includes blobs and manifests signed with the provided keys. ```javascript const BithompXRPL = require("@bithomp/xrpl-api"); // setup connection const config = [ { // this connection will be used to get validators details from the ledger, use web socket with connection to network you are building list for (mainnet, testnet, devnet, etc.) "url": "wss://xrplcluster.com", "connectionTimeout": 10000 } ]; BithompXRPL.Client.setup(config); // connect await BithompXRPL.Client.connect(); // validator(master) secrets, should not belong to any validators keys. // can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used, // can ne generated with BithompXRPL.Validator.generateSecrets() or by generateSeed from ripple-keypairs const vk = { privateKey: "p__________________________", publicKey: "ED________________________________", }; // signing secrets, should not belong to any validators keys and should be different from vk. // can be any ed25519 (publicKey starts on `ED`) or secp256k1 could be used, // can ne generated with BithompXRPL.Validator.generateSecrets() or by generateSeed from ripple-keypairs const sk = { privateKey: "p__________________________", publicKey: "ED_______________________________", }; // validator list, public addresses, they have to be available on the ledger // for accessing to manifest data (it will be stored in a blob), // the address should start with `n` const publishBlobCurrent = { sequence: 1, // sequence number expiration: 1696508603, validatorsPublicKeys: ["nHUFE9prPXPrHcG3SkwP1UzAQbSphqyQkQK9ATXLZsfkezhhda3p"], }; const publishBlobFuture = { sequence: 2, // sequence number effective: 1696508603, // optional in unixtime (seconds) expiration: 1723620871, // in unixtime (seconds) validatorsPublicKeys: ["nHB8QMKGt9VB4Vg71VszjBVQnDW3v3QudM4DwFaJfy96bj4Pv9fA"], }; const vl = await BithompXRPL.Client.createVLv2(vk, sk, [publishBlobCurrent, publishBlobFuture]); // vl will contain the signed validator list with // { // "blobs_v2": "...", // "manifest": "...", // signed with vk.privateKey and sk.privateKey // "version": 2, // "public_key": "..." // vk.publicKey // } // NOTE: to be able rippled to accept the validator list, you have to add validator(master) public key // to [validator_list_keys] in rippled.cfg // disconnect BithompXRPL.Client.disconnect(); ``` -------------------------------- ### Create Validator List Source: https://github.com/bithomp/xrpl-api/blob/master/README.md Creates a signed validator list for use with rippled nodes. ```APIDOC ## POST /create_validator_list ### Description Generates a signed validator list object, which can be submitted to a rippled node. This requires specific keys and validator addresses. ### Method POST ### Endpoint /create_validator_list ### Parameters #### Request Body - **vk** (object) - Required - The validator master public key object. Must contain `privateKey` and `publicKey`. - **privateKey** (string) - Required - The private key for the validator master. - **publicKey** (string) - Required - The public key for the validator master. - **sk** (object) - Required - The signing secrets object. Must contain `privateKey` and `publicKey`. - **privateKey** (string) - Required - The private key for signing. - **publicKey** (string) - Required - The public key for signing. - **sequence** (number) - Required - The sequence number for the validator list. - **expiration** (number) - Required - The expiration time of the validator list in Unix timestamp (seconds). - **validators** (array) - Required - An array of public addresses of the validators to include in the list. ### Request Example ```json { "vk": { "privateKey": "p__________________________", "publicKey": "ED________________________________" }, "sk": { "privateKey": "p__________________________", "publicKey": "ED_______________________________" }, "sequence": 1, "expiration": 1696508603, "validators": ["nHB8QMKGt9VB4Vg71VszjBVQnDW3v3QudM4DwFaJfy96bj4Pv9fA"] } ``` ### Response #### Success Response (200) - **blob** (string) - The signed validator list data. - **manifest** (string) - The signed manifest of the validator list. - **signature** (string) - The signature for the validator list, signed with `sk.privateKey`. - **version** (number) - The version of the validator list format. - **public_key** (string) - The public key of the validator master (`vk.publicKey`). #### Response Example ```json { "blob": "...", "manifest": "...", "signature": "...", "version": 1, "public_key": "ED________________________________" } ``` ``` -------------------------------- ### Encode NFTokenID with XRPL API Source: https://github.com/bithomp/xrpl-api/blob/master/README.md This JavaScript snippet demonstrates how to encode NFTokenID components into a valid NFTokenID string. It takes flags, transfer fee, issuer address, NFTokenTaxon, and sequence number as input. This function is useful for testing, validation, or predicting NFTokenIDs before minting. ```javascript const BithompXRPL = require("@bithomp/xrpl-api"); const flags = 11; const transferFee = 3140; const issuer = "rNCFjv8Ek5oDrNiMJ3pw6eLLFtMjZLJnf2"; const nftokenTaxon = 146999694; const sequence = 3429; // NOTE: This function is not minting NFTokenID, it is just encoding it from the data provided, // can be used if you want to test something, check if the NFTokenID is valid, or predict the NFTokenID before minting const result = BithompXRPL.Models.buildNFTokenID(flags, transferFee, issuer, nftokenTaxon, sequence); // result will contain NFTokenID // "000B0C4495F14B0E44F78A264E41713C64B5F89242540EE2BC8B858E00000D65" ``` -------------------------------- ### Decode NFTokenID with XRPL API Source: https://github.com/bithomp/xrpl-api/blob/master/README.md This JavaScript snippet shows how to decode an XRPL NFTokenID into its constituent parts. It takes a hexadecimal NFTokenID string as input and returns an object containing flags, transfer fee, issuer address, NFTokenTaxon, and sequence number. ```javascript const BithompXRPL = require("@bithomp/xrpl-api"); const nftokenID = "000861A8A7C507A12088BF6A6BB62BAFEE9CDAABA2961DB216E5DA9C00000001"; const decoded = BithompXRPL.Models.parseNFTokenID(nftokenID); // decoded will contain // { // "NFTokenID: "000861A8A7C507A12088BF6A6BB62BAFEE9CDAABA2961DB216E5DA9C00000001", // "Flags": 8, // "TransferFee": 25000, // "Issuer": "rGJn1uZxDX4ksxRPYuj2smP7ZshdwjeSTG", // "NFTokenTaxon": 0, // "Sequence": 1, // } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.