Help with getting user token Balance for Dex Project

Hi Everyone,

I’m building a UI for my Dex now I’ve finished the course, but am not able to get the user’s token balance.

I am using the below line of code with my deployed Link contract.

const wlBalance = await link_contract.methods.balanceOf(accounts[0]).call();

The error I keep getting is MetaMask - RPC Error: Internal JSON-RPC error. {code: -32603, message: “Internal JSON-RPC error.”

This looks like it might be set-up related. I’m using Ganache…Anyone any idea what I am doing wrong?

Hi @n1g3

That call seems right to me, can you post the whole JS file?

Cheers,
Dani

Ah! I have just realised that my link_contract.options.address is the same as dex_contract.options.address…

So, It looks like I’m not creating a reference to the Link contract correctly…Hopefully I can figure this out :slight_smile:

1 Like

:grimacing: I wasn’t doing this!

      deployedNetwork = LinkContract.networks[networkId];

Let us know if you need help :slight_smile: