我无法在用户界面中显示令牌的余额
这是应该显示所有这些统计信息的代码
function update() {
var account =
web3.eth.accounts !== undefined && web3.eth.accounts[0] !== undefined
? web3.eth.accounts[0]
: '0x0000000000000000000000000000000000000001';
FNB.allInfoFor.call(account, function(error, info) {
if (!error) {
console.log(info);
$('#totalSupply').text(
formatNumber(parseFloat(web3.fromWei(info[0], 'ether')), 5)
);
$('#totalStaked').text(
formatNumber(parseFloat(web3.fromWei(info[1], 'ether')), 5)
);
$('#myTokens').text(
formatNumber(parseFloat(web3.fromWei(info[2], 'ether')), 5)
);
$('#myStaked').text(
formatNumber(parseFloat(web3.fromWei(info[3], 'ether')), 5)
);
$('#myDividends').text(
formatNumber(parseFloat(web3.fromWei(info[4], 'ether').toFixed(2)), 5)
);
$('#withdrawAmount').text(
formatNumber(parseFloat(web3.fromWei(info[4], 'ether')), 5)
);
FNB.balanceOf.call(faucetAddress, function(error, balance) {
if (!error) {
$('#faucetBalance').text(
formatNumber(parseFloat(web3.fromWei(balance, 'ether')), 5)
);
web3.eth.getBalance(account, 8900000, function(error, balance) {
if (!error) {
console.log(balance);
$('#myPastBalance').text(
formatNumber(parseFloat(web3.fromWei(balance, 'ether')), 5)
);
} else {
console.log(error);
}
});
} else {
console.log(error);
}
});
} else {
console.log(error);
}
});
}
,这是一个pastebin的链接,因为完整的文件会很大 https://pastebin.com/kJ3AfSmL
然后就是html文件
<div class="row px-3 my-5" id="stake">
<div class="col-12 mb-5 mb-lg-0 text-center w-100">
<h2 class="text-center">Staking</h2>
<div class="row">
<div class="col-lg-6 px-0">
<div class="card mb-4 mb-lg-0 ">
<div class="card-body">
<h4 class="card-title text-left mb-0">Stake PoorFag</h4>
<div class="Stake">
<ul class="fa-ul text-left ml-0" style="margin-bottom: 10px">
<li style="color: #f1e41a;">PoorFag balance: <span id="myTokens">0</span></li>
</ul>
<form class="form" style="position: relative; z-index: 1!important;margin-top: 5px;" id="before-list" onsubmit="return false;">
<div class="input-group" style="position: relative;">
<input type="number" pattern="[0-9]" id="stakeAmount" placeholder="PoorFag to Stake">
<div class="input-group-append" style="position: absolute; top: 8px; right: 0px; width: 70px; z-index: 5;">
<button class="btn2 btn-primary px-3" type="button" id="setMaxStake">MAX</button>
</div>
</div>
</form>
<a href="#" class="btn btn-block btn-primary" id="stake">Stake PoorFag</a>
</div>
<h4 class="card-title text-left mb-0 mt-5">Your PoorFag dividends</h4>
<div class="divs">
<h2 class="text-left float-left mt-3" id="myDividends" style="width: 60%">0</h2>
<a href="#" class="btn btn-block btn-primary float-right mt-3" id="withdraw" style="width: 40%;">Collect</a>
</div>
</div>
</div>
</div>
这是我的UI的链接 solid-sticks.surge.sh
我不知道问题出在哪里,它显示了已抵押的总代币,但未显示ERC20合同的代币余额等。