Add ledger hardware wallet support
Would be cool to support this hardware wallet: https://www.ledgerwallet.com
Currently blocked by #3249
Most of the JS integration has already been written by the MyEtherWallet team here!
This would be really cool indeed! Happy to help make it possible
Now that this milestone is done https://github.com/MetaMask/metamask-plugin/milestone/14?closed=1, would it be possible to implement Ledger support?
Hi @izqui, thanks for the interest!
Our architecture will now support it, but we still haven't settled on what the UI/UX is going to be. If you know the constraints of the Ledger well, maybe you could help propose an account adding / signing flow.
One proposal:
- We're planning to add an "Import Account" menu item to the top-right menu.
- That menu will allow selection of different types of accounts to support.
- One of those account types could be Ledger.
What does that UI look like? What code can we use under the hood?
The other big question for Ledger support:
What does transaction signing look like? I generally like the idea that reviewing a transaction can continue to have a common interface, and as we improve that, it improves all signing strategies, but when the user clicks "Accept", some types of accounts (like Ledger) will need to show another view, and instruct the user how to complete the interaction. What does that look like?
@izqui also - how does a ledger wallet integration work? do you start a webserver stored on the USB device? Haven't looked into it yet but certainly is possible.
Last time I asked, @kumavis, I was told to basically copy MEW's code, but it didn't look quite as neatly abstracted as I'd hoped. I'm hoping there'd be a Ledger.js lib that we could drop in for getting listed accounts & requesting signatures.
@flyswatter My Ledger Nano S is arriving on Friday. Will think about what a good flow could be then.
Regarding signing transactions, i think showing the Metamask confirmation screen but without buttons, indicating to perform the confirmation using Ledger's hardware could be an option.
I have been doing some research and it seems that the Ledger only allows to sign transactions and not arbitrary data.
AFAIK, this would make deploying contracts or signing proofs impossible.
Also, regarding My Ether Wallet implementation:
- MEW doesn't allow using Ledger for signing messages (https://www.myetherwallet.com/#sign-message)
- MEW offers the option to deploy a contract using the Ledger, but I cannot get it to work (https://www.myetherwallet.com/#contracts)
I have talked to Ledger support to see if they can give me an status update on this.
Good initial research.
Since Ledger has apps, I wonder if we could convince them to add message signing support.
In addition to removing buttons on the approval screen, I'd want a message, and then there is still the question of what the UI to pair should look like.
Quick update: I emailed Ledger support regarding arbitrary data signing, and referenced me to their public trello (https://trello.com/b/5nQ1mdzt/ledger-roadmap) where there is no reference of this feature/bug.
I was invited to join their Slack to continue the conversation (EDIT: Was just told that "we're already looking at that for other integrations, should happen shortly" 🙌)
Regarding confirmation screen, this is what they have in their Ethereum Wallet implementation (MEW doesn't show any UI related to the ledger)

The 'pair' should offer a list of all Ethereum addresses derived from the Ledger seed (MEW solves this well) and when the user selects one, save that address and the fact that is a Ledger address (no private key) that requires Ledger interaction to work with.
@LogvinovLeon and I implemented a LedgerWalletProvider that connects to the Ledger wallet over U2F. This should be an easier starting point than the MyEtherWallet code.
The Ledger wallets are based on a HD wallets and use derivation paths. This is a bit of a mismatch with Ethereuem/web3 that is based on a flat list of accounts.
The Ledger supports (as far as I have tested) any derivation path of the form m/44'/60'/*where * can be empty. (61 for ETC)
Their own Ethereum Wallet currently only uses the address available on m/44'/60'/0'/0. From their slack channel future versions will support multiple addresses, of the form m/44'/60'/${account}'/${address}. But this is not final and will be given further thought before implementation.
MyEtherWallet uses addresses available on m/44'/60'/0'/${address}.
For the LedgerWalletProvider we currently only implement m/44'/60'/0'/0 (our goal is to be compatible rather than flexible).
@Recmo That is fantastic stuff! The linked code is a perfect starting point.
I'll need to either fork it to break out the core functionality or wrap it strangely though, since we don't use signing subproviders directly.
Maybe once I break that out into a small module, we could share that piece to share improvements and fixes.
Anyways, thanks a lot, I hope to work off this soon!
Thanks! Feel free to fork it, we are very open to pull-requests. It implements the Web3-providers API, but has no dependencies on it. You should be able to use it on it's own just as easily:
const Ledger = require('ledger-wallet-provider')
ledger = new Ledger()
ledger.getAccounts(console.log)
ledger.signTransaction(...
The happy-paths are working, we will soon be adding more error handling and feedback (ie. "Browser unsupported").
Oh that surface is actually closer to what I wanted than I thought! Very cool!
+1, would love to see this feature done. I have a ledger nano s and ledger blue so can help test, maybe code if given some guidance
Just looking at ledger-wallet-provider mentioned above, nice! https://github.com/Neufund/ledger-wallet-provider
Noting another nice looking ledger client available: https://github.com/LedgerHQ/ledger-node-js-api
EDIT @flyswatter helped me find out that MetaMask is currently following BIP 44 spec. As long as you all keep that up then I'm happy with your implementation. :) Leaving this here for future readers that end up in this space, but you can mostly ignore this unless there is a plan to move away from BIP 44.
Cross posting my comment here. Please don't do what MEW and the Ledger app did (rumors suggest it was an accident that made it to release and now change is hard) and use a m/44'/* path without actually following the rest of the (BIP 44 spec). When you all get around to implementing this, please follow the spec and either create a new purpose (first segment) or use purpose 44' and follow the spec associated with that : m / purpose' / coin_type' / account' / change / address_index
Alternatively, do something totally different with regards to the path, just don't have it start with 44'. :)
Soapbox aside, what are your plans for this? As a dApp engineer working on Ledger integration, compatibility with MetaMask is important to us and we would like to make sure we are on the same page with the various wallet/integration providers.
You can see what other wallets are doing over in that thread (I believe you all already have some representation there) but it is more even more important to follow the standard when integrating with a HW wallet because users will expect the hardware wallet to show the same accounts no matter which tool they use to interact with the wallet. It is unfortunate that a bug in an early release of the Ledger app has resulted in this much community disconnect, but I think getting back on track with current standards until there is an official Ethereum one is critical for good UX for all of our users.
Do you have an ETA on this? It would really enhance the functionality of the ledger to use smart contracts.
I think this would be an excellent feature, and add a lot of security and usability to MetaMask. +1