I am stuck when deploying a Smart Contract to rinkeby testnet by running (on macOS 12.1) this:

sudo truffle migrate --reset --network rinkeby

The contract compiles and I can deploy it locally, but migration to testnet fails, returning this error:

Error: error:0308010C:digital envelope routines::unsupported
    at new Hash (node:internal/crypto/hash:67:19)
    at Object.createHash (node:crypto:130:10)
    at createHash (/Users/mac/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/hdkey/lib/hdkey.js:238:1)
    at f.hash160 (/Users/mac/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/hdkey/lib/hdkey.js:39:1)
    at Function.privateKey [as fromMasterSeed] (/Users/mac/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/hdkey/lib/hdkey.js:183:1)
    at Function.fromMasterSeed (/Users/mac/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/Users/gnidan/src/work/truffle/node_modules/ethereumjs-wallet/hdkey.js:18:1)
    at fromMasterSeed (/Users/mac/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/src/index.js:57:1)
    at new checkBIP39Mnemonic (/Users/mac/node_modules/truffle-hdwallet-provider/dist/webpack:/truffle-hdwallet-provider/src/index.js:90:1)
    at Object.provider (/Users/mac/learning/Blockchain/TestToken1/truffle-config.js:21:16)
    at Object.getProvider (/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:20:1)
    at Object.create (/usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/index.js:13:1)
    at TruffleConfig.get [as provider] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/config/dist/configDefaults.js:249:1)
    at Object.detect (/usr/local/lib/node_modules/truffle/build/webpack:/packages/environment/environment.js:19:1)
    at Object.module.exports [as run] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:22:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)
Truffle v5.4.26 (core: 5.4.26)
Node v17.1.0

Line 10 of this error message points to my truffle-config.js file, in particular to

return new HDWalletProvider(mnemonic, 'https://rinkeby.infura.io/v3/'+infuraKey)

I am using Metamask seed phrase and Infura.

In truffle-config.js, I set up rinkeby connection as follows:

rinkeby: {
  provider: function () {
    return new HDWalletProvider(mnemonic, 'https://rinkeby.infura.io/v3/'+infuraKey);
    network_id: 4,       // rinkeby's id
    gas: 600000000,        // rinkeby has a lower block limit than mainnet
    gasPrice: 10000000000

I have tried:

  • setting an env. variable export NODE_OPTIONS=--openssl-legacy-provider,
  • tripple-checking MNEMONIC and Infura key,
  • Trying multiple Infura projects, to make sure the same contract is not created for the same ID,
  • Increasing gas fees.

Nothing worked so far and suspect the issue is in the sequence of steps I execute the commands.

I suspect the issue is in the sequence I do when setting up the project. I do the following:

  1. Run mkdir project_id,
  2. Run cd project_id,
  3. Run truffle init to initialize a truffle project,
  4. Run npm install --save truffle-hdwallet-provider,
  5. Run npm install openzeppelin-solidity,
  6. Set up contract and migration files, and truffle-config.js,
  7. Run truffle compile
  8. Run truffle migrate --reset
  9. Run truffle migrate --reset --network rinkeby

Initially I thought this could be a Node version issue, but then I managed to run the code successfully once.

Strange results when running the same code

At one moment, I tried to deploy a simpler contract in a different project to test everything works. After returning to the main project and repeating the same Compile->Migrate commands, the contract actually was deployed - I checked this at etherscan. Unfortunately, I noticed a bug afterwards and had to re-run the Compile->Migrate commands. Then, the error shown above the screenshot appeared again.

I tried subsequently to repeat the sequence again, but was not able to successfully migrate the contract.


Anyone knows how to fix this?

1 Answer 1


So I figured out the work-around - I changed the Node version to the latest stable version (v16) and everything worked like a charm. For those who need to change the version, here is a good tutorial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.