@@ -185,7 +185,17 @@ function refundTicket(buyerAddress, ticketPrice) {
185
185
}
186
186
} ) ;
187
187
}
188
-
188
+ function getEthBalance ( ) {
189
+ contractInstance . getEthBalanceOf ( web3 . eth . accounts [ 0 ] , ( ( error , result ) => {
190
+ if ( ! error ) {
191
+ balance = result ;
192
+ $ ( '#balance' ) . text ( "BALANCE: " + web3 . fromWei ( result , 'ether' ) + " ETH" ) ;
193
+ $ ( '#user_balance' ) . text ( "AVAILABLE BALANCE: " + web3 . fromWei ( result , 'ether' ) + " ETH" ) ;
194
+ } else {
195
+ console . log ( "FAILED TO GET ETH BALANCE" ) ;
196
+ }
197
+ } ) )
198
+ }
189
199
// createWallet
190
200
function createWallet ( password ) {
191
201
@@ -228,6 +238,11 @@ function getBalance(address) {
228
238
return web3 . fromWei ( web3 . eth . getBalance ( address ) . toNumber ( ) , 'ether' ) ;
229
239
}
230
240
241
+
242
+
243
+
244
+
245
+
231
246
// switch to hooked3webprovider which allows for external Tx signing
232
247
// (rather than signing from a wallet in the Ethereum client)
233
248
function switchToHooked3 ( _keystore ) {
@@ -337,6 +352,18 @@ window.onload = function() {
337
352
$ ( "#balance" ) . html ( getBalance ( address ) ) ;
338
353
} ) ;
339
354
355
+ function getEthBalance ( ) {
356
+ contractInstance . getEthBalanceOf ( web3 . eth . accounts [ 0 ] , ( ( error , result ) => {
357
+ if ( ! error ) {
358
+ balance = result ;
359
+ $ ( '#balance' ) . text ( "BALANCE: " + web3 . fromWei ( result , 'ether' ) + " ETH" ) ;
360
+ $ ( '#user_balance' ) . text ( "AVAILABLE BALANCE: " + web3 . fromWei ( result , 'ether' ) + " ETH" ) ;
361
+ } else {
362
+ console . log ( "FAILED TO GET ETH BALANCE" ) ;
363
+ }
364
+ } ) )
365
+ }
366
+
340
367
// Set value of wallet to accounts[1]
341
368
$ ( "#buyerAddress" ) . val ( accounts ) ;
342
369
$ ( "#refBuyerAddress" ) . val ( accounts ) ;
0 commit comments