Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Version of balance.html for use with latest go-ethereum
<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;
var balance = web3.eth.balanceAt(coinbase);
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...';'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);
<h1>coinbase balance</h1>
<button type="button" onClick="watchBalance();">watch balance</button>
<div id="original"></div>
<div id="current"></div>
<div id="diff"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment