2014-09-30 15:51:53 -05:00
|
|
|
<!doctype>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
2014-11-05 11:46:01 -06:00
|
|
|
<script type="text/javascript" src="js/es6-promise/promise.min.js"></script>
|
2015-01-16 09:04:41 -06:00
|
|
|
<script type="text/javascript" src="js/bignumber.js/bignumber.min.js"></script>
|
2014-11-11 08:47:58 -06:00
|
|
|
<script type="text/javascript" src="../dist/ethereum.js"></script>
|
2014-09-30 15:51:53 -05:00
|
|
|
<script type="text/javascript">
|
2014-11-13 12:28:58 -06:00
|
|
|
|
2014-11-12 21:21:51 -06:00
|
|
|
var web3 = require('web3');
|
2015-01-21 13:29:02 -06:00
|
|
|
web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
|
2014-11-12 21:21:51 -06:00
|
|
|
|
2014-11-13 12:28:58 -06:00
|
|
|
function watchBalance() {
|
|
|
|
var coinbase = web3.eth.coinbase;
|
|
|
|
var originalBalance = 0;
|
|
|
|
|
2015-01-21 14:12:07 -06:00
|
|
|
var balance = web3.eth.balanceAt(coinbase);
|
|
|
|
var originalBalance = web3.toDecimal(balance);
|
|
|
|
document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
|
2014-11-13 12:28:58 -06:00
|
|
|
|
|
|
|
web3.eth.watch({altered: coinbase}).changed(function() {
|
2015-01-21 14:12:07 -06:00
|
|
|
balance = web3.eth.balanceAt(coinbase)
|
|
|
|
var currentBalance = web3.toDecimal(balance);
|
|
|
|
document.getElementById("current").innerText = 'current: ' + currentBalance;
|
|
|
|
document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance);
|
2014-11-03 10:46:56 -06:00
|
|
|
});
|
2014-11-12 21:21:51 -06:00
|
|
|
}
|
2014-09-30 15:51:53 -05:00
|
|
|
|
2014-11-13 12:28:58 -06:00
|
|
|
</script>
|
|
|
|
</head>
|
2014-09-30 15:51:53 -05:00
|
|
|
<body>
|
2014-11-14 06:11:47 -06:00
|
|
|
<h1>coinbase balance</h1>
|
2014-11-13 12:28:58 -06:00
|
|
|
<button type="button" onClick="watchBalance();">watch balance</button>
|
2014-11-12 21:21:51 -06:00
|
|
|
<div></div>
|
2014-11-13 12:28:58 -06:00
|
|
|
<div id="original"></div>
|
|
|
|
<div id="current"></div>
|
|
|
|
<div id="diff"></div>
|
2014-09-30 15:51:53 -05:00
|
|
|
</body>
|
|
|
|
</html>
|
2014-11-12 21:21:51 -06:00
|
|
|
|