Ledger Live Setup | Developers

Ledger Live Setup

Estimated reading time: 3 minutes

Introduction

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 packages, RxJS 6.x, bignumber.js and React + Redux 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 a src/families dedicated folder which contains the specifics of a coin family - that can be shared by multiple crypto-assets that use the same implementation (i.e. Bitcoin-like coins share the same bitcoin family).

This document only concerns new blockchain integrations using Typescript - we will use an imaginary coin named MyCoin as a walkthrough.

Setup

Requirements

Development tools (used or required)

  • yalc for locally linking ledger-live-common with other projects
  • eslint - ensure it’s working in your IDE (vscode plugin)
  • prettier - through an eslint-plugin
  • typescript - ensure it works fine with your IDE

Hardware prerequisites

  • A physical device (Ledger Nano S, Nano X or Nano S Plus)
  • MyCoin app installed on device

Installation

Structure

Your whole implementation of MyCoin must reside in a mycoin folder in src/families/ with the exception of some changes to apply in shared code.

Here is a typical family folder structure (TS integration):

./src/families/mycoin
├── bridge
│   └── js.ts
├── hw-app-mycoin
│   └── MyCoin.ts
├── api.ts
├── hw-getAddress.ts
├── errors.ts
├── deviceTransactionConfig.ts
├── account.ts
├── transaction.ts
├── serialization.ts
├── cli-transaction.ts
├── logic.ts
├── cache.ts
├── preload.ts
├── react.ts
├── specs.ts
├── speculos-deviceActions.ts
├── test-dataset.ts
├── test-specifics.ts
└── types.ts
Note
You can refer to existing implementations to complete given examples, like Polkadot integration

Building the CLI for Development

Do not forget to build before testing:

yalc publish --push
# if not yarn watch
cd cli
yarn build

Environment Variables

Ledger Live provides a lot of flexibility through ENV variables. You can export them, define them before calling cli or use a tool like direnv.

To list them all, you can execute:

ledger-live envs

The one you will use the most before releasing you integration is:

EXPERIMENTAL_CURRENCIES=mycoin

to use them :

EXPERIMENTAL_CURRENCIES=mycoin ledger-live send -c mycoin --amount 0.1 ---recipient mycoinaddr -i 0

or for LLD :

EXPERIMENTAL_CURRENCIES=mycoin yarn start

It will consider mycoin as supported (you can also add it to the supported currencies in src/ledger-live-common-setup-base.ts).

For clarity, we will omit this environment variable in this document.

If needed, you can add your own in src/env.ts (always try to add a MYCOIN_ prefix to avoid collisions):

// const envDefinitions = { ...
  MYCOIN_API_ENDPOINT: {
    def: "https://mycoin.coin.ledger.com",
    parser: stringParser,
    desc: "API for mycoin",
  },
// }

Did you find this page helpful?


How would you improve this page for developers?



Linking local packages with yalc
Getting Started
Theme Features
Customization