wallets fromPhrase are not the same as in Metamask... #4148
-
Hi, I'm trying to generate a lot of wallet with this code
and so it works, but the wallet list are different from what I have in Metamask? Only the first one matches... How to make the generated wallets list match the Metamask method? and also how to get the privateKey from a generated wallet, because it seems like it doesn't have such value, and the v6 docs seems doesn't have it also maybe..... Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
MetaMask uses a different derivation path, opting to modify the There are two functions to use to derive the path, depending on which standard you are using, documented here. When using software like Ledger it will scan both standards and tag any index-based accounts with the MetaMask tag. Also, keep in mind when using Does that all make sense? |
Beta Was this translation helpful? Give feedback.
-
I think I got it... finally haha import { HDNodeWallet, Mnemonic } from 'ethers';
|
Beta Was this translation helpful? Give feedback.
MetaMask uses a different derivation path, opting to modify the
index
field in the BIP-43 instead of theaccount
field.There are two functions to use to derive the path, depending on which standard you are using, documented here.
When using software like Ledger it will scan both standards and tag any index-based accounts with the MetaMask tag.
Also, keep in mind when using
fromPhrase
it loads the target path, which means you are already too deep to use derive path. Depending on the target standard, you will need to specify the path 1 above it in the HD path, and then derive the child path from there. Unless you need the performance gain, I would recommend using the above functions to der…