We are trying to "swapExactTokensforTokens" for swapping any token, and it runs well, but we get this error at the blockchain:
TRANSFER_FROM_FAILED
https://polygonscan.com/tx/0xf584e421990628131b92b22b2aad270e91752287817eeb518a4d9bdb4b37d086
When we use "swapETHForExactTokens" it makes the trade, but can only use MATIC/ETH/BNB as token1, and we want to trade any tokens. Do you know how to solve this?
CODE: (we are not approving contracts in code before, but we are approving them at polygonscan).
const tx = await router.swapExactTokensForTokens(
amountIn,
amountOutMin,
[tokenIn, tokenOut],
data.recipient,
Date.now() + 1000 * 60 * 5, //5 minutes
{
'gasLimit': data.gasLimit,
'gasPrice': data.gasPrice
});
Thanks!