@exodus/hw-ledger

中文文档
4.0.2发布于 2026/10/01MITTypeScriptES Module近 30 天下载 1.1万

The ledger module

原始使用文档
文档目录9 节
  1. Install
  2. Usage
  3. API Side
  4. UI Side
  5. Architecture
  6. Development
  7. Installing Ledger Emulator (Recommended)
  8. MacOS launch issues:
  9. Install udev rules for real devices (Linux only)

@exodus/hw-ledger

This Exodus SDK feature handles all hardware wallet actions that are specific to Ledger and implements and interface which is abstracted for all hardware wallet devices.

Install

pnpm add @exodus/hw-ledger

Usage

This feature is designed to be used together with @exodus/headless. See using the sdk.

API Side

import hardwareWalletLedger from '@exodus/hw-ledger'
import Transport from '@ledgerhq/hw-transport-node-speculos'

// Add a transportsFactories adapter to hold
// the factory funcctions that are specific to the platform.
const transportsFactories = {
  tcp: Transport,
}

// Create IoC
const ioc = createIocContainer({ adapters: { transportsFactories }, config, debug })
ioc.use(hardwareWalletLedger({ bluetoothScannerTimeout: 60 * 1000 }))

// Retrieve the ledgerDiscovery through dependency injection

const ledgerDescriptors = await ledgerDiscovery.list()
// [
//   {
//       manufacturer: 'ledger',
//       transportType: 'tcp',
//       get: function () => { ... }
//   }
// ]

let ledgerDevice = null
try {
  ledgerDevice = await ledgerDescriptors[0].get()
} catch (err) {
  // Instantiating the device may fail, deal with this.
  // e.g unplugged, udev issues, no networking
  logger.error(`Unable to connect to device.`, err)
}

if (ledgerDevice) {
  const address = await ledgerDevice.getAddress({
    assetName: 'bitcoin',
    derivationPath: `m/86'/0'/0'/0/0`,
  })
  logger.log(`bitcoin address is ${address}`)
  // bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr
}

UI Side

This package is not ment to be used directly through the UI. See using the @exodus/hardware-wallets for UI usage.

Architecture

The discovery provides descriptors which can be used to retrieve device handles.

flowchart LR
    AA[TransportFactory] --> A
    A[LedgerDiscovery] -->|"list()"| B(HardwareWalletDescriptor)
    B --> |"get()"| C(LedgerDevice)
    C --> |"getAddress()"| D{Pick by \nasset}
    D -->|bitcoin| E[BitcoinHandlers]
    D -->|ethereum| F[EthereumHandlers]
    D -->|solana| G[SolanaHandlers]

Development

If you're on Linux then it's highly likely that you'll want to setup your udev rules.

Clone the speculos repository & change your current working directory

git clone https://github.com/LedgerHQ/speculos.git --branch v0.3.5 --single-branch --depth 1 speculos-0.3.5
cd speculos-0.3.5

Get the Docker image

docker image pull ghcr.io/ledgerhq/speculos:sha-8241dc2 # v0.3.5
docker image tag ghcr.io/ledgerhq/speculos:sha-8241dc2 speculos

Get the Docker image for ARM (M1/M2)

docker image build -t ghcr.io/ledgerhq/speculos-builder:latest -f build.Dockerfile .
docker image build -t speculos:latest .

Launch the emulator while within the speculos directory

docker container run --rm -it -v "$(pwd)"/apps:/speculos/apps:ro \
-p 127.0.0.1:4000:4000 -p 127.0.0.1:40000:40000 speculos \
--display headless --api-port 4000 --apdu-port 40000 --seed "secret" --model nanos --sdk 2.0 ./apps/btc.elf

Now visit http://127.0.0.1:4000 to interact with the emulator.

MacOS launch issues:

  • port XXXX is already in use: re-map any available host port (doc)

Install udev rules for real devices (Linux only)

If you want to talk with real devices then you might require setting up udev rules.

sudo ./scripts/setup_udev.sh

版本与发布记录

@exodus/hw-ledger 共发布 60 个版本,首次发布于 2023/07/05;过去 12 个月发布了 9 个版本。

版本发布日期距今
4.0.2latest2026/10/011 个月前
4.0.12026/06/304 个月前
4.0.02026/06/115 个月前
3.9.22026/05/295 个月前
3.9.12026/04/166 个月前
3.9.02026/01/229 个月前

关于 @exodus/hw-ledger 的常见问题

@exodus/hw-ledger 是什么?

The ledger module

如何安装 @exodus/hw-ledger?

在项目目录运行 npm install @exodus/hw-ledger,或使用 pnpm add / yarn add / bun add。

@exodus/hw-ledger 支持 TypeScript 吗?

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

@exodus/hw-ledger 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@exodus/hw-ledger 可以商用吗?

@exodus/hw-ledger 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@exodus/hw-ledger 的下载量有多少?

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

@exodus/hw-ledger 还在维护吗?

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