diff options
Diffstat (limited to 'example/balance.html')
-rw-r--r-- | example/balance.html | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/example/balance.html b/example/balance.html index d70ea648b..60b8bbe87 100644 --- a/example/balance.html +++ b/example/balance.html @@ -8,23 +8,21 @@ <script type="text/javascript"> var web3 = require('web3'); - web3.setProvider(new web3.providers.AutoProvider()); + web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080')); 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...'; - }); + 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() { - 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); - }); + balance = web3.eth.balanceAt(coinbase) + var currentBalance = web3.toDecimal(balance); + document.getElementById("current").innerText = 'current: ' + currentBalance; + document.getElementById("diff").innerText = 'diff: ' + (currentBalance - originalBalance); }); } |