I am using this simple code to get wallet balance of USDC. I am not sure how I can convert wei value to proper value. Let's say I have 1,076.235541 USDC in wallet. The below code shows 1076235541 and 0.000000001076235541. But I need to get value 1076 from it.
const minABI = [
// balanceOf
{
constant: true,
inputs: [{ name: "_owner", type: "address" }],
name: "balanceOf",
outputs: [{ name: "balance", type: "uint256" }],
type: "function",
},
];
const tokenAddress = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const walletAddress = MY_WALLET_ADDRESS;
const contract = new Web3Client.eth.Contract(minABI, tokenAddress);
async function getBalance() {
const result = await contract.methods.balanceOf(walletAddress).call();
const format = Web3Client.utils.fromWei(result);
console.log(result);
console.log(format);
}