Last active
August 6, 2021 11:26
-
-
Save percybolmer/222e4dd1b8410f11bc873badae79a7ac 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
// connectMetaMask is used to connect to MetaMask and ask permission to grab account information | |
function connectMetaMask() { | |
// We need to make the connection to MetaMask work. | |
// Send Request for accounts and to connect to metamask. | |
window.web3.requestAccounts() | |
.then((result) => { | |
// Whenever the user accepts this will trigger | |
setAccounts(result); | |
}) | |
.catch((error) => { | |
// Handle errors, such as when a user does not accept | |
throw new Error(error); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment