# @tronweb3/tronwallet-adapter-ledger

> Wallet adapter for the Ledger wallet.

Latest version **1.1.15** (published 2026-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tronweb3/tronwallet-adapter-ledger
pnpm add @tronweb3/tronwallet-adapter-ledger
yarn add @tronweb3/tronwallet-adapter-ledger
bun add @tronweb3/tronwallet-adapter-ledger
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.15 |
| Published | 2026-08-07 |
| First published | 2022-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16 |
| Dependencies | 9 |
| Unpacked size | 5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 80 |
| Author | tronweb3 |
| Maintainers | troncore, tronwallet-adapter |
| Keywords | TRON, TronWeb, Ledger |

## Links

- npm: https://www.npmjs.com/package/@tronweb3/tronwallet-adapter-ledger
- Repository: https://github.com/tronweb3/tronwallet-adapter
- Homepage: https://github.com/tronweb3/tronwallet-adapter#readme
- Issues: https://github.com/tronweb3/tronwallet-adapter/issues
- npm.io page: https://npm.io/package/@tronweb3/tronwallet-adapter-ledger

## Dependencies (9)

- [buffer](https://npm.io/package/buffer.md) 6.0.3
- [preact](https://npm.io/package/preact.md) 10.23.0
- [tronweb](https://npm.io/package/tronweb.md) 6.4.0
- [eventemitter3](https://npm.io/package/eventemitter3.md) 5.0.4
- [@ledgerhq/hw-app-trx](https://npm.io/package/@ledgerhq/hw-app-trx.md) 6.29.2
- [@ledgerhq/hw-transport](https://npm.io/package/@ledgerhq/hw-transport.md) 6.27.1
- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) 5.17.0
- [@ledgerhq/hw-transport-webhid](https://npm.io/package/@ledgerhq/hw-transport-webhid.md) 6.27.1
- [@tronweb3/tronwallet-abstract-adapter](https://npm.io/package/@tronweb3/tronwallet-abstract-adapter.md) 1.2.0

## Recent versions

- 1.1.15 (latest) — 2026-08-07
- 1.1.14 — 2026-07-10
- 1.1.13 — 2026-03-25
- 1.1.12 — 2026-01-26
- 1.1.11 — 2025-03-25
- 1.1.10 — 2024-10-25
- 1.1.9 — 2024-09-24
- 1.1.8 — 2023-11-15
- 1.1.7 — 2023-06-20
- 1.1.6 — 2023-05-05
- 1.1.5 — 2023-03-23
- 1.1.4 — 2023-03-01
- 1.1.3 — 2023-02-21
- 1.1.2 — 2023-02-20
- 1.1.1 — 2023-02-06
- … 1 more at https://npm.io/package/@tronweb3/tronwallet-adapter-ledger/versions

## README

# `@tronweb3/tronwallet-adapter-ledger`

This package provides an adapter for the Ledger Wallet.

## Demo

```typescript
import { LedgerAdapter } from '@tronweb3/tronwallet-adapter-ledger';
import TronWeb from 'tronweb';
const tronWeb = new TronWeb({
    fullHost: 'https://api.trongrid.io',
    headers: { 'TRON-PRO-API-KEY': 'your api key' },
});

const adapter = new LedgerAdapter({
    // Initial total accounts to get once connection is created
    accountNumber: 5,
    // Custom derivate path for address
    getDerivationPath(index) {
        return `44'/195'/0'/0/${index}`;
    },
});
// connect
await adapter.connect();

// then you can get address
console.log(adapter.address);

// create a send TRX transaction
const unSignedTransaction = await tronWeb.transactionBuilder.sendTrx(targetAddress, 100, adapter.address);
// using adapter to sign the transaction
const signedTransaction = await adapter.signTransaction(unSignedTransaction);
// broadcast the transaction
await tronWeb.trx.sendRawTransaction(signedTransaction);
```

## Documentation

### API

-   `Constructor(config: LedgerAdapterConfig)`

    ```typescript
    interface LedgerAdapterConfig {
        /**
         * Set if open Wallet's website when wallet is not installed.
         * Default is true.
         */
        openUrlWhenWalletNotFound?: boolean;
        /**
         * Initial total accounts to get once connection is created, default is 1
         */
        accountNumber?: number;

        /**
         * Hook function to call before connecting to ledger and geting accounts.
         * By default, a modal will popup to reminder user to prepare the ledger and enter Tron app.
         * You can specify a function to disable this modal.
         */
        beforeConnect?: () => Promise<unknown> | unknown;

        /**
         * Hook function to call after connecting to ledger and geting initial accounts.
         * The function should return the selected account including the index of account.
         * Following operations such as `signMessage` will use the selected account.
         */
        selectAccount?: (params: { accounts: Account[]; ledgerUtils: LedgerUtils }) => Promise<Account>;

        /**
         * Function to get derivate BIP44 path by index.
         * Default is `44'/195'/${index}'/0/0`
         */
        getDerivationPath?: (index: number) => string;
    }
    interface Account {
        /**
         * The index to get BIP44 path.
         */
        index: number;
        /**
         * The BIP44 path to derivate address.
         */
        path: string;
        /**
         * The derivated address.
         */
        address: string;
    }
    interface LedgerUtils {
        /**
         * Get accounts from ledger by index. `from` is included and `to` is excluded.
         * User can use the function to load more accounts.
         */
        getAccounts: (from: number, to: number) => Promise<Account[]>;
        /**
         * Request to get an address with specified index using getDerivationPath(index) to get BIP44 path.
         * If `display` is true, will request user to approve on ledger.
         * The promise will resove if user approve and reject if user cancel the operation.
         */
        getAddress: (index: number, display: boolean) => Promise<{ publicKey: string; address: string }>;
    }
    ```

-   Property: `ledgerUtils`
    `ledgerUtils` on LedgerAdapter is used to get useful functions to interact with Ledger directly. `ledgerUtils` is defined as last section.

    -   `getAccounts(from: number, to: number)` is a wrapped function to get multiple accounts by index range from ledger.
        For example:

        ```typescript
        const adapter = new LedgerAdapter();
        // get 5 accounts from ledger
        const accounts = await adapter.ledgerUtils.getAcccounts(0, 5);
        // [{ address: string, index: 0, path: "44'/195'/0'/0/0" }, ...]
        ```

    -   `getAddress: (index: number, display: boolean)` is a raw function to request an address from ledger.
        If `display` is true, will request user to approve on ledger.
        For example, following code will request user approve on Ledger to confirm to connect their ledger.

        ```typescript
        const adapter = new LedgerAdapter();
        const result = await adapter.ledgerUtils.getAddress(0, true);
        // { address: 'some address', publicKey: 'publicKey for address' }
        ```

### Methods

-   `signTransaction(transaction, options?)`

    Sign a transaction via the Ledger wallet.

    -   `transaction` - `Transaction` to sign.
    -   `options` - optional object:
        -   `fallbackToHashSign?: boolean` - If the ledger returns `Too many bytes to encode`, whether to retry with `signTransactionHash`. Defaults to `true`.

    ```ts
    const signedTransaction = await adapter.signTransaction(unSignedTransaction);
    // or disable fallback:
    const signedTx = await adapter.signTransaction(unSignedTransaction, { fallbackToHashSign: false });
    ```

-   `signTransactionHash(transaction)`

    Sign the transaction by its hash. This avoids encoding the full transaction payload and is useful when the transaction is too large for the Ledger to encode.

    -   `transaction` - `Transaction` to sign.

    ```ts
    const signedTransaction = await adapter.signTransactionHash(unSignedTransaction);
    ```

### Caveats

-   `multiSign()` and `switchChain(chainId: string)` are not supported.
-   `signMessage` only supports strings with a buffer length less than 226.

For more information about tronwallet adapters, please refer to [`@tronweb3/tronwallet-adapters`](https://github.com/tronweb3/tronwallet-adapter/tree/main/packages/adapters/adapters)

---
_Source: https://npm.io/package/@tronweb3/tronwallet-adapter-ledger · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
