I have tried everything but just can't get the web3.currentProvider to work. I have metamask installed and working and somehow want to connect the website on the test network. Has there been some recent update which is not reflected in the documentation?
[Ethereum] Unable to connect to metamask using web3
metamaskweb3js
Best Answer
The problem here is likely that you are trying to run your page locally, which is explicitly restricted in MetaMask:
You will need to publish your code to a local server to test MetaMask functionality.
In the situation where you do not need the MetaMask user context, you can use the
HttpProvider
fallback using infura.io:https://github.com/shawntabrizi/ETH-Balance/blob/master/index.html#L13
This should allow you to do basic read operations on the Ethereum blockchain without needing to deploy to a local test server.