ethers-ledger
This is just a quick sample I threw together, it needs a lot more work to detect and relay meaningful errors to the application developer.
Importing
Node.js
This will connect to the Ledger via the HID protocol.
const LedgerSigner = ;
Browser
This will connect to the Ledger via the U2F protocol, which requires a compatible browser (e.g. Chrome, Opera) and the site must be hosted on an SSL site. The Ledger must also be in "Broswer Mode".
<!-- MUST load the ethers library first --><script src="" type="text/javascript"><script src="" type="text/javascript"><script type="text/javascript"> const LedgerSigner = ethersLedgerSigner;</script>
TypeScript
;
API
// Options are optional; this is the defaultlet options = path: "m'/44'/0'/0'/0/0"; let provider = ethersproviders; // Connect using the default Transport// - In the browserified (dist) library, the U2F interface// - In node.js, the HID interfacelet signer = LedgerSigner; signer; let message = "Hello!"signer; let binaryMessage = 72 101 108 108 111 33 ;signer; signer; // This requires a provider was providedsigner; let ropstenProvider = ethersproviders;let ropstenSigner = signer;
Custom Transport
If you need to specify the transport to use, the constructor can be called directly:
let signer = new LedgerSigner(transport, provider, options);
License
MIT License.