connect to walletconnect with web3modal
when I try to connect to my wallet from trust wallet browser, it redirects me to google
[1]: https://i.stack.imgur.com/V4PPx.jpg[2]: https://i.stack.imgur.com/soFxv.jpg
the code is like this which is just as the same as trustWallet doc
1. how can I properly connect to the wallet connect ?
2. is there anyway to connect to testnets like ropsten with wallet connect ?
// set chain id and rpc mapping in provider options
const providerOptions = {
walletconnect: {
package: WalletConnectProvider,
options: {
rpc: {
56: 'https://bsc-dataseed1.binance.org'
},
chainId: 56
}
}
}
const web3Modal = new Web3Modal({
network: "mainnet", // optional
cacheProvider: true, // optional
providerOptions // required
});
const provider = await web3Modal.connect();
await web3Modal.toggleModal();
// regular web3 provider methods
const newWeb3 = new Web3(provider);
const accounts = await newWeb3.eth.getAccounts();
console.log(accounts);
Solution 1:
If i understand you correct, try
const provider = await Web3Modal.connectTo('walletconnect')
instead of
const provider = await web3Modal.connect();
await web3Modal.toggleModal();
UPD: walletConnect is just 'agregator'. you can't connect directly to any wallet (at least first time) you should choose wallet which you want connect to (left tab with button will choose apps on your mobile phone to which it can connect (metamask, trust, ...) and right tab 'qr-code' will show you qr which you can scan with wallet apps (metamask, trust, ...) on another devices). then if 'cacheProvider' is true, you don't need to click it again till disconnect from wallet