Skip to content
A wrapper around official Ledger libraries that makes it easier to deal with Ledger wallets (bundle)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes
AUTHORS.md
CHANGELOG.md
CONTRIBUTING.md
EXAMPLES.md
LICENSE.md
README.md
bower.json
ledger-wallet.js
ledger-wallet.js.map
package-lock.json

README.md

ledger-wallet / ReadmeExamplesContributingChangelog

Readme

Licence Dependencies Vulnerabilities Bundle Downloads

Easy Ledger Wallet support for Stellar applications and command line.

(Weekly updates: Reddit, Twitter, Keybase, Telegram)

Introduction

This library is a convenient wrapper around the official Ledger libraries for Stellar:

It provides a way to support Ledger Wallets with a few one-liners:

// Step 1: Connect
await ledgerWallet.connect()

// Step 2: Get public key
const pubkey = ledgerWallet.publicKey

// Step 3: Sign transaction
await ledgerWallet.sign(transaction)

// Extra: Event handlers
ledgerWallet.onConnect = connectionHandler
ledgerWallet.onDisconnect = disconnectionHandler

This library is compatible with both Node.js and browser environments.

Installation

NPM/Yarn

  • NPM: npm install @cosmic-plus/ledger-wallet
  • Yarn: yarn add @cosmic-plus/ledger-wallet

In your script: const ledgerWallet = require("@cosmic-plus/ledger-wallet")

Bower

bower install cosmic-plus-ledger-wallet

In your HTML page:

<script src="./bower_components/cosmic-plus-ledger-wallet/ledger-wallet.js"></script>

HTML

In your HTML page:

<script src="https://cdn.cosmic.plus/ledger-wallet@1.x"></script>

Note: For production release it is advised to serve your copy of the library.

Usage

Methods

await ledgerWallet.connect([account])

Waits for a connection with the Ledger Wallet application for Stellar. If account is not provided, account 0 is used. The library will stop listening for a connection if await ledgerWallet.disconnect() is called.

Once the connection is established, you can use await ledgerWallet.connect() again at any time to ensure the device is still connected.

When switching to another account, you can await ledgerWallet.connect(new_account) without prior disconnection.

Note: Account numbering starts at 0 to remain compatible with previous releases of this library. This will change with the next major release to be consistent with the Ledger application which starts at account 1.

Param Type Default Description
[account] Number | String 0 Either an account number (starts at 0) or a derivation path (e.g: m/44'/148'/0').

await ledgerWallet.sign(transaction)

Prompts the user to accept transaction using the connected account of their Ledger Wallet.

If the user accepts, adds the signature to transaction. Else, throws an error.

Param Type Description
transaction Transaction A StellarSdk Transaction

await ledgerWallet.disconnect()

Close the connection with the Ledger device, or stop waiting for one in case a connection has not been established yet.

Events

ledgerWallet.onConnect : function

Function to execute on each connection.

ledgerWallet.onDisconnect : function

Function to execute on each disconnection.

Members

ledgerWallet.publicKey : String

Public key of the connected account.

ledgerWallet.path : String

Derivation path of the connected account (default: m/44'/148'/0').

ledgerWallet.version : String

Version of the Stellar application installed on the connected device.

ledgerWallet.multiOpsEnabled : Boolean

Whether or not the user accepts to sign transactions without checking them on the device first. This allows to sign long transactions (10+ ops) that could normally not be handled by the device memory, but this is insecure.

ledgerWallet.transport : Transport

The Ledger Transport instance. (internal component)

ledgerWallet.application : StellarApp

The Ledger Stellar application instance. (internal component)

Links

Organization: Cosmic.plus | @GitHub | @NPM

Follow: Reddit | Twitter | Medium | Codepen

Talk: Telegram | Keybase

You can’t perform that action at this time.