@avalabs/hw-app-avalanche

中文文档
2.1.0发布于 2026/09/16Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2484

Node API for Avalanche App (Ledger Nano S/X/S+)

原始使用文档
文档目录3 节
  1. Usage
  2. Notes
  3. Release

@zondax/ledger-avalanche-app

License npm version

This package provides a basic client library to communicate with the Avalanche App running in a Ledger Nano S/X

We recommend using the npmjs package in order to receive updates/fixes.

Usage

Connect through Ledger's Device Management Kit and hand the SDK a DMKTransport (from @zondax/ledger-js). The X/P-chain methods only need the transport; the C-Chain (EVM) methods also need the DMK session behind it, because they are driven by @ledgerhq/device-signer-kit-ethereum:

import { DeviceManagementKitBuilder } from "@ledgerhq/device-management-kit";
import { DMKTransport } from "@zondax/ledger-js";
import AvalancheApp from "@zondax/ledger-avalanche-app";

const dmk = new DeviceManagementKitBuilder()
  .addTransport(/* web-hid, node-hid... */)
  .build();
const sessionId = await dmk.connect({
  device,
  sessionRefresherOptions: { isRefresherDisabled: true },
});

const app = new AvalancheApp(new DMKTransport(dmk, sessionId), {
  dmk,
  sessionId,
});

await app.getAddressAndPubKey("m/44'/9000'/0'/0/0", true, "avax"); // X/P chain
await app.signEVMTransaction("m/44'/60'/0'/0/0", rawTxHex); // C chain
await app.signPersonalMessage("m/44'/60'/0'/0/0", messageHex); // C chain, EIP-191

signPersonalMessage is the exception on the C-Chain: it sends its APDU through the transport, so it works without the DMK session. Pass the message bytes as hex; the app adds the \x19Ethereum Signed Message:\n prefix itself. It takes the same arguments and returns the same { v, r, s } as hw-app-eth's signPersonalMessage, with two differences:

  • The path must have 3 to 5 levels (e.g. m/44'/60'/0'/0/0); hw-app-eth accepted any depth.
  • An empty message is signed rather than rejected.

The SDK does not check message size before sending. The app rejects a message that is too large only after it has been sent in full.

Any object with a hw-transport-style send(cla, ins, p1, p2, data?, statusList?) still works as the first argument, but the deprecated @ledgerhq/hw-transport packages stop working against Ledger's services in September 2026.

Notes

Use yarn install to avoid issues.

Release

Push to main branch and a release will be automatic. Release versions are based on commitizen commit messages.

版本与发布记录

@avalabs/hw-app-avalanche 共发布 28 个版本,首次发布于 2022/10/11;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.0latest2026/09/161 个月前
2.0.02026/09/111 个月前
1.1.32026/08/122 个月前
1.1.12025/10/011.1 年前
1.1.02025/08/291.2 年前
1.0.22025/03/041.7 年前

其他发布通道:alpha → 0.1.0。

关于 @avalabs/hw-app-avalanche 的常见问题

@avalabs/hw-app-avalanche 是什么?

Node API for Avalanche App (Ledger Nano S/X/S+)

如何安装 @avalabs/hw-app-avalanche?

在项目目录运行 npm install @avalabs/hw-app-avalanche,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:rxjs(7.8.2)、@ledgerhq/device-management-kit(^1.9.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@avalabs/hw-app-avalanche 支持 TypeScript 吗?

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

@avalabs/hw-app-avalanche 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@avalabs/hw-app-avalanche 可以商用吗?

@avalabs/hw-app-avalanche 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@avalabs/hw-app-avalanche 的下载量有多少?

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

@avalabs/hw-app-avalanche 还在维护吗?

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