when I try to connect to my wallet from trust wallet browser, it redirects me to google
The code is like this which is just as the same as trustWallet doc
- how can I properly connect to the wallet connect?
- 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);
Just ran across this by chance. To answer your second question, to connect to specific Testnet chain:
options.rpc
node, ensuring the "gas token" is also correctly set in thenetwork
nodeConsidering WalletConnect v1 has been deprecated (as of writing this), if you happen to move to using Web3Modal and WalletConnect v2, you could import chain defaults from '@wagmi/core/chains', then use in the "defaultChain".