A library for interacting with hardware wallets from JS/TS. Supports KeepKey, Trezor, and Ledger. Intended for use in web apps, chrome apps/extensions, and electron/node apps.
Try it out here!
yarn add @keepkey/hdwallet-core
yarn add @keepkey/hdwallet-keepkey-webusb
yarn add @keepkey/hdwallet-trezor-connect
yarn add @keepkey/hdwallet-ledger-webusbYou can import the generated bundle to use each of the component libraries:
import{HDWallet}from"@keepkey/hdwallet-core";import{isKeepKey,KeepKeyHDWallet}from"@keepkey/hdwallet-keepkey";import{WebUSBKeepKeyAdapter}from"@keepkey/hdwallet-keepkey-webusb";The recommended way to use the library is through a Keyring singleton,
which manages connected devices:
import{Keyring}from"@keepkey/hdwallet-core";constkeyring=newKeyring();To add in support for a given wallet type, add in the relevant Transport
adapter by calling useKeyring() on it:
import{WebUSBKeepKeyAdapter}from"@keepkey/hdwallet-keepkey-webusb";constkeepkeyAdapter=WebUSBKeepKeyAdapter.useKeyring(keyring);After setting up a Keyring, and plugging various transport adapters into
it, the next step is to pair a device:
letwallet=awaitkeepkeyAdapter.pairDevice();wallet.getLabel().then((result)=>{console.log(result);});It is expected that this take quite some time (around 10 minutes), due to the large size of the compiled KeepKey protobuf encoder/decoder.
yarn clean
yarn
yarn buildTo compile and watch the browser bundle, run:
yarn dev:sandboxThis will launch an ssl webserver that runs at https://localhost:1234, with
a small demo app that shows how to use various HDWallet functionality.
We use Zeit Now for continuous deployment of this sandbox app. On pull requests, the builder will publish a new version of that app with the changes included (for example #68). Try out the latest build here: https://hdwallet.shapeshift.now.sh/
yarn
yarn build
yarn testThe integration tests have been set up to run either against a physical KeepKey with debug firmware on it, or in CI pointed at a dockerized version of the emulator. Trezor and Ledger tests run against mocks of their respective transport layers.
See our developer guidelines here.