ethers.Wallet.fromMnemonic is not a function in ethers 6.9.0 -- How do I generate a wallet from a mnemonic using ethers 6.9.0?

I was using the ethers.Wallet.fromMnemonic but for some reason I am getting errors saying it is not a function and I think it may because the latest version of ethers (6.9.0) might not have that function?

1

There are 1 best solutions below

0
On

In version 5.7.0 we have a method named fromMnemonic which create a instance of Wallet from a mnemonic phrase.

const walletFromMnemonic = new ethers.Wallet.fromMnemonic(mnemonic)

Link: https://docs.ethers.org/v5/api/signer/#Wallet.fromMnemonic

But in version 6.9.0 we have a method named fromPhrase which create a instance of HDNodeWallet from phrase.

const walletFromMnemonic = new ethers.Wallet.fromPhrase(phrase: string, provider?: Provider)

Link: https://docs.ethers.org/v6/api/wallet/#Wallet_fromPhrase

You can try to create wallet instace using the above syntax. but i am not sure about the difference between a Wallet instance vs a HDNodeWallet instance.