2014-09-30 20:51:53 +00:00
|
|
|
<!doctype>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
2015-03-30 07:11:56 +00:00
|
|
|
<script type="text/javascript" src="../node_modules/bignumber.js/bignumber.min.js"></script>
|
2015-04-07 02:39:47 +00:00
|
|
|
<script type="text/javascript" src="../dist/web3-light.js"></script>
|
2014-09-30 20:51:53 +00:00
|
|
|
<script type="text/javascript">
|
2014-11-13 18:28:58 +00:00
|
|
|
|
2015-04-07 02:39:47 +00:00
|
|
|
var web3 = require('web3');
|
2015-03-10 09:47:44 +00:00
|
|
|
web3.setProvider(new web3.providers.HttpProvider());
|
2014-11-13 03:21:51 +00:00
|
|
|
|
2014-11-13 18:28:58 +00:00
|
|
|
function watchBalance() {
|
|
|
|
var coinbase = web3.eth.coinbase;
|
|
|
|
|
2015-03-09 13:19:42 +00:00
|
|
|
var originalBalance = web3.eth.getBalance(coinbase).toNumber();
|
|
|
|
document.getElementById('coinbase').innerText = 'coinbase: ' + coinbase;
|
|
|
|
document.getElementById('original').innerText = ' original balance: ' + originalBalance + ' watching...';
|
2014-11-13 18:28:58 +00:00
|
|
|
|
2015-03-09 13:19:42 +00:00
|
|
|
web3.eth.filter('pending').watch(function() {
|
|
|
|
var currentBalance = web3.eth.getBalance(coinbase).toNumber();
|
2015-01-21 20:12:07 +00:00
|
|
|
document.getElementById("current").innerText = 'current: ' + currentBalance;
|
|
|
|
document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
|
2014-11-03 16:46:56 +00:00
|
|
|
});
|
2014-11-13 03:21:51 +00:00
|
|
|
}
|
2014-09-30 20:51:53 +00:00
|
|
|
|
2014-11-13 18:28:58 +00:00
|
|
|
</script>
|
|
|
|
</head>
|
2014-09-30 20:51:53 +00:00
|
|
|
<body>
|
2014-11-14 12:11:47 +00:00
|
|
|
<h1>coinbase balance</h1>
|
2014-11-13 18:28:58 +00:00
|
|
|
<button type="button" onClick="watchBalance();">watch balance</button>
|
2014-11-13 03:21:51 +00:00
|
|
|
<div></div>
|
2015-03-09 13:19:42 +00:00
|
|
|
<div id="coinbase"></div>
|
2014-11-13 18:28:58 +00:00
|
|
|
<div id="original"></div>
|
|
|
|
<div id="current"></div>
|
|
|
|
<div id="diff"></div>
|
2014-09-30 20:51:53 +00:00
|
|
|
</body>
|
|
|
|
</html>
|
2014-11-13 03:21:51 +00:00
|
|
|
|