9

The sample code here for deploying to Ropsten used HDWalletProvider and a mnemonic in the configuration, but I am not sure I understand its purpose.

Is this just telling it the account that will become the contract owner when you deploy?

var HDWalletProvider = require("truffle-hdwallet-provider");

// 12-word mnemonic
var mnemonic = process.env.NMEMONIC;

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*" // Match any network id
    },
    ropsten: {
      provider: new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"),
      network_id: 3 // official id of the ropsten network
    }
  }
};

3 Answers 3

5

The Truffle HDWallet provider is a convenient and easy to configure network connection to ethereum through infura.io (or any other compatible provider).

For example the HDWallet provider add some features required by Truffle that are not available with infura like event filtering and transaction signing.

4
  • Is HDWalletProvider secure for production use? Or only testing?
    – M H
    Commented Aug 14, 2018 at 5:34
  • @MH I didn't have any problem when I used it, but I can't vouch for it to be error free. In my experience Truffle developers were fast to respond when I reported other issues with ganache/truffle.
    – Ismael
    Commented Aug 14, 2018 at 15:39
  • I was more asking about the security. Can I use HDWalletProvider with a wallet and be sure someone isn't viewing my mnemonic? I understand if you dont know. I wanted to hear from everyone.
    – M H
    Commented Aug 14, 2018 at 18:21
  • @MH A better place to ask about that should be reddit.com/r/ethdev or reddit.com/r/ethereum
    – Ismael
    Commented Aug 14, 2018 at 19:40
4

When deploying a contract you eventually need to sign a transaction with an account (with a private key).

This account management process is handled by the provider, in this case, the @truffle/hdwallet-provider (Note that truffle-hdwallet-provider is deprecated). This could be another provider like Metamask or a local Web3 provider.

0

HDWallet provider is used by truffle when we deploy the contract however metamask providers are used when we want to interact with the contract in the browser.

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.