Requirements and installation
ledger-live monorepository. The work to integrate a Blockchain in Ledger Live will all happen in this monorepository.
Ledger Live Common (
./libs/ledger-live-common) is the shared core library used by Ledger Live Desktop and Mobile, that also includes a CLI for testing purpose or for using Ledger Live features directly from a terminal (in a limited way).
This library is built upon a pretty standard ES6 + Typescript stack and relies on a bunch of ledgerjs (opens in a new tab) packages, RxJS 6.x (opens in a new tab), bignumber.js (opens in a new tab) and React (opens in a new tab) + Redux (opens in a new tab) for some front-end utilities and hooks.
It is designed to have very generic models and mechanics (for currencies, accounts, storage, synchronisation, events...) that also facilitates new blockchain integrations through flexibility.
All integrated coins are implemented in their own package in the
libs directory, following the naming convention. To be fully integrated, a
libs/ledger-live-common/src/families dedicated folder needs to contain a few "glue" files - that can be shared by multiple crypto-assets that use the same implementation (i.e. Bitcoin-like coins share the same
This document only concerns new blockchain integrations using Typescript - we will use an imaginary coin named
MyCoin as a walkthrough.
- Node.email@example.com (opens in a new tab)
- PnPm@8.x.x (opens in a new tab)
- Python 2.7 or 3.5+
- A C/C++ toolchain (see node-gyp documentation)
- eslint (opens in a new tab) - ensure it works in your IDE (vscode plugin (opens in a new tab))
- prettier (opens in a new tab) - through an eslint-plugin
- typescript (opens in a new tab) - ensure it works fine with your IDE
- A physical device (Ledger Nano S, S Plus, X or a Stax)
- MyCoin app installed on device
- Fork and clone the
ledger-liverepository https://github.com/LedgerHQ/ledger-live (opens in a new tab)
- Install with
Your whole implementation of MyCoin must reside in a
mycoin folder in
libs/ledger-live-common/src/families/ with the exception of some changes to apply in shared code.
Here is a typical family folder structure (TS integration):
./libs ├── coin-mycoin/src │ ├── api │ │ ├── cache.ts │ │ └── index.ts │ ├── bridge │ │ └── js.ts │ ├── account.ts │ ├── bridge.integration.test.ts │ ├── buildTransaction.ts │ ├── cli-transaction.ts │ ├── deviceTransactionConfig.ts │ ├── errors.ts │ ├── hw-getAddress.ts │ ├── js-broadcast.ts │ ├── js-createTransaction.ts │ ├── js-estimateMaxSpendable.ts │ ├── js-getFeesForTransaction.ts │ ├── js-getTransactionStatus.ts │ ├── js-prepareTransaction.ts │ ├── js-signOperation.ts │ ├── js-synchronization.ts │ ├── logic.ts │ ├── serialization.ts │ ├── signer.ts │ ├── specs.ts │ ├── speculos-deviceActions.ts │ ├── transaction.ts │ └── types.ts ├── ledger-live-common/src/families/mycoin │ ├── bridge.integration.test.ts │ ├── logic.ts │ ├── react.ts │ ├── setup.ts │ └── types.ts └── ledgerjs/packages/hw-app-mycoin/src └── MyCoin.ts
You can refer to existing implementations to complete given examples, like Polkadot integration.
src/apidirectory: Contains all the logic to send requests to the explorer.
src/bridge/js.tsfile: Entry point of Ledger Live integration of the coin-module. This file lists
src/hw-getAddress.tsfile: Logic on how to interact with device-app to retrieve addresses.
src/js-*files: Split of
BridgeAccountlogic in dedicated files.
src/signer.tsfile: Interface definition of the ledger device-app related to this coin.
src/specs.tsfile: Definition of tests to be run on the bot.
src/logic.ts: Lists coin specific business logic.
src/react.ts: Defines and lists coin specfic react hooks for UI.
src/setup.ts: Glue file for coin integration.
src/types.ts: Lists coin specific types.
All files related to communication with the device-app.