-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
264c3a9
commit 2681739
Showing
1 changed file
with
16 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
import Web3 from "web3"; | ||
let web3; | ||
if (window.web3 !== undefined) { | ||
web3 = new Web3(window.web3.currentProvider); | ||
} else { | ||
const provider = new Web3.providers.HttpProvider( | ||
"https://sepolia.infura.io/v3/ad38a519efd04371b5e1dc45843d733c" | ||
); | ||
web3 = new Web3(provider); | ||
} | ||
const web3 = new Web3(window.web3.currentProvider); | ||
window.addEventListener("load", async () => { | ||
if (window.ethereum) { | ||
window.web3 = new Web3(window.ethereum); | ||
try { | ||
await window.ethereum.enable(); | ||
} catch (error) {} | ||
} else if (window.web3) { | ||
window.web3 = new Web3(web3.currentProvider); | ||
} else { | ||
const provider = new Web3.providers.HttpProvider( | ||
"https://sepolia.infura.io/v3/ad38a519efd04371b5e1dc45843d733c" | ||
); | ||
web3 = new Web3(provider); | ||
} | ||
}); | ||
export default web3; |