I'm using wagmi and viem to transfer USDT in AVAX network from one address to another. But using usePrepareContractWrite hook I'm unable to figure out what is going wrong.
Using the below code, it initiates a smart contract call but it's displaying to transfer 0 AVAX instead of 5 USDT which I inputted. After successful confirmation, there's no USDT deducted from my wallet and SnowTrace shows "To" address as USDT contract address which is filled in the address field.
const { chain: activeChain } = useNetwork();
const { config: writeConfig } = usePrepareContractWrite({
address: '0xdac17f958d2ee523a2206206994597c13d831ec7' // USDT contract address,
chainId: activeChain?.id // 43114,
abi: token === 'USDT' ? usdtAbi : erc20ABI,
functionName: 'transfer',
args: [
receivingAddress,
parseEther(usdcValue),
],
});
Can someone please let me know what I'm doing wrong. Any help would be appreciated.
