Skip to content

Instantly share code, notes, and snippets.

@ankitbrahmbhatt1997
Created March 17, 2019 15:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitbrahmbhatt1997/ea7b647a178897290db0dcc556bc159c to your computer and use it in GitHub Desktop.
Save ankitbrahmbhatt1997/ea7b647a178897290db0dcc556bc159c to your computer and use it in GitHub Desktop.
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