question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ethers.Wallet not working on node v17,18

See original GitHub issue

Ethers Version

5.6.8

Search Terms

wallet, mnemonic, private key

Describe the Problem

Issue: Wallet intialization not working in Node v17.x.x or v18.x.x Code:

const ethers = require("ethers");

(async() => {
    const pvKey = ethers.ethers.Wallet.createRandom().privateKey;
    console.log(pvKey);
})();

It throws this error:

node:internal/crypto/hash:67
  this[kHandle] = new _Hash(algorithm, xofLen);
                  ^

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at createHash (node:crypto:135:10)
    at ripemd160 (/Users/vanxh/codes/bitpack/extension/node_modules/@ethersproject/sha2/lib/sha2.js:11:43)
    at new HDNode (/Users/vanxh/codes/bitpack/extension/node_modules/@ethersproject/hdnode/lib/index.js:74:110)
    at Function.HDNode._fromSeed (/Users/vanxh/codes/bitpack/extension/node_modules/@ethersproject/hdnode/lib/index.js:211:16)
    at Function.HDNode.fromMnemonic (/Users/vanxh/codes/bitpack/extension/node_modules/@ethersproject/hdnode/lib/index.js:218:23)
    at Function.Wallet.fromMnemonic (/Users/vanxh/codes/bitpack/extension/node_modules/@ethersproject/wallet/lib/index.js:235:43)
    at /Users/vanxh/codes/bitpack/extension/z.js:7:41
    at Object.<anonymous> (/Users/vanxh/codes/bitpack/extension/z.js:13:3)
    at Module._compile (node:internal/modules/cjs/loader:1097:14) {
  opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
  library: 'digital envelope routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_EVP_UNSUPPORTED'
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
ricmoocommented, Aug 19, 2022

Fixed in v5.7.0.

Thanks! 😃

1reaction
ricmoocommented, Jul 14, 2022

As a note for those that need a quick fix, the RIPEMD-160 was removed from the default crypto provider, you can re-enable it on the node command line using --openssl-legacy-provider.

I’ll use the software implementation in hash.js starting in v5.7.0 so this won’t be necessary after that release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Ethers.js
Returns a Promise which will stall until the network has heen established, ignoring errors due to the target node not being active yet....
Read more >
@ethersproject/wallet - npm
Classes for managing, encrypting and decrypting Ethereum private keys as a Signer for ethers.. Latest version: 5.7.0, last published: 4 ...
Read more >
How to set private key for Ethers Signer
My question is: Where should I provide my private key? I mean - the provider requires me to give only a node url...
Read more >
Wallets and Signers — ethers.js 4.0.0 documentation
A Wallet manages a private/public key pair which is used to cryptographically sign transactions and prove ownership on the Ethereum network.
Read more >
How to connect to Ethereum network with ethers.js - QuickNode
1. When someone thinks of developing a dApp the first tool that comes to their mind is web3.js which is ... 2. First,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found