-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
50 lines (46 loc) · 1.29 KB
/
index.html
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
<head>
<title>Hello</title>
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
</head>
<body>
<p>hello 123</p>
</body>
<script>
console.log("start");
var connected = false;
async function connectToWeb3() {
if (!connected) {
if (window.ethereum) {
window.web3 = new Web3(ethereum);
try {
// Request account access if needed
await ethereum.enable();
// Acccounts now exposed
connected = true;
} catch (error) {
// User denied account access...
}
} else if (window.web3) {
window.web3 = new Web3(web3.currentProvider);
// Acccounts always exposed
connected = true;
} else {
console.log('Non-Ethereum browser detected. You should consider trying MetaMask!');
}
}
}
var TOEKNCONTRACTADDRESS = "0xf9834a2e213626de786b4d358441d5f4b1d681f8";
async function doIt() {
console.log("Ping connected=" + connected);
connectToWeb3();
}
function timeoutCallback() {
doIt();
setTimeout(function() {
timeoutCallback();
}, 2500);
}
timeoutCallback();
</script>
</html>