Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (32 sloc) 1.39 KB
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../node_modules/bignumber.js/bignumber.min.js"></script>
<script type="text/javascript" src="../dist/web3_hpb-light.js"></script>
<script type="text/javascript">
var web3_hpb = require('web3_hpb');
var web3_hpb = new web3_hpb();
web3_hpb.setProvider(new web3_hpb.providers.HttpProvider());
function watchBalance() {
var coinbase = web3_hpb.hpb.coinbase;
var originalBalance = web3_hpb.hpb.getBalance(coinbase).toNumber();
document.getElementById('coinbase').innerText = 'coinbase: ' + coinbase;
document.getElementById('original').innerText = ' original balance: ' + originalBalance + ' watching...';
web3_hpb.hpb.filter('latest').watch(function () {
var currentBalance = web3_hpb.hpb.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="coinbase"></div>
<div id="original"></div>
<div id="current"></div>
<div id="diff"></div>
</body>
</html>
You can’t perform that action at this time.