Created
December 23, 2019 06:49
-
-
Save ryanpedersen42/4ab0795873f2d3fc846f3ddf20c9f5c7 to your computer and use it in GitHub Desktop.
load web3 App.jsx
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