Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ethereum stack exchange question
if (typeof window !== "undefined" && typeof window.web3 !== "undefined") {
// In the browser and metamask is running
web3 = new Web3(window.web3.currentProvider);
} else {
// We are on the server *OR* the user is not running metamask
const provider = new Web3.providers.HttpProvider(
web3 = new Web3(provider);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment