MetaMask Browser extension not detected
I have tried using the pure JS implementation of the provided guide => https://c0f4f41c-2f55-4863-921b-sdk-docs.github.io/guide/metamask-sdk-js/metamask-sdk-pure-javascript.html
Works all well on my mobile device to open the target MetaMask application, however, on the browser, it does not seem to detect my MetaMask already installed extension... Is this meant to be like this ? I have noticed that on the https://recordit.co/g9u0X2S60Z link, the use of the Browser Extension is not shown, only via the QR-Code Signing...
Hi, in the recording there is no extension installed, that's why the connection is made with MM SDK. MM SDK checks if the extension is installed, and if so then it shouldn't show the modal but simply open the extension.
Which browser are you using? Also, the pure javascript minified file needs to be updated with the latest version of the MM SDK and we'll do it in a very few days.
Thanks for reporting this.
Closing due to no further response.
I have the same problem, please help!
package.json
{
"name": "@metamask/sdk-pure-javascript-example",
"version": "1.0.0",
"private": true,
"description": "An example use of the MetaMask SDK on pure-javascript",
"repository": {
"type": "git",
"url": "https://github.com/MetaMask/sdk.git"
},
"license": "ISC",
"main": "src/index.js",
"files": [
"dist/"
],
"scripts": {
"start": "serve .",
"allow-scripts": "echo 'n/a'"
},
"dependencies": {
"@metamask/sdk": "^0.18.5",
"serve": "13.0.2"
}
}
My helloworld html
<!doctype html>
<html>
<head>
<script src="node_modules/@metamask/sdk/dist/browser/iife/metamask-sdk.js"></script>
<script>
const sdk = new MetaMaskSDK.MetaMaskSDK({
dappMetadata: {
name: "Pure JS example",
url: window.location.host,
},
logging: {
sdk: true,
}
});
</script>
<script>
let provider;
function connect() {
console.log('connect button clicked')
sdk.connect()
.then((res) => {
console.log('sdk.connect.then')
provider = sdk.getProvider();
console.log(provider.isMetaMask)
})
.catch((e) => console.log('request accounts ERR', e));
}
function addEthereumChain() {
provider
.request({
method: 'wallet_addEthereumChain',
params: [
{
chainId: '0x89',
chainName: 'Polygon',
blockExplorerUrls: ['https://polygonscan.com'],
nativeCurrency: { symbol: 'MATIC', decimals: 18 },
rpcUrls: ['https://polygon-rpc.com/'],
},
],
})
.then((res) => console.log('add', res))
.catch((e) => console.log('ADD ERR', e));
}
</script>
</head>
<body>
<button onclick="connect()">Connect</button>
<button onclick="addEthereumChain()">ADD ETHEREUM CHAIN</button>
</body>
</html>
I've tried different browsers: Firefox Chromium and Brave. All failed to detect Metamask extesion.
Hi @jimgreen2013, can you post this issue in https://github.com/metamask/metamask-sdk?
Hi @jimgreen2013, can you post this issue in https://github.com/metamask/metamask-sdk?
Sure