I am using
truffle-hdwallet-provider to connect to the node that operates over https and it works perfectly. Now I want to connect to websocket-powered node but keep my HD Wallet provider. I cannot find how to do that. All I found is package
web3-providers-ws but cannot find is it possible (and how) to chain multiple providers?
I am using
In https://github.com/trufflesuite/truffle-hdwallet-provider/blob/master/index.js, it is hard coded to use HttpProvider
You would need to fork and modify this line of code:
this.engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider(provider_url)));
this.engine.addProvider(new Web3Subprovider(new Web3.providers.WebsocketProvider(provider_url)));
I will give it a try some day and get back to this thread...
You can pass an instance of the provider instead of a string as a second argument. So you can pass a websocket provider in:
const webSocketProvider = new Web3.providers.WebsocketProvider(...); const walletProvider = new HDWalletProvider(mnemonic, webSocketProvider);