Skip to content

Instantly share code, notes, and snippets.

@TravisMullen
Created June 5, 2017 22:35
Show Gist options
  • Save TravisMullen/02a7256fd3d1eaca710e8c98624fe5ac to your computer and use it in GitHub Desktop.
Save TravisMullen/02a7256fd3d1eaca710e8c98624fe5ac to your computer and use it in GitHub Desktop.
function loadWeb3 () {
let web3Injected = window.web3;
if(typeof web3Injected !== 'undefined'){
// detect MetaMask.io
web3 = new Web3(web3Injected.currentProvider)
} else {
// eth node
web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment