TRANSFER_FROM_FAILED error when trying to swap BCLNC tokens for ETH on Uniswap

  • I'm attempting to swap BCLNC tokens for ETH on Uniswap, but I get the following error:

    The transaction cannot succeed due to error: TransferHelper: TRANSFER_FROM_FAILED. This is probably an issue with one of the tokens you are swapping.

    However, it is clear that other transactions are successful such as this one.

    I've attempted to perform a swapExactTokensForETH directly on the Uniswap contract replicating the details such as Path and the correct values for amountIn, to and deadline, but it attempts to charge me an excessive gas fee (over $160), and MetaMask displays the following error:

    ALERT: Transaction Error. Exception thrown in contract code.

    Any idea what the issue could be here?

    This error is usually the result of you not calling `approve` prior to calling `transferFrom`.

    On the ERC20 contract at address `path[0]`

    You need to execute function `approve(uniswapContractAddress, amountIn)`

    Using the same account which you are trying to execute function `swapExactTokensForETH ` with.

    @goodvibration I did call `approve` as you can see here. The error kept occurring afterwards.

    Sorry, you should approve an amount equal to or larger than the first value in the array returned from `UniswapV2Library.getAmountsOut(factory, amountIn, path)`, so you might wanna check what this function returns on your input.

    @goodvibration You can see from the decoded input data of my `approve` tx that I set the amount to the largest possible `uint256` value (115792089237316195423570985008687907853269984665640564039457584007913129639935). So any possible value of `getAmountsOut` would work. At the time, Uniswap reported an output of around 2 ETH. Now it's even less. So, this can't be the issue.

    @Neo I'm really sorry to inform you that you were a victim of a honeypot contract. Look at the ensure modifier, only the owner can make arbitrary transfers.

    @Ismael I can see that `owner` is set in the `constructor` as `msg.sender`, and is also used in the `approval` and `allowance` functions. I don't see how this limits swaps conducted on Uniswap to be limited to a specific address. There's no wallet address specified anywhere in the contract code.

    @Neo Look at `transfer` and `transferFrom` both are guarded by `ensure` modifier. That modifier prevents arbitrary transfers, you can buy tokens from the owner, and from uniswap's pool, but you can't sell them to anyone but the owner.

    @Ismael I can see that `transferFrom` is protected by `ensure`. `owner` is set by `constructor`. I can see from here that `constructor` is executed only when the SC is created. Therefore, this is when `owner` is set in this case, and would be the same address that created the SC. Is my understanding correct?

    @Neo You are correct. Another suspicious function is `delegate` that allows owner arbitrary code execution.

    Did you get to resolved this? I am having the same error for myself- The transaction cannot succeed due to error: TransferHelper: TRANSFER_FROM_FAILED. This is probably an issue with one of the tokens you are swapping.

  • It is because your function needs to be payable if your receiver address is a contract

    Thanks for your answer.. but the question is not to transfer Ether. It is to transfer a Token. and it does not need to have wallet payable.

    ah maybe you need to approve your tokens in order for unsiwap to spend it? Dunno if your tokens are an ERC20 token

License under CC-BY-SA with attribution


Content dated before 7/24/2021 11:53 AM