# fabric-wallet-migration

> Migration from Hyperledger Fabric 1.4 to 2.0 wallets

Latest version **0.3.0** (published 2025-04-28) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install fabric-wallet-migration
pnpm add fabric-wallet-migration
yarn add fabric-wallet-migration
bun add fabric-wallet-migration
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2025-04-28 |
| First published | 2020-02-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 49.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Mark S. Lewis |
| Maintainers | bestbeforetoday |

## Links

- npm: https://www.npmjs.com/package/fabric-wallet-migration
- Repository: https://github.com/bestbeforetoday/fabric-wallet-migration
- Homepage: https://github.com/bestbeforetoday/fabric-wallet-migration#readme
- Issues: https://github.com/bestbeforetoday/fabric-wallet-migration/issues
- npm.io page: https://npm.io/package/fabric-wallet-migration

## Recent versions

- 0.3.0 (latest) — 2025-04-28
- 0.2.0 — 2020-08-14
- 0.1.0 — 2020-03-11
- 0.0.7 — 2020-03-02
- 0.0.6 — 2020-02-29
- 0.0.5 — 2020-02-29
- 0.0.4 — 2020-02-28
- 0.0.3 — 2020-02-25
- 0.0.2 — 2020-02-24
- 0.0.1 — 2020-02-24

## README

This module allows access to data stored in the wallets used by legacy Hyperledger Fabric client SDKs.

For users of the Fabric version 2 Node SDK, a custom WalletStore implementation that allows a Hyperledger Fabric version 1.4 wallet to be accessed using the version 2.x SDKs Wallet API. This can be used to migrate a version 1.4 wallet to the version 2 wallet format.

For users of the [Fabric Gateway client API](https://hyperledger.github.io/fabric-gateway/), a custom Wallet API implementation is provided that allows data to be directly accessed from legacy Node SDK wallets in a form suitable for use with the Fabric Gateway client API.

## Example migration from v1.4 to v2 wallet format

```TypeScript
import * as WalletMigration from "fabric-wallet-migration";
import { Wallet, Wallets } from "fabric-network"; // fabric-network v2

async function migrateWallet(oldWalletDirectory: string, newWalletDirectory: string): Promise<void> {
    const walletStore = await WalletMigration.newFileSystemWalletStoreV1(oldWalletDirectory);
    const oldWallet = new Wallet(walletStore);

    const newWallet = await Wallets.newFileSystemWallet(newWalletDirectory);

    const identityLabels = await oldWallet.list();
    for (const label of identityLabels) {
        const identity = await oldWallet.get(label);
        if (identity) {
        await newWallet.put(label, identity);
        }
    }
}
```

## Example use of v2 wallet with Fabric Gateway client API

```TypeScript
import * as grpc from "@grpc/grpc-js";
import { wallets } from "fabric-wallet-migration";
import { connect, hash, signers } from "@hyperledger/fabric-gateway";

async function connectGateway(client: grpc.Client): Promise<Gateway> {
    const wallet = await wallets.newFileSystemWallet("path/to/wallet");
    const entry = await wallet.get("myIdLabel");
    if (!entry) {
        throw new Error("Failed to read wallet entry");
    }

    const identity = entry.identity;
    const signer = signers.newPrivateKeySigner(entry.privateKey);

    return connect({
        identity,
        signer,
        hash: hash.sha256,
        client,
    });
}
```

---
_Source: https://npm.io/package/fabric-wallet-migration · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
