Closed swatijindal12 closed 9 months ago
Hey @A-Feder Can you please provide me solution?
Hi @swatijindal12 , we are reviewing this and will get back to you ASAP. Please, refrain from opening multiple issues for this.
For completeness, I am including the information you already provided below:
When adding custom network MetaMask SDK does not find chain ID and crashes Platform: React Native MetaMask SDK Version: "@metamask/sdk": "^0.1.0" MetaMask App Version: 7.10.0 (Android)
Additional Info: Ethereum testnets are working fine, others (e.g. Polygon, private networks) present the issue
Hey @swatijindal12 , can you please make sure to update the SDK to its latest version and inform me if the issue persists?
Can you please let me know latest version?
Right now, i am using metamask SDK version 0.1.0 But when i used lastest version i.e. 0.12.0 Then, I am getting error:
Hi @swatijindal12 ! The latest version of the SDK is 0.12.0. Can you please try our reactNative Example to see if the issue still persists?
Also, about the chainSwitching issue you reported, there is currently an issue we're investigating related to the error codes being returned. For the time being, you'll be able to act on both error codes (even though only one should be used) by checking:
if (error.code === -32603 || error.code === 4902) {
// Add Chain
}
We're sorry for the inconvenience.
Okay. Will try & let you know.
Hey @A-Feder , i am facing one more issue when i am connecting metamask through mobile app in my application then i save provider & signer in the context. But when i integrate smart contarct using ethers & sign tx using metamask i have to again connect to metamask & got provider.
The issue is that i have to reconnect metamask everytime in mobile app.
Hi @swatijindal12 ! Can you please share the specific steps to reproduce this issue?
Hi, Once we have connected with sdk and execute smart contract method after that when we try to execute smart contract method again, we are getting this error "Error: Error: MetaMask is not connected/installed, please call eth_requestAccounts to connect first." To resolve this issue as per the documentation - "You can configure the SDK using any options and call any provider API methods. Always call eth_requestAccounts using ethereum.request(args) first, since it prompts the installation or connection popup to appear." To unblock us, currently before calling any smart contract method i am calling wallet connect method.
Hi! That's correct, that should always be the first step. Keep in mind that when using deeplinks it needs to come from the user interaction so that it actually acts as a deeplink and establishes the connection. Without the exact contract call you're trying to execute we are unable to replicate your issue. Would it be possible to share that piece of code?
Here i attached. Please let me know.
Hi @swatijindal12 ! We will be updating the reactNativeDemo in the coming days to take advantage of the sdk-react package long side the hooks that it provides. This should ease the use of the SDK without having to use a custom context and in the end simplify your code. We'll update this issue once it is available.
Hi @swatijindal12 ! We recently updated the reactNativeDemo. You can find the docs for it here. Also, for future reference, we recently added a reactNative demo that uses expo.
Code sample
i am using this code
try { console.log("hello2"); await ethereum.request({ method: 'wallet_switchEthereumChain', params: [{ chainId: '0x483' }], }); } catch (switchError) { console.log("hello3"); // This error code indicates that the chain has not been added to MetaMask. if (switchError.code === 4902) { try { console.log("hello4"); await ethereum.request({ method: 'wallet_addEthereumChain', params: [ { chainId: '0x483', chainName: 'Quorum', rpcUrls: ['https://...........'] , }, ], }); } catch (addError) { // handle "add" error } } // handle other "switch" errors }