@bithomp/xrpl-api

中文文档
3.8.23发布于 2026/11/05GPL-3.0TypeScriptCommonJS近 30 天下载 2086

用于与 XRP Ledger 交互的 Bithomp JavaScript/ TypeScript 库

中文使用文档
文档目录5 节
  1. 获取账户信息
  2. 创建验证器列表 第 1 版
  3. 创建验证器列表 第 2 版
  4. 解码 NFTokenID
  5. 编码 NFTokenID

@Bithomp/xrpl-api (英语)

用于与 XRP Ledger 交互的 Bithomp JavaScript/ TypeScript 库 图书馆被设计为XRP Ledger的单一访问点. 它使用多条连接到XRP Ledger,并为请求选择了最好的一条. 如果连接丢失,库会自动重联.

库还支持创建验证器列表.

在现有项目中(与 package.json),安装 @bithomp/xrpl-api数字 :

# install package
$ npm install --save @bithomp/xrpl-api

使用实例

获取账户信息

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();

创建验证器列表 第 1 版

设置连接,则需要从分类账中获取验证器的细节.

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();

创建验证器列表 第 2 版

设置连接,则需要从分类账中获取验证器的细节.

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, [publishBlob, 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();

解码 NFTokenID

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,
// }

编码 NFTokenID

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"

版本与发布记录

@bithomp/xrpl-api 共发布 200 个版本,首次发布于 2023/06/23;过去 12 个月发布了 57 个版本。

版本发布日期距今
3.8.23latest2026/11/053 天前
3.8.222026/10/2018 天前
3.8.212026/10/1919 天前
3.8.202026/10/1425 天前
3.8.192026/10/1325 天前
3.8.182026/10/1326 天前

关于 @bithomp/xrpl-api 的常见问题

@bithomp/xrpl-api 是什么?

用于与 XRP Ledger 交互的 Bithomp JavaScript/ TypeScript 库

如何安装 @bithomp/xrpl-api?

在项目目录运行 npm install @bithomp/xrpl-api,或使用 pnpm add / yarn add / bun add。

@bithomp/xrpl-api 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bithomp/xrpl-api 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@bithomp/xrpl-api 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bithomp/xrpl-api 可以商用吗?

@bithomp/xrpl-api 使用 GPL-3.0 许可。强 Copyleft:分发包含该代码的软件时,整个作品需以 GPL-3.0 兼容许可开源,并附带专利与反锁定条款。仅内部使用不触发此义务。以上为概括,不构成法律意见,请以许可原文为准。

@bithomp/xrpl-api 的下载量有多少?

根据 npm 官方下载统计,@bithomp/xrpl-api 在 2026/10/08 – 2026/11/06 这 30 天内被下载 2,086 次,日均约 70 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bithomp/xrpl-api 还在维护吗?

最新版本 3.8.23 发布于 2026/11/05(3 天前);至今共发布 200 个版本,其中过去 12 个月发布了 57 个;首次发布于 2023/06/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。