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

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay