Hello, I’m unable to send an ERC20 token from the Polygon network. The code executes and reaches the line await tx.wait(); but then there’s no response. What could be the reason?
async function sendToken() {
try {
const provider = new ethers.providers.JsonRpcProvider(INFURA_MAINNET);
const wallet = new ethers.Wallet(privateKey as any, provider);
const tokenAddress = '0x5fe2b58c013d7601147dcdd68c143a77499f5531';
const abi = ['function transfer(address to, uint256 amount)'];
const contract = new ethers.Contract(tokenAddress, abi, wallet);
const toAddress = '0x515f807cf3b2f74fa6a76d308c60230cdb28d348';
const amount = ethers.utils.parseUnits('5.0', 18);
const tx = await contract.transfer(toAddress, amount);
console.log('Transaction hash:', tx.hash);
await tx.wait();
console.log('Transaction confirmed');
} catch (err) {
console.error('Error:', err);
}