-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
34 lines (32 loc) · 1.31 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
<!doctype>
<html>
<head>
<script type="text/javascript" src="../node_modules/bignumber.js/bignumber.min.js"></script>
<script type="text/javascript" src="../dist/web3-light.js"></script>
<script type="text/javascript">
var Web3 = require('web3');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider());
function watchBalance() {
var conduitAccount = web3.eth.accounts[0];
var originalBalance = web3.eth.getBalance(conduitAccount).toNumber();
document.getElementById('conduitAccount').innerText = 'conduitToken: ' + conduitAccount;
document.getElementById('original').innerText = ' original balance: ' + originalBalance + ' watching...';
web3.eth.filter('latest').watch(function() {
var currentBalance = web3.eth.getBalance(coinbase).toNumber();
document.getElementById("current").innerText = 'current: ' + currentBalance;
document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
});
}
</script>
</head>
<body>
<h1>coinbase balance</h1>
<button type="button" onClick="watchBalance();">watch balance</button>
<div></div>
<div id="conduitAccount"></div>
<div id="original"></div>
<div id="current"></div>
<div id="diff"></div>
</body>
</html>