Show alice balance
This commit is contained in:
parent
25c18b88ce
commit
ee0d1445e6
|
@ -1,6 +1,7 @@
|
||||||
App = {
|
App = {
|
||||||
web3Provider: null,
|
web3Provider: null,
|
||||||
contracts: {},
|
contracts: {},
|
||||||
|
aliceAddress: '0x0',
|
||||||
account: '0x0',
|
account: '0x0',
|
||||||
|
|
||||||
init: function() {
|
init: function() {
|
||||||
|
@ -68,7 +69,8 @@ App = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
// NOTE: async, might want to pull some stuff out here
|
||||||
|
render: async function() {
|
||||||
var electionInstance;
|
var electionInstance;
|
||||||
var loader = $("#loader");
|
var loader = $("#loader");
|
||||||
var content = $("#content");
|
var content = $("#content");
|
||||||
|
@ -77,21 +79,22 @@ App = {
|
||||||
content.hide();
|
content.hide();
|
||||||
|
|
||||||
// Load account data
|
// Load account data
|
||||||
web3.eth.getCoinbase(function(err, account) {
|
aliceAddress = await web3.eth.accounts[0];
|
||||||
console.log("getCoinbase", account, err);
|
App.aliceAddress = aliceAddress;
|
||||||
if (err === null) {
|
$("#accountAddress").html("Your Account: " + aliceAddress);
|
||||||
App.account = account;
|
console.log("aliceAddress", aliceAddress)
|
||||||
$("#accountAddress").html("Your Account: " + account);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
web3.eth.getCoinbase(function(err, account) {
|
web3.eth.getBalance(
|
||||||
console.log("getCoinbase", account, err);
|
App.aliceAddress,
|
||||||
if (err === null) {
|
function(err, res) {
|
||||||
App.account = account;
|
if (err == null) {
|
||||||
$("#accountAddress").html("Your Account: " + account);
|
console.log("Balance", res.toNumber())
|
||||||
|
aliceBalance = res.toNumber()
|
||||||
|
$("#aliceBalance").html("Alice Balance: " + aliceBalance);
|
||||||
|
} else {
|
||||||
|
console.log("Err", App.aliceAddress, err)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
// Load contract data
|
// Load contract data
|
||||||
// TODO Replace me
|
// TODO Replace me
|
||||||
|
|
Loading…
Reference in New Issue