-
-
Save rfikki/0670edf84658cc5d6205 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script type="text/javascript" src="bignumber.min.js"></script> | |
| <script type="text/javascript" src="ethereum.js"></script> | |
| <script type="text/javascript"> | |
| var web3 = require('web3'); | |
| web3.setProvider(new web3.providers.HttpSyncProvider('http://localhost:8080')); | |
| var coinbase = web3.eth.coinbase; | |
| console.log('coinbase:'+coinbase) | |
| var balance = web3.eth.balanceAt(coinbase); | |
| console.log('balance:'+balance.toString()); | |
| 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('pending').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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Keeping track of travel card balances before commuting can save a lot of unnecessary delays, especially in busy cities where public transport is used daily. I recently found some practical information on checking recharge status, transaction history, and card validity through SMS or mobile apps here https://nolcardscheck.ae/. The guide is easy to follow and genuinely helpful for tourists or regular commuters who depend on metro, bus, or tram services and want smoother travel without last-minute balance issues.