current position:Home>TransferHelper: TRANSFER_ FROM_ FAILED


2022-02-03 20:42:52 Q & A of Denglian community

Contract published on bsc Test chain , stay Release liquidity , Use uniswap Report an error when selling tokens TransferHelper: TRANSFER_FROM_FAILED, How to solve this problem ? sell token Code for :

function _swapTokensForBnb(uint256 tokenAmount) public {        address[] memory path = new address[](2);        path[0] = address(this);        path[1] = uniswapV2Router.WETH();        _approve(address(this), address(uniswapV2Router), tokenAmount);        // make the swap        uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(            tokenAmount,            0,            path,            address(this),            block.timestamp        );    }

Take the answer 1:

TRANSFER_FROM_FAILED Usually without authorization , Or not enough .

Do you have tokens in your contract ?

copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.

Random recommended