-
Notifications
You must be signed in to change notification settings - Fork 1
/
web3.js
29 lines (26 loc) · 1008 Bytes
/
web3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const Web3 = require("web3");
let web3;
if (typeof window !== "undefined" && window.web3 !== undefined) {
//we are in the browser && metamask is running
web3 = new Web3(window.web3.currentProvider);
} else {
//We on the server or the user in not running metmask
const provider = new Web3.providers.HttpProvider(
"https://rinkeby.infura.io/v3/c3085f6dbf9347358b5ab5d30de1fdbe"
);
web3 = new Web3(provider);
}
export default web3;
// if (typeof window !== "undefined" && window.web3 !== undefined) {
// //we are in the browser && metamask is running
// web3 = new Web3(window.web3.currentProvider);
// } else {
// //We on the server or the user in not running metmask
// // const provider = new Web3.providers.HttpProvider(
// // "https://rinkeby.infura.io/v3/c3085f6dbf9347358b5ab5d30de1fdbe"
// // );
// var provider = new Web3.providers.HttpProvider(
// "https://christopherigbojekwe:<password>@christopherigbojekwe.blockchain.azure.com:3200"
// );
// web3 = new Web3(provider);
// }