I use the following code to create the swap_transaction:

swap_transaction = router_contract.functions.swapETHForExactTokens(
        0, [weth_address  ,token_address], account_address, int(time.time()) + (10000)


            'nonce': nonce,
            'gas': 200000,
            'gasPrice': w3.to_wei(gasprice,'gwei'),
            'from': account_address,
            'value': w3.to_wei(ether_amount,'ether')


Here I use the swapETHForExactTokens function but I have also seen the 'swapExactETHForTokensSupportingFeeOnTransferTokens' function. What is the difference between these two and which one should I use? In tutorials and the unofficial uniswap python package the 'swapETHForExactTokens' is used but when I go to etherscan I also see the other function. Thank you

1 Answer 1


There are some tokens that charge a fee for every transfer. A new function was introduced swapExactETHForTokensSupportingFeeOnTransferTokens because the original function swapExactETHForTokens doesn't know how to deal with those type of tokens.

From the developer documentation

swapExactTokensForTokensSupportingFeeOnTransferTokens: Identical to swapExactTokensForTokens, but succeeds for tokens that take a fee on transfer.

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.