I'm trying to perform a multiswap transaction on UniswapV3 using exactInput. I'm not deploying a smart contract of my own, but rather calling the contract directly using Web3.py using the following:

        params = (
            int(time.time()) + 12,
            int(Web3.toWei(0.0001, "ether")),
        self.call_function = self.router_contract.functions.exactInput(params).buildTransaction({"chainId": self.chain_id, "from": self.caller, "nonce": self.nonce})
        self.signed_tx = self.web3.eth.account.sign_transaction(self.call_function, private_key=self.private_key)

The contract I'm calling is 0xE592427A0AEce92De3Edee1F18E0157C05861564, which is UniswapV3's router. The approvals for transferring USDC and WETH tokens have been granted to the router contract for my wallet as well. However, I'm still getting an "STF" error when creating the transaction. I've tried different amounts of approvals (it's currently set to unlimited) to no avail. The other possibility is that the encoding code I'm using to encode the swap path is incorrect, but it seems to be producing the correct output. The code I'm using is as follows:

def encodePath(self) -> str:
        path = self.tokens
        fees = self.fees

        fee_size = 6 # uint24 has 3 bytes so 6 hex digits
        if len(path) != len(fees) + 1:
            print('path/fee lengths do not match')

        encoded = '0x'
        for i in range(len(fees)):
            encoded += path[i][2:]
            fee = hex(fees[i])[2:];
            encoded += fee.zfill(fee_size)
        encoded += path[-1][2:]
        return encoded

Most other questions and examples use an intermediate contract that performs the calls to the router, but I'm not using a separate contract. Any help will be greatly appreciated.

Gist of the overall transaction creation code: https://gist.github.com/ashiswin/7b27f38d6bc8b73287ddbe1d853128da

2 Answers 2


My two cents:

When i'm working with Uniswap and i still receiving STF error, i go on etherscan and try to query the token contract to make sure that i authorized through approve an amount that covers the amount i'm willing to swap.


I faced same issue before, In my self exactInputSingle method expects ether, I didn't passed ether to the exactInputSingle method. After sending ether - 0 (pass 0 - if you are not swapping eth for token) as a value, the contract method succeeded the transaction.

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.