walletconnect-dart-sdk
walletconnect-dart-sdk copied to clipboard
Switch Network popup
Hello,
Is there a way in which I can provide a SwitchNetwork popup to the user?
just like the below-attached screenshot
Does any one have any idea about showing the switch network popup?
Are you trying to show a popup in your own wallet or call the MetaMask switch network popup?
@RootSoft I want to call the MetaMask switchNetwork popup,
@RootSoft Could you please update on this? Thanks :)
@RootSoft Any update on my query?
@VivekMakwana24 I don't think it's possible to do that since that's native to MM, and I don't think they provide an API to show the switch network popup. Your best bet would be to ask in the MM repo?
Ok let me check with them, I have found the below link, do you think it will be useful? https://community.metamask.io/t/how-to-send-switch-network-request-from-dapp-to-metamask-mobile/13501
@RootSoft Below is the code that I have tried, but unfortunately I am not getting any response from it.
`
Future<dynamic> switchNetwork() async {
final request = JsonRpcRequest(
id: payloadId,
method: 'wallet_switchEthereumChain',
params: [
{
"chainId": "0xa86a",
}
],
);
session.handshakeId = request.id;
session.handshakeTopic = const Uuid().v4();
debugPrint("req2 ${request.toJson()}");
final response = await sendRequest(request, topic: session.handshakeTopic);
debugPrint("response ${response}");
return response;
}
` Request : {id: 1660718671093646, jsonrpc: 2.0, method: wallet_switchEthereumChain, params: [{chainId: 0xa86a}]} Response : null
Any updates on this issue? I am also trying to switch the network but no luck.
@robmagario No, I have tried by contacting the walletConnect community but no solution yet
@VivekMakwana24 I think you'll have to dig in the Metamask source code. Maybe build the app and step through it. Unfortunately, at the moment I don't have a lot of time to dig deep into this. This is more related to Metamask then WC in my opinion.
@VivekMakwana24 Try this
await connector.sendCustomRequest( method: 'wallet_switchEthereumChain', params: [ { 'chainId': '0x${provider.chainId.toRadixString(16)}', }, ], );
@olegys Did it worked with metamask?
@VivekMakwana24 Yes
@olegys
This is how I have tried it, But Unfortunately, I am receiving null response.
I tried to call this method before launching the walletURI for connection.
Is it the correct flow?