I have the following contract. When I try to call swap_token function from the RemixIDE, I get the error:

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution revertedI specify the amount of ETH as an argument of the function. I also tried to call the function using python web3 library using the following code:

contract_address = ''
signature = ''
from_address = ''
goerli_url = 'https://goerli.infura.io/v3/'
w3 = Web3(Web3.HTTPProvider(goerli_url))
contract = w3.eth.contract(address = contract_address,abi = abi)
nonce = w3.eth.get_transaction_count(from_address)
tprint('Uniswap project')
key = contract.functions.swap_token(10000000000000000).buildTransaction({'from':from_address,'nonce':nonce})
tx_code = w3.eth.signTransaction(key,signature)

But I'm getting the error:

raise ContractLogicError('execution reverted')
web3.exceptions.ContractLogicError: execution reverted

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

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract Uniswap {
    address private constant uniswap_goerli = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
    address private constant WETH_Goerli = '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6';
    address private constant ETH_Goerli = '0x7af963cF6D228E564e2A0aA0DdBF06210B38615D';

    function swap_token(uint _amount_to_send) public {
       // uint amount_to_send = _amount_to_send * 1e18;
        IERC20(ETH_Goerli).transferFrom(msg.sender, address(this),_amount_to_send);

    function get_balance() public view returns(uint) { 
        return address(this).balance;

Could you help and tell me how I should call via Remix and Web3 library?

  • Did you approve the contract to pull your ETH_Goerli token?
    – 0xSanson
    Commented Sep 30, 2022 at 22:54

1 Answer 1


You need to make sure you have the token(ETH_Goerli) amount that you are trying to transferFrom msg.sender (your address) to address(this) (smart contract that you deployed).

Also, make sure that msg.sender needs to approve the smart contract to transfer ETH_Goerli

you can use EthTx tx decoder to see execution trace

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.