We can check which require the transaction failed to meet by searching for the message in contract TRANSFER_FROM_FAILED
.
The function calls transferFrom function. transferFrom function requires the owner of the token to approve a spender to spend on his/her behalf.
Seems like you have not approve the spender to spend on your behalf.
You can check more info regarding transferFrom at this docs
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper: TRANSFER_FROM_FAILED');
swapExactTokensForETH
uses safeTransferFrom
function
...
TransferHelper.safeTransferFrom(
path[0],
msg.sender,
UniswapV2Library.pairFor(factory, path[0], path[1]),
amounts[0]
);
...