aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/mist/assets/examples/balance.html
diff options
context:
space:
mode:
authorEthan Buchman <ethan@coinculture.info>2015-02-18 08:25:18 +0800
committerEthan Buchman <ethan@coinculture.info>2015-02-18 08:25:18 +0800
commit2ba65f4fbaea49c1e0d99959b0331e09b153f931 (patch)
treeadd8cabb05cd7fbf0ba4b4bbaf9460dacfc2082d /cmd/mist/assets/examples/balance.html
parent2da367a2bee84d74d1bb0ea1b42d4c22fae486dd (diff)
parent60318c96d03bcaaf731802b1080a3d87cb482124 (diff)
downloaddexon-2ba65f4fbaea49c1e0d99959b0331e09b153f931.tar
dexon-2ba65f4fbaea49c1e0d99959b0331e09b153f931.tar.gz
dexon-2ba65f4fbaea49c1e0d99959b0331e09b153f931.tar.bz2
dexon-2ba65f4fbaea49c1e0d99959b0331e09b153f931.tar.lz
dexon-2ba65f4fbaea49c1e0d99959b0331e09b153f931.tar.xz
dexon-2ba65f4fbaea49c1e0d99959b0331e09b153f931.tar.zst
dexon-2ba65f4fbaea49c1e0d99959b0331e09b153f931.zip
Merge branch 'develop' of https://github.com/ethereum/go-ethereum into develop
Diffstat (limited to 'cmd/mist/assets/examples/balance.html')
-rw-r--r--cmd/mist/assets/examples/balance.html40
1 files changed, 40 insertions, 0 deletions
diff --git a/cmd/mist/assets/examples/balance.html b/cmd/mist/assets/examples/balance.html
new file mode 100644
index 000000000..bc483a879
--- /dev/null
+++ b/cmd/mist/assets/examples/balance.html
@@ -0,0 +1,40 @@
+<!doctype>
+<html>
+
+<head>
+<script src="../ext/bignumber.min.js"></script>
+<script src="../ext/ethereum.js/dist/ethereum.js"></script>
+<script type="text/javascript">
+
+ var web3 = require('web3');
+ web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080'));
+
+ function watchBalance() {
+ var coinbase = web3.eth.coinbase;
+ var originalBalance = 0;
+
+ var balance = web3.eth.balanceAt(coinbase);
+ var originalBalance = web3.toDecimal(balance);
+ document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
+
+ web3.eth.watch({altered: coinbase}).changed(function() {
+ balance = web3.eth.balanceAt(coinbase)
+ var currentBalance = web3.toDecimal(balance);
+ 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="original"></div>
+ <div id="current"></div>
+ <div id="diff"></div>
+</body>
+</html>
+
+