This is a wrapper around the official Ledger libraries for Stellar:
Ledger wallet support may be a bit tricky to implement because it doesn't require the same libraries whether you're on Node.js or in web browser. Also, it requires quite a few lines of code.
This library is solving that by loading the right dependencies automatically and providing a few simple one-liners.
npm install @cosmic-plus/ledger-wallet
yarn add @cosmic-plus/ledger-wallet
In your scripts:
const ledgerWallet = require('@cosmic-plus/ledger-wallet')
bower install cosmic-plus-ledger-wallet
In your HTML pages:
Note: For production release it is advised to serve your own copy of the libraries.
This will wait for a connection with the Ledger Wallet application for Stellar.
If account_number is not provided, account 0 will be used. Note that you'll
ledgerWallet.disconnect() if you want the library to stop listening
for a connection.
If at some point you need to make sure that the Ledger Wallet is still
connected, you can
await ledgerWallet.connect() again (will re-use previously set account_number).
If you need to switch to another account, you can directly
await ledgerWallet.connect(new_account_number) without prior deconnection.
Ask the user to confirm transaction on its Ledger Wallet. If confirmed, returns the signed transaction. Else, throw an error.
This method requires that you
Close the connection with Ledger Wallet Stellar application, or stop listening for a connection if none have been established.
Once the device is connected, contains the public key of the selected account.
The bip path for the selected account
ledgerWallet.onConnect = Function
Function to execute on connection.
ledgerWallet.onDisconnect = Function
Function to execute on disconnection.
Ledger Wallet Stellar application version.
Whether or not user accept to sign transactions without checking them on the device first. This allows to sign long transactions that could normally not be handled by the device memory, but this is insecure.
The Ledger Transport instance (internal component).
The Ledger Stellar application instance (internal component).
Feedback & More
You'll find several ways to contact me on https://cosmic.plus.