I am building a web3 and I have a problem where the page doesn't load if the browser doesn't detect Metamask (or web3 app) and it loads and works perfectly otherwise.
I looked at the browser's Console, in the case where Metamask isn't installed and saw this error:
Uncaught Error: missing provider (argument="provider", value=undefined, code=INVALID_ARGUMENT, version=providers/5.7.2)
in my source code I have these lines in the global variables section (right before the function Main() {
line):
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
so I am assuming when Metamask isn't install, this first line is causing a trouble that I can't seem to avoid or fix, and I am unable to find a way to put them inside the Main()
function because many inner functions use them (inside Main).
I have tried so many things so far and searched a lot. Any idea how I can fix this. Thanks