https://github.com/trufflesuite/truffle-hdwallet-provider/blob/master/README.md provides sample usage for the deployment configuration inside tuffle.js.
I need a sample that update the Web3 currentProvider inside a web page to be used differently with every user (I will use the code upon a user request after generating the mnemonic seed words)
Thanks to @jsantos, and I found it here also: https://gnosis-apollo.readthedocs.io/en/latest/pm-js-usage.html.
Actually, it was not mentioned in the documentation that the truffle-hdwallet-provider is compatible with Web3 and could be passed in the constructor. I created a pull request for that: https://github.com/trufflesuite/truffle/pull/1850. Bellow is the code snippet:
var HDWalletProvider = require("truffle-hdwallet-provider"); var mnemonic = "mountains supernatural bird..."; // 12 word mnemonic var provider = new HDWalletProvider(mnemonic, "http://localhost:8545"); // Or, alternatively pass in a zero-based address index. var provider = new HDWalletProvider(mnemonic, "http://localhost:8545", 5); // Or, use your own hierarchical derivation path var provider = new HDWalletProvider(mnemonic, "http://localhost:8545", 5, 1, "m/44'/137'/0'/0/"); // HDWalletProvider is compatible with Web3. Use it at Web3 constructor, just like any other Web3 Provider const web3 = new Web3(provider); // Or, if web3 is alreay initialized, you can call the 'setProvider' on web3, web3.eth, web3.shh and/or web3.bzz web3.setProvider(provider) // ... // Write your code here. // ... // At termination, `provider.engine.stop()' should be called to finish the process elegantly. provider.engine.stop();