Skip to content
Permalink
456626ea42
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
21 lines (16 sloc) 685 Bytes
const Web3 = require("web3");
let web3;
const apiLink = "https://rinkeby.infura.io/v3/4b6cf47f5f6e4aca850c45c04a58cf0d";
if (typeof window !== 'undefined' && typeof window.web3 !== 'undefined') {
// we are in the browser and metamask is running
web3 = new Web3(window.web3.currentProvider);
} else {
// we are on the server or user is not running metamask
// set up our own provider that works through infura
const provider = new Web3.providers.HttpProvider(apiLink
// pass url of remote node
// 'https://mainnet.infura.io/v3/4b6cf47f5f6e4aca850c45c04a58cf0d'
);
web3 = new Web3(provider);
}
module.exports = web3;