TransWikia.com

I can not call a function dynamically

Ethereum Asked by Uzair Kath on December 14, 2020

token.methods.balanceOf(accounts[0]).call().then(result=>{
    console.log(result);
   $creditsValue.innerHTML = result;
});

In this code when I try to fetch the balance from the contract dynamically it does not work and returns 0.
But when I check the balance manually it works like this:

token.methods.balanceOf('0xC9bb53aBc2DAA3726D6D2FD38B2664F2889EBb0d').call().then(result=>{
console.log(result);
$creditsValue.innerHTML = result;
});

Although the dynamic expression works fine in local network, but this problem is arising on the test network
Can someone please tell what’s the problem it is urgent

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP