Created
December 26, 2019 18:41
-
-
Save ryanpedersen42/8503c1b11d521c10caf20e10a1e59c64 to your computer and use it in GitHub Desktop.
web3 Auth
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
loadWeb3 = async () => { | |
const { setEthAddress } = this.props; | |
if (window.ethereum) { | |
window.web3 = new Web3(window.ethereum) | |
const ethAddresses = await window.ethereum.enable() | |
const ethAddress = ethAddresses[0] | |
await setEthAddress(ethAddress) | |
} | |
else if (window.web3) { | |
window.web3 = new Web3(window.web3.currentProvider) | |
} | |
else { | |
window.alert('Non-Ethereum browser detected!') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment