DocumentationLedger LiveAccountsBeginner's guidesBuild the CLI for development

Building the CLI for development

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
ℹ️

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
Ledger
Copyright © Ledger SAS. All rights reserved. Ledger, Ledger Nano S, Ledger Vault, Ledger OS are registered trademarks of Ledger SAS