Skip to main content
Provides Ledger hardware wallet support for Amino transaction signing. Implements the OfflineAminoSigner interface, making it compatible with SigningStargateClient and SigningCosmWasmClient.
npm install @cosmjs/ledger-amino
Requires the Cosmos app installed on your Ledger device and a transport library like @ledgerhq/hw-transport-webusb (browser) or @ledgerhq/hw-transport-node-hid (Node.js).

LedgerSigner

Implements OfflineAminoSigner using a Ledger hardware wallet.
MethodParametersReturns
constructortransport: Transport, options?: LedgerConnectorOptionsLedgerSigner
getAccountsPromise<readonly AccountData[]>
signAminosignerAddress: string, signDoc: StdSignDocPromise<AminoSignResponse>
showAddresspath?: HdPathPromise<AddressAndPubkey> (asks the device to display an address for user confirmation)

Options

interface LedgerConnectorOptions {
  readonly hdPaths?: readonly HdPath[];
  readonly prefix?: string;
  readonly testModeAllowed?: boolean;
  readonly ledgerAppName?: string;
  readonly minLedgerAppVersion?: string;
}

Usage

import TransportWebUSB from "@ledgerhq/hw-transport-webusb";
import { LedgerSigner } from "@cosmjs/ledger-amino";
import { makeCosmoshubPath } from "@cosmjs/amino";
import { SigningStargateClient, GasPrice } from "@cosmjs/stargate";

const transport = await TransportWebUSB.create();
const signer = new LedgerSigner(transport, {
  hdPaths: [makeCosmoshubPath(0)],
  prefix: "cosmos",
});

const [{ address }] = await signer.getAccounts();

const client = await SigningStargateClient.connectWithSigner(
  "https://rpc.my-chain.network",
  signer,
  { gasPrice: GasPrice.fromString("0.025uatom") },
);

const result = await client.sendTokens(
  address,
  "cosmos1recipient...",
  [{ denom: "uatom", amount: "1000000" }],
  "auto",
);

LedgerConnector

Low-level interface for direct communication with the Cosmos Ledger app.
MethodParametersReturns
constructortransport: Transport, options?: LedgerConnectorOptionsLedgerConnector
getCosmosAppVersionPromise<string>
getPubkeyhdPath?: HdPathPromise<Uint8Array>
getPubkeysPromise<readonly Uint8Array[]> (one per configured HD path)
getCosmosAddresspubkey?: Uint8ArrayPromise<string>
signmessage: Uint8Array, hdPath?: HdPathPromise<Uint8Array>
showAddresshdPath?: HdPathPromise<AddressAndPubkey>

Types

interface AddressAndPubkey {
  readonly address: string;
  readonly pubkey: Secp256k1Pubkey;
}
When constructing LedgerConnector without options, these defaults apply: ledgerAppName is "Cosmos", minLedgerAppVersion is "1.5.3", testModeAllowed is false, prefix is "cosmos", and hdPaths defaults to [makeCosmoshubPath(0)].