Created
January 26, 2018 20:51
-
-
Save tko22/5e6c51282b51a0209eaf12287d19cdc2 to your computer and use it in GitHub Desktop.
This file contains 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
// When the page loads, we create a web3 instance and set a provider. We then set up the app | |
window.addEventListener("load", function() { | |
// Is there an injected web3 instance? | |
if (typeof web3 !== "undefined") { | |
console.warn("Using web3 detected from external source like Metamask") | |
// If there is a web3 instance(in Mist/Metamask), then we use its provider to create our web3object | |
window.web3 = new Web3(web3.currentProvider) | |
} else { | |
console.warn("No web3 detected. Falling back to http://localhost:9545. You should remove this fallback when you deploy live, as it's inherently insecure. Consider switching to Metamask for development. More info here: http://truffleframework.com/tutorials/truffle-and-metamask") | |
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail) | |
window.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:9545")) | |
} | |
// initializing the App | |
window.App.start() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment