@@ -185,7 +185,17 @@ function refundTicket(buyerAddress, ticketPrice) {
185185 }
186186 } ) ;
187187}
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+ }
189199// createWallet
190200function createWallet ( password ) {
191201
@@ -228,6 +238,11 @@ function getBalance(address) {
228238 return web3 . fromWei ( web3 . eth . getBalance ( address ) . toNumber ( ) , 'ether' ) ;
229239}
230240
241+
242+
243+
244+
245+
231246// switch to hooked3webprovider which allows for external Tx signing
232247// (rather than signing from a wallet in the Ethereum client)
233248function switchToHooked3 ( _keystore ) {
@@ -337,6 +352,18 @@ window.onload = function() {
337352 $ ( "#balance" ) . html ( getBalance ( address ) ) ;
338353 } ) ;
339354
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+
340367 // Set value of wallet to accounts[1]
341368 $ ( "#buyerAddress" ) . val ( accounts ) ;
342369 $ ( "#refBuyerAddress" ) . val ( accounts ) ;
0 commit comments