DEV Community

Vaibhav
Vaibhav

Posted on

Please Help!

Hey!
Does anyone know how to get balance of token deployed on thirdweb into React app.

My code is:

const balance = await token.balanceOf(walletAddress);
console.log(balance.displayValue);
Enter fullscreen mode Exit fullscreen mode

I'm getting this error:

Error Image

I am taking reference from
Link

Thanks in advance!

Top comments (1)

Collapse
 
codeofrelevancy profile image
Code of Relevancy

I hope this will help you:

import Thirdweb from "thirdweb";

const thirdweb = new Thirdweb();
const tokenAddress = "YOUR_TOKEN_ADDRESS";
const accountAddress = "YOUR_ACCOUNT_ADDRESS";
const balance = await thirdweb.getTokenBalance(tokenAddress, accountAddress);

console.log('balance:', balance);
Enter fullscreen mode Exit fullscreen mode