The code below continues to give me a forceful send / gas issue, I'm not sure what is wrong, what could be the issue? do I need to approve something? I've been stuck with this error for some time now. An example to a working SwapEthForExactTokens would be a great start as well.

   // SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

contract swapTest{
    address private constant uniswapV2Router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
    address private constant token = address(this);
    function swap(uint256 amount) external returns (bool) {
            address[] memory uniswapPairPath = new address[](2);
            uniswapPairPath[0] = uniswapV2Router.WETH();
            uniswapPairPath[1] = token;
            uint256 amount = address(this).balance;
            uniswapV2Router.swapExactETHForTokensSupportingFeeOnTransferTokens{value: amount}(
            return true;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.