-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
86 lines (66 loc) · 2.85 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<title>Learning Solidity</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="styles/style.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<a class="navbar-brand" href="#">Learning Solidity</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<div class="container">
<div class="spacer"></div>
<div>
<h1>Ethereum Balance</h1>
</div>
<div class="row">
<div class="col-md-7">
<div id="balances"></div>
<div class="alert alert-dark" role="alert">
<pre>
function getBalances(provider) {
var ethWeb3 = new Web3(provider);
ethWeb3.eth.getAccounts(function (err, accounts) {
for(var i = 0; i < accounts.length; i++) {
var account = accounts[i];
ethWeb3.eth.getBalance(accounts[i], function (err, balance) {
addBalance(account, ethWeb3.fromWei(balance, 'ether'));
})
}
});
}
</pre>
</div>
</div>
<div class="col-md-5">
<div id="no-meta-mask" class="alert alert-danger" role="alert">
<i class="fa fa-times" aria-hidden="true"></i> Metamask installed
</div>
<div id="has-metamask" class="alert alert-success" role="alert">
<i class="fa fa-check" aria-hidden="true"></i> Metamask installed
</div>
<div class="alert alert-dark" role="alert">
<pre>
if (typeof window.web3 !== 'undefined') {
getBalances(web3.currentProvider);
$('#no-meta-mask').hide();
} else {
$('#has-metamask').hide();
}
</pre>
</div>
</div>
</div>
</div>
<script src="scripts/metamask.js"></script>
</body>
</html>