0

I have a DAPP and ERC20 Token which has an initial supply of 9000 for testing purpose..First step is to login/register into the DAPP where all the information resides..There is an element in the DAPP which shows user token balance..The major issue is whenever I refresh the page it makes token balance to zero..Surprisingly, when I open the dev mode and try to refresh, it actually shows user actual token balance before showing zero again.

I also have other elements which load on page refresh, takes some time to load but eventually they show accurate information instead of zero..But the token balance often show zero...

Moreover, I'm testing this with Metamask(Rinkeby Testnet) For instance: if i refresh the page 10 times then there are chances it will show token balance only once or twice I guess...

Solidity

mapping(address => uint256) internal tokenLedger;

function getBalance(address _owner)  public view returns(uint256) {
    return tokenLedger[_owner];
}

web3js

if ($('.user_balance')) {
contract.getBalance(web3.eth.coinbase, (err, balance) => {
    if (err) {
        alert(err.message);
    } else {
        $('.user_balance').text(Math.floor(balance));
    }
});

}

0

Your question does not mention how do you test it: what network, how token is being created and so on.

Most likely you do not account in transaction delays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.