问题: 当单击退出按钮时,我将调用函数,而在本例中,当模态窗口打开时,这两次之间没有更新平衡。
单击“提款”按钮或调用功能将余额更新为实时在合同中计算的最后金额有什么办法?
const contract = await tronWeb.contract().at(contractAddress);
const getContractBalance = await contract.getContractBalance().call();
if (amount < MIN_WITHDRAW) {
alert("Minimum withdraw is 10 TRX!");
}
else if (amount * 1e6 >= getContractBalance) {
alert("Couldn't withdraw more than total TRX balance on the contract!");
}
else {
contract.getUserCollectWithdraw(window.tronWeb.defaultAddress.base58).call().then(res => {
// const balanceTRX = (res.toString() / 1e6).toFixed(6);
contract.withdraw(getUserCollectWithdraw).send().then(res => {
alert("Your withdrawal was successfully.");
});
})
}
```