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.

Cannot read property 'replace' of undefined for truffle-hdwallet-provider

See original GitHub issue

Issue

truffle migrate error:

Cannot read property 'replace' of undefined caused by truffle-hdwallet-provider. 

I have tried to install truffle-hdwallet-provider by

npm install --save truffle-hdwallet-provider@web3-one

It works before and now it broken again. My experience is that “truffle-hdwallet-provider” is not very stable and often caused by version mismatch of web3. Don’t know the root cause for this issue.

Environment

Operating System: MacOS truffle-hdwallet-provider: 1.0.8 truffle version: v5.0.15. Node: v10.15.3 npm: 6.9.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
CruzMolinacommented, May 9, 2019

@chaosma, I believe you need to pass a thunk that returns a new HDWalletProvider.

For example:

module.exports = {
  networks: {
    ropsten: {
      provider: () => {
        return new HDWalletProvider(
          privateKeys,
          "https://ropsten.infura.io/v3/" + process.env.INFURA_API_KEY,
          0,
          1
        );
      },
      network_id: 3, // Ropsten's id
      gas: 5500000, // Ropsten has a lower block limit than mainnet
      skipDryRun: true
    },
    main: {
      provider: () => {
        return new HDWalletProvider(
          privateKeys,
          "https://mainnet.infura.io/v3/" + process.env.INFURA_API_KEY,
          0,
          1
        );
      },
      network_id: 1,
      gas: 5700000,
      gasPrice: 10000000000
    }
  }
};
0reactions
CruzMolinacommented, May 13, 2019

Sweet! Glad to hear that @chaosma 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

ConsenSys/truffle - Gitter
I keep seeing it on the debugger for many of the smart contracts I do. (TypeError: Cannot read property 'replace' of undefined)
Read more >
@truffle/hdwallet-provider - npm
Start using @truffle/hdwallet-provider in your project by running `npm i @truffle/hdwallet-provider`. There are 357 other projects in the ...
Read more >
Why is truffle migration failing to deploy contracts? "cannot ...
The following code should work : const SushiToken = artifacts.require("./SushiToken.sol") module.exports = function(deployer) ...
Read more >
js: TypeError: Cannot read property 'replace' of undefined using
I wanted to replace /\r?\n|\r/g with empty string but got a type error "Cannot read property 'replace' of undefined".
Read more >
Truffle: deployProxy error: Cannot read property 'evm' of ...
I get the typeError cannot read property EVM of undefined deploying this ... truffle-hdwallet-provider has been deprecated, so we should use ...
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