aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/ethtest/example/index.html
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-22 18:57:13 +0800
committerobscuren <geffobscura@gmail.com>2014-12-22 18:57:13 +0800
commite42517754ac2912b6d3ca78a34b8aeadf8805906 (patch)
treec69969cf68d0fd20598c531db394cbff864547dd /cmd/ethtest/example/index.html
parenta153b47c2be80bbfb38954c5eae310305d54120b (diff)
downloaddexon-e42517754ac2912b6d3ca78a34b8aeadf8805906.tar.gz
dexon-e42517754ac2912b6d3ca78a34b8aeadf8805906.tar.zst
dexon-e42517754ac2912b6d3ca78a34b8aeadf8805906.zip
updated ethereum.js
Diffstat (limited to 'cmd/ethtest/example/index.html')
-rw-r--r--cmd/ethtest/example/index.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/cmd/ethtest/example/index.html b/cmd/ethtest/example/index.html
new file mode 100644
index 000000000..d0bf094ef
--- /dev/null
+++ b/cmd/ethtest/example/index.html
@@ -0,0 +1,41 @@
+<!doctype>
+<html>
+
+<head>
+<script type="text/javascript" src="js/es6-promise/promise.min.js"></script>
+<script type="text/javascript" src="../dist/ethereum.js"></script>
+<script type="text/javascript">
+
+ var web3 = require('web3');
+ web3.setProvider(new web3.providers.AutoProvider());
+
+ function watchBalance() {
+ var coinbase = web3.eth.coinbase;
+ var originalBalance = 0;
+
+ web3.eth.balanceAt(coinbase).then(function (balance) {
+ originalBalance = web3.toDecimal(balance);
+ document.getElementById('original').innerText = 'original balance: ' + originalBalance + ' watching...';
+ });
+
+ web3.eth.watch({altered: coinbase}).changed(function() {
+ web3.eth.balanceAt(coinbase).then(function (balance) {
+ 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>
+