I'm using for deploying contracts hdwallet-provider, but I have issue on client side to get multiple accounts using web3.eth.getAccounts() call.
I know this is like duplicate question and truffle already has solution for this, but I have issue getting more than one account address.
On metamask I have three accounts, but only the default one is showing on the client side. From the first snippet u can see that I'm setting 3 as fourth parametar
Deploy code
const provider = new HDWalletProvider(
'mnemonic....',
'https://rinkeby.infura.io/v3/bba91a6c349c44afbde264a1bda1af75', 0, 3
);
How I import web3 in client code
import Web3 from 'web3';
if (window.ethereum) {
window.web3 = new Web3(window.ethereum);
(async () => {
await window.ethereum.enable();
})();
}
// Legacy dapp browsers...
else if (window.web3) {
window.web3 = new Web3(window.web3.currentProvider);
}
// Non-dapp browsers...
else {
console.log('Non-Ethereum browser detected. You should consider trying MetaMask!');
}
export default window.web3;
Client code
web3.eth.getAccounts().then(console.log);
BR, Igor