Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MetaMask Browser extension not detected #664

Closed
migbash opened this issue Feb 19, 2023 · 5 comments
Closed

MetaMask Browser extension not detected #664

migbash opened this issue Feb 19, 2023 · 5 comments

Comments

@migbash
Copy link

migbash commented Feb 19, 2023

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...

@andreahaku
Copy link
Contributor

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.

@alexandratran
Copy link
Contributor

Closing due to no further response.

@jimgreen2013
Copy link

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.

@alexandratran
Copy link
Contributor

Hi @jimgreen2013, can you post this issue in https://github.com/metamask/metamask-sdk?

@jimgreen2013
Copy link

Hi @jimgreen2013, can you post this issue in https://github.com/metamask/metamask-sdk?

Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants