Consider this example:
https://opentarget.org/test/stupid/mm/wc/index2.html
Ignore the "Send Transaction" button, just consider the "Connect" one, which is yours.
This attempts to connect to the BNB Smart Chain.
If you do this with MetaMask browser extension (choosing Metamask when asked to choose wallet, that is using the MetaMask API), and the currently selected network is not BSC, but BSC is configured, then MetaMask will prompt to switch network as expected.
But if you do not have the BSC network set up in Networks, it will not prompt to add it.
Prompting to add a network is trivial. Look at this example:
https://opentarget.org/test/stupid/mm/trans/
This does the following:
- if BSC is already configured and is already the current network, just prompts to connect, just like you do
- if BSC is configured but is not the current network, prompts to switch network and connect, just like you do
- if BSC is not configured, prompts to add it, switch to it and connect
(my example then also proceeds to request a transaction but that's irrelevant.)
I believe this can be done also with WalletConnect, but of that I'm not 100% sure. What's 100% sure is it can be done when choosing the MetaMask API, and I'm almost sure with Binance Wallet too, since their API is pretty much copied from MetaMask's.
Consider this example:
https://opentarget.org/test/stupid/mm/wc/index2.html
Ignore the "Send Transaction" button, just consider the "Connect" one, which is yours.
This attempts to connect to the BNB Smart Chain.
If you do this with MetaMask browser extension (choosing Metamask when asked to choose wallet, that is using the MetaMask API), and the currently selected network is not BSC, but BSC is configured, then MetaMask will prompt to switch network as expected.
But if you do not have the BSC network set up in Networks, it will not prompt to add it.
Prompting to add a network is trivial. Look at this example:
https://opentarget.org/test/stupid/mm/trans/
This does the following:
(my example then also proceeds to request a transaction but that's irrelevant.)
I believe this can be done also with WalletConnect, but of that I'm not 100% sure. What's 100% sure is it can be done when choosing the MetaMask API, and I'm almost sure with Binance Wallet too, since their API is pretty much copied from MetaMask's.