Skip to content

Instantly share code, notes, and snippets.

Embed
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(
"https://rinkeby.infura.io/v3/bb20540179824ccb94cf748904d43090"
);
web3 = new Web3(provider);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment