Building the CLI for development | Developers

Building the CLI for development

Estimated reading time: 3 minutes

Using a local version of Ledger Live to test your integration can be time consuming. If you would rather have a faster process, you can use the CLI.

Set up

To install the CLI do:

pnpm i

To publish:

# build the cli for publishing
pnpm build:cli

To use it:

pnpm run:cli <command> args

You can test that your local Live Common and your device works correctly by executing a CLI command like:

pnpm run:cli version      # should print live-common version
pnpm run:cli deviceInfo   # should display information about connected device

If everything is fine, you are ready to start integrating your blockchain!

Ledger Live CLI cmd example

pnpm run:cli sync -c bitcoin -i 0 -s native_segwit   # using device
pnpm run:cli sync -c bitcoin --xpub 'xpub......'    # using xpub
pnpm run:cli getAddress -c bitcoin --path "84'/0'/0'/0/0" --derivationMode ''
pnpm run:cli send -i 0 -s segwit --recipient 13LcRWZyZnZu1xrABuAK9Ayftg4kfVs1AA --amount 0.00056 --feePerByte 5
Note
Be aware that the CLI has some limitations compared to Ledger Live. For example, every sync with the CLI will sync the entire account history.

You will find a complete list of commands here.

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:

pnpm run:cli envs

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

EXPERIMENTAL_CURRENCIES=mycoin

to use them:

EXPERIMENTAL_CURRENCIES=mycoin pnpm run:cli -c mycoin --amount 0.1 ---recipient mycoinaddr -i 0

or for LLD:

EXPERIMENTAL_CURRENCIES=mycoin pnpm dev:lld

It will consider mycoin as supported (you can also add it to the supported currencies in cli/src/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",
  },
// }

Demo

  • 00:00 Ledger Live Installation
  • 00:38 CLI Build
  • 01:20 CLI Usage

Did you find this page helpful?


How would you improve this page for developers?



Requirements and installation
Ledger Live mobile and desktop build
Getting Started
Theme Features
Customization

Blockchain support