• This repository has been archived on 27/Jun/2022
  • Stars
    star
    574
  • Rank 77,410 (Top 2 %)
  • Language
    TypeScript
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⛔️ MOVED to monorepo "ledger-live"

⛔️ DEPRECATED

This repository is now deprecated. We moved to a new mono repository architecture containing all of Ledger Live JavaScript Ecosystem that you can find here. You can follow the migration guide to help you make the transition.

We are hiring, join us! 👨‍💻👩‍💻

Ledger Devs Slack License

Welcome to Ledger's JavaScript libraries.

See also:

@ledgerhq/hw-transport-*

To communicate with a Ledger device, you first need to identify which transport(s) to use.

The hw-transport libraries implement communication protocol for our hardware wallet devices (Ledger Nano / Ledger Nano S / Ledger Nano X / Ledger Blue) in many platforms: Web, Node, Electron, React Native,... and using many different communication channels: U2F, HID, WebUSB, Bluetooth,...

Channels U2F/WebAuthn HID WebUSB Bluetooth
Blue DEPRECATED1 YES NO NO
Nano S DEPRECATED1 YES YES NO
Nano X DEPRECATED1 YES YES YES
  1. U2F is deprecated. See https://github.com/LedgerHQ/ledgerjs/blob/master/docs/migrate_webusb.md

Summary of implementations available per platform

Platforms U2F/WebAuthn HID WebUSB Bluetooth
Web @ledgerhq/hw-transport-u2f @ledgerhq/hw-transport-webhid @ledgerhq/hw-transport-webusb @ledgerhq/hw-transport-web-ble
Electron/Node.js NO @ledgerhq/hw-transport-node-hid1 NO @ledgerhq/hw-transport-node-ble
iOS NO NO NO @ledgerhq/react-native-hw-transport-ble
Android @ledgerhq/hw-transport-u2f2 @ledgerhq/react-native-hid @ledgerhq/hw-transport-webusb2 @ledgerhq/react-native-hw-transport-ble
  1. 3 implementations available
  2. via Android Chrome

Beware the current web support:

Channels U2F WebHID. WebUSB WebBluetooth
Windows DEPRECATED1 YES OK BUT2 YES
Mac DEPRECATED1 YES YES YES
Linux DEPRECATED1 YES YES YES
Chrome DEPRECATED1 YES3 YES YES
Safari DEPRECATED1 NO NO NO
Firefox DEPRECATED1 NO NO NO
IE. DEPRECATED1 NO NO NO
  1. U2F is deprecated. See https://github.com/LedgerHQ/ledgerjs/blob/master/docs/migrate_webusb.md
  2. instabilities has been reported
  3. WebHID supported under Chrome experimental flags

Please find respective documentation for each transport:

An unified Transport interface

All these transports implement a generic interface exposed by @ledgerhq/hw-transport. There are specifics for each transport which are explained in each package.

A Transport is essentially:

  • Transport.listen: (observer)=>Subscription
  • Transport.open: (descriptor)=>Promise<Transport>
  • transport.exchange(apdu: Buffer): Promise<Buffer>
  • transport.close()

and some derivates:

  • transport.create(): Promise<Transport>: make use of listen and open for the most simple scenario.
  • transport.send(cla, ins, p1, p2, data): Promise<Buffer>: a small abstraction of exchange

NB: APDU is the encoding primitive for all binary exchange with the devices. (it comes from smart card industry)

@ledgerhq/hw-app-*

As soon as your Transport is created, you can already communicate by implementing the apps protocol (refer to application documentations, for instance BTC app and ETH app ones).

We also provide libraries that help implementing the low level exchanges. These higher level APIs are split per app:

Community packages:

Other packages

Published Packages

Package Version Description
create-dapp npm Ledger DApp Ethereum starter kit
@ledgerhq/web3-subprovider npm web3 subprovider implementation for web3-provider-engine
Development Tools
@ledgerhq/hw-transport-mocker npm Tool used for test to record and replay APDU calls.

Basic gist

import Transport from "@ledgerhq/hw-transport-node-hid";
// import Transport from "@ledgerhq/hw-transport-webusb";
// import Transport from "@ledgerhq/react-native-hw-transport-ble";
import AppBtc from "@ledgerhq/hw-app-btc";
const getBtcAddress = async () => {
  const transport = await Transport.create();
  const btc = new AppBtc(transport);
  const result = await btc.getWalletPublicKey("44'/0'/0'/0/0");
  return result.bitcoinAddress;
};
getBtcAddress().then(a => console.log(a));

Contributing

Please read our contribution guidelines before getting started.

You need to have a recent Node.js and Yarn installed.

Install dependencies

yarn

Build

Build all packages

yarn build

Watch

Watch all packages change. Very useful during development to build only file that changes.

yarn watch

Lint

Lint all packages

yarn lint

Run Tests

First of all, this ensure the libraries are correctly building, and passing lint and flow:

yarn test

then to test on a real device...

Plug a device like the Nano S and open Bitcoin app.

Then run the test and accept the commands on the devices for the tests to continue.

yarn test-node

You can also test on the web:

yarn test-browser

make sure to configure your device app with "Browser support" set to "YES".

Deploy

Checklist before deploying a new release:

  • you have the right in the LedgerHQ org on NPM
  • you have run npm login once (check npm whoami)
  • Go to master branch
    • your master point on LedgerHQ repository (check with git config remote.$(git config branch.master.remote).url and fix it with git branch --set-upstream master origin/master)
    • you are in sync (git pull) and there is no changes in git status
  • Run yarn once, there is still no changes in git status

deploy a new release

 yarn run publish

then, go to /releases and create a release with change logs.

alternatively:

deploy a canary release (beta, etc)

 yarn run publish -c

NB: if there is a new package, AFAIK you need to manually npm publish it once on NPM.

VSCode settings

Here is a example config for a workspace file to handle the monorepo setup.
Just add project.code-workspace to your .vscode folder

{
  "folders": [
    {
      "name": "root",
      "path": "../"
    },
    {
      "name": "cryptoassets",
      "path": "../packages/cryptoassets"
    },
    {
      "name": "devices",
      "path": "../packages/devices"
    },
    {
      "name": "errors",
      "path": "../packages/errors"
    },
    {
      "name": "hw-app-algorand",
      "path": "../packages/hw-app-algorand"
    },
    {
      "name": "hw-app-btc",
      "path": "../packages/hw-app-btc"
    },
    {
      "name": "hw-app-cosmos",
      "path": "../packages/hw-app-cosmos"
    },
    {
      "name": "hw-app-eth",
      "path": "../packages/hw-app-eth"
    },
    {
      "name": "hw-app-polkadot",
      "path": "../packages/hw-app-polkadot"
    },
    {
      "name": "hw-app-str",
      "path": "../packages/hw-app-str"
    },
    {
      "name": "hw-app-tezos",
      "path": "../packages/hw-app-tezos"
    },
    {
      "name": "hw-app-trx",
      "path": "../packages/hw-app-trx"
    },
    {
      "name": "hw-app-xrp",
      "path": "../packages/hw-app-xrp"
    },
    {
      "name": "hw-transport",
      "path": "../packages/hw-transport"
    },
    {
      "name": "hw-transport-http",
      "path": "../packages/hw-transport-http"
    },
    {
      "name": "hw-transport-mocker",
      "path": "../packages/hw-transport-mocker"
    },
    {
      "name": "hw-transport-node-ble",
      "path": "../packages/hw-transport-node-ble"
    },
    {
      "name": "hw-transport-node-hid",
      "path": "../packages/hw-transport-node-hid"
    },
    {
      "name": "hw-transport-node-hid-noevents",
      "path": "../packages/hw-transport-node-hid-noevents"
    },
    {
      "name": "hw-transport-node-hid-singleton",
      "path": "../packages/hw-transport-node-hid-singleton"
    },
    {
      "name": "hw-transport-node-speculos",
      "path": "../packages/hw-transport-node-speculos"
    },
    {
      "name": "hw-transport-web-ble",
      "path": "../packages/hw-transport-web-ble"
    },
    {
      "name": "hw-transport-webhid",
      "path": "../packages/hw-transport-webhid"
    },
    {
      "name": "hw-transport-webusb",
      "path": "../packages/hw-transport-webusb"
    },
    {
      "name": "logs",
      "path": "../packages/logs"
    },
    {
      "name": "react-native-hid",
      "path": "../packages/react-native-hid"
    },
    {
      "name": "react-native-hw-transport-ble",
      "path": "../packages/react-native-hw-transport-ble"
    }
  ],
}

More Repositories

1

ledger-live-desktop

⛔️ DEPRECATED - Ledger Live (Desktop)
JavaScript
954
star
2

ledger-live

Mono-repository for packages related to Ledger Live and its JavaScript ecosystem.
JavaScript
410
star
3

ledger-live-mobile

⛔️ DEPRECATED - Ledger Live (Mobile)
JavaScript
381
star
4

ledger-nano-s

Ledger Nano S, a personal security device from Ledger (blockchain / bitcoin / ethereum / FIDO)
277
star
5

app-monero

Monero wallet application for Ledger Nano S & X
Python
267
star
6

app-ethereum

Ethereum wallet application for Ledger devices
C
178
star
7

ledger-wallet-chrome

Ledger Wallet Chrome application
JavaScript
162
star
8

satstack

Bitcoin full node with Ledger Live
Go
148
star
9

ledger-javacard

Ledger Unplugged - Java Card implementation of Ledger Bitcoin Hardware Wallet
Java
140
star
10

ledger-live-common

⛔️ DEPRECATED - Common ground for the Ledger Wallet apps
TypeScript
135
star
11

speculos

Ledger Nano/Blue apps emulator
C
129
star
12

app-bitcoin

Bitcoin wallet application for Ledger Blue and Nano S
C
118
star
13

blue-loader-python

Python Loader for Ledger Blue (all), Nano S (all) and Nano X (developer units)
Python
114
star
14

openpgp-card-app

OpenPGP Card Application
C
110
star
15

nanos-secure-sdk

Secure (ST31) SDK for Ledger Nano S
C
94
star
16

app-bitcoin-new

Modern Bitcoin Application based on PSBT and Descriptors
C
93
star
17

ledger-wallet-api

High level API to the Ledger Wallet Chrome app
HTML
82
star
18

lib-ledger-core

C++
79
star
19

app-ssh-agent

Simple SSH and GPG agent for Ledger Blue and Nano S
C
78
star
20

udev-rules

udev rules to support Ledger devices on Linux
Shell
76
star
21

app-passwords

Password Manager application for Ledger Blue and Nano S
C
74
star
22

ledger-wallet-ripple

JavaScript
65
star
23

ledger-u2f-javacard

Java Card FIDO U2F authenticator for Ledger Unplugged
Java
63
star
24

btchip-python

Ledger HW.1 Python API
Python
60
star
25

ledger-wallet-ethereum-chrome

Ledger Wallet Ethereum Chrome application
JavaScript
55
star
26

ledger-sample-apps

Sample Applications for Ledger Nano S and Ledger Blue
C
54
star
27

ledgerjs-examples

LedgerJS examples
JavaScript
53
star
28

ledger-manager-chrome

Ledger Manager Chrome application
Scala
50
star
29

android-u2f-bridge

Generic support for USB U2F tokens on Android
Java
49
star
30

ledger-dotnet-api

.NET API for Ledger
C#
48
star
31

xpub-scan

Tool to perform master public key analysis
TypeScript
45
star
32

ledger-blue

Ledger Blue, a personal security device from Ledger (blockchain / bitcoin / ethereum / FIDO)
41
star
33

ledger-device-rust-sdk

Rust SDK for Ledger device applications
Rust
38
star
34

wallet-api

Wallet API Monorepo
TypeScript
38
star
35

ledgerctl

A library to control Ledger devices
Python
37
star
36

bolos-enclave

BOLOS community enclave for SGX & simulator
C
34
star
37

ledger-wallet-ios

Ledger Wallet iOS application
Swift
34
star
38

app-u2f

FIDO U2F Application for Ledger Blue and Nano S
C
33
star
39

app-boilerplate

Boilerplate application for Ledger Nano S/X
C
33
star
40

recover-whitepaper

33
star
41

app-boilerplate-rust

Rust boilerplate application for Ledger Nano S/S+/X
Python
31
star
42

bolos-tee

Implementation of Ledger BOLOS for TEE applications
C
29
star
43

ledger-dev-doc

DEPRECATED - please use https://github.com/LedgerHQ/developer-portal
Python
28
star
44

developer-portal

MDX
27
star
45

nanos-ui

UI application for Ledger Nano S
C
26
star
46

blue-devenv

DEPRECATED - Development Environment for Ledger Blue and Nano S
26
star
47

OUTDATED_ledger-wallet-android

OUTDATED – for Ledger Live mobile, the correct repository is here =>
Scala
26
star
48

solidity-exercise

A RPG multiplayer game that will be used for interviews and internal workshops.
Solidity
22
star
49

app-streaming

Develop apps without any constraints
C
22
star
50

ledger-app-builder

Docker image to compile app for the Ledger Nano S.
Dockerfile
22
star
51

rust-app-demo

(DEPRECATED) Proof of concept setup for a Rust App on Nano
Rust
19
star
52

ledger-secure-os

C
19
star
53

nanox-secure-sdk

This repository has been replaced by https://github.com/LedgerHQ/ledger-secure-sdk/. Please read the new repository README for more information.
C
19
star
54

app-xrp

Ripple wallet application for Ledger Blue and Nano S
C
18
star
55

connect-kit

TypeScript
16
star
56

rust-app-password-manager

Rust
15
star
57

ui

⛔️ MOVED to monorepo "ledger-live"
TypeScript
15
star
58

app-starknet

Official Ledger Starknet application (Rust implementation)
Python
15
star
59

ledger-wallet-webtool

A utility application used to deploy utility functions to Ledger users
JavaScript
14
star
60

ledger-fresh-management

This is where product topics are discussed for Ledger Fresh
14
star
61

nanos-nonsecure-firmware

Non Secure (STM32) Firmware for Ledger Nano S
C
14
star
62

cargo-ledger

(Moved in the ledger device rust SDK --> https://github.com/LedgerHQ/ledger-device-rust-sdk). Load code on a Ledger device with a `cargo` subcommand
Rust
14
star
63

live-app-sdk

TypeScript
13
star
64

ledger-live-wagmi-connector

Wagmi JS lib Connector for Ledger Live Dapp Browser
TypeScript
13
star
65

lascar

Mirror of lascar (https://github.com/Ledger-Donjon/lascar)
Python
13
star
66

app-starknet-zondax

Starknet application for Ledger Nano S, SP, X
Rust
13
star
67

moosig

Fun with MuSig2 and Ledger devices 🎵
Python
13
star
68

nanos-nonsecure-firmware-releases

Non Secure (STM32) Firmware releases for Ledger Nano S
12
star
69

blue-secure-sdk

Secure (ST31) SDK for Ledger Blue
C
12
star
70

web3allowlist

Allowlist data for Web3Checks
Python
12
star
71

lib-ledger-core-node-bindings

C++
12
star
72

btchip-c-api

Ledger HW.1 C APIs
C
12
star
73

resigner

The hottest miniscript signing server
Python
12
star
74

innovation-contracts-solidity

Collection of smart contracts written in Solidity
Solidity
11
star
75

app-plugin-boilerplate

C
10
star
76

ledger-nano-piv

Hackathon project, not production ready (yet)
Rust
9
star
77

app-age

Rust
9
star
78

ledger-repl

DEPRECATED, this project moved to https://github.com/LedgerHQ/ledger-live – this repository will be archived once we migrated the website too
JavaScript
9
star
79

btchip-doc

Ledger HW.1 firmware documentation
HTML
9
star
80

app-near

Ledger repo for Near app
C
9
star
81

ledger-javacard-eligibility

Java Card applet to test features and performance of a Hierarchical Deterministic Bitcoin Hardware Wallet implementation
Java
9
star
82

ledger-asset-dapps

Python
9
star
83

passwords-backup

JavaScript
8
star
84

ledger-starter-iso

Ledger Starter ISO recipe
Python
8
star
85

vanadium-legacy

Unlimited power for apps
C
8
star
86

lib-ledger-core-react-native-bindings

Java
8
star
87

ledger-app-otherdime

Offchain private key exchange as an attestation demonstration for Ledger Blue and Nano S
C
8
star
88

app-recovery-check

C
7
star
89

app-exchange

Exchange application to SWAP and SELL with Ledger Live
C
7
star
90

CTF

C
7
star
91

ragger

Small wrapper around Speculos, LedgerWallet & LedgerComm to ease instrumentation
Python
7
star
92

wallet-connect-live-app

TypeScript
7
star
93

btchip-js-api

Ledger HW.1 JavaScript APIs
JavaScript
7
star
94

starknet-wallet-contracts

Python
7
star
95

ethereum-plugin-sdk

C
7
star
96

bitcoin-lib-grpc

A modular gRPC service to interact with the Bitcoin protocol. ₿
Go
7
star
97

blue-nonsecure-firmware

Non Secure (STM32) Firmware for Ledger Blue
C
7
star
98

ledger-fresh-web

Frontend of Ledger fresh, our open source web wallet based on the account abstraction
TypeScript
7
star
99

ledgercomm

Library to communicate with Ledger Nano S/X and Speculos
Python
7
star
100

notification-center

Open source notification web service
TypeScript
6
star