The sample code here for deploying to Ropsten used HDWalletProvider and a mnemonic in the config, 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: "",
      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

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.

|improve this answer|||||
  • Is HDWalletProvider secure for production use? Or only testing? – M H Aug 14 '18 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 Aug 14 '18 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 Aug 14 '18 at 18:21
  • @MH A better place to ask about that should be reddit.com/r/ethdev or reddit.com/r/ethereum – Ismael Aug 14 '18 at 19:40

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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