Last active
August 6, 2021 11:26
-
-
Save percybolmer/e51eb32e14dbaf7a4e0174d8bb98a567 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this will trigger whenever the App function is called, which index.js runs at startup | |
useEffect(() => { | |
// Here we check if there is web3 support | |
if (typeof web3 !== 'undefined') { | |
window.web3 = new Web3(window.web3.currentProvider) | |
// Check if its MetaMask that is installed | |
if (window.web3.currentProvider.isMetaMask === true) { | |
connectMetaMask(); | |
connectToSelectedNetwork(); | |
} else { | |
// Another web3 provider, add support if you want | |
} | |
}else { | |
// The browser has no web3 | |
// Suggest the user to install a web3 compatible browser plugin | |
throw new Error("No web3 support, redirect user to a download page or something :) "); | |
} | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment