I am trying to call Uniswap's Router's function swapExactTokensForETHSupportingFeeOnTransferTokens(). When I enter the values manually on etherscan, it goes through. However, when I do it via python code it gives me a validation error. The error looks like this:
web3.exceptions.ValidationError: Could not identify the intended function with name swapExactTokensForETHSupportingFeeOnTransferTokens, positional argument(s) of type (<class int>, <class int>, <class list>, <class str>, <class float>) and keyword argument(s) of type {}. Found 1 function(s) with the name swapExactTokensForETHSupportingFeeOnTransferTokens: [swapExactTokensForETHSupportingFeeOnTransferTokens(uint256,uint256,address[],address,uint256)] Function invocation failed due to no matching argument types.
Here's the code im using:
swap = uniswap_router_contract.functions.swapExactTokensForETHSupportingFeeOnTransferTokens(uint amount, 0, list_of_two_token_addresses, my_address_string, unix_time_stamp_deadline).buildTransaction({'nonce': some_nonce})
gas_amount = web3.eth.estimateGas(swap)
print(gas amount)
Am I supposed to somehow turn my ints into unsigned int in python? I tried but it didn't fix it. Im using the web3py library. Could someone direct me to the issue or to existing code that calls said function?
Thanks.
Edit:
I converted timestamp into int and also made sure my address strings were checksum using the web3.toChecksum method.
swap = uniswap_router_contract.functions.swapExactTokensForETHSupportingFeeOnTransferTokens(uint amount, 0, list_of_two_token_addresses, my_address_string, int(unix_time_stamp_deadline)).buildTransaction({'nonce': some_nonce})
gas = web3.eth.estimateGas(swap)
print(gas)
When I run this it gives me this error:
raise SolidityError(response['error']['message'])
web3.exceptions.SolidityError: execution reverted: TransferHelper:
TRANSFER_FROM_FAILED
question from:
https://stackoverflow.com/questions/65951183/validationerror-on-smart-contract-function-call-for-no-apparent-reasonweb3py 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…