@dfinity/ledger-wallet-identity
v0.1.0
Published
Ledger hardware wallet identity for the Internet Computer
Readme
@dfinity/ledger-wallet-identity
A Ledger hardware wallet identity for the Internet Computer.
This package provides LedgerWalletIdentity, an implementation of the SignIdentity interface from @icp-sdk/core that signs transactions using a Ledger hardware wallet. It supports both browser (WebHID) and Node.js (node-hid) environments.
Installation
npm install @dfinity/ledger-wallet-identityIn Node.js environments, you also need node-hid:
npm install node-hidUsage
By default, LedgerWalletIdentity.create() uses the WebHID transport (browser):
import { LedgerWalletIdentity } from "@dfinity/ledger-wallet-identity";
import { HttpAgent } from "@icp-sdk/core/agent";
const identity = await LedgerWalletIdentity.create();
const agent = new HttpAgent({ identity });Note:
@zondax/ledger-icp(a transitive dependency) uses Node.jsBuffer. Browser bundlers will need abufferpolyfill (e.g. thebufferpackage).
Node.js
Import from @dfinity/ledger-wallet-identity/node and pass createNodeHidTransport:
import {
LedgerWalletIdentity,
createNodeHidTransport,
} from "@dfinity/ledger-wallet-identity/node";
const identity = await LedgerWalletIdentity.create({
transportFactory: createNodeHidTransport,
});Custom derivation path
const identity = await LedgerWalletIdentity.create({
derivePath: "m/44'/223'/0'/0/1",
});ICRC-21 consent message signing
LedgerWalletIdentity supports ICRC-21 consent message signing via flagUpcomingIcrc21(). Use it with @dfinity/icrc21-agent for transparent consent message flows:
import { LedgerWalletIdentity } from "@dfinity/ledger-wallet-identity";
import { Icrc21Agent } from "@dfinity/icrc21-agent";
const identity = await LedgerWalletIdentity.create();
const agent = await Icrc21Agent.create(identity);License
Apache-2.0
