docs
docs copied to clipboard
Calling exactInputSingle returns execution reverted: STF
w3 = Web3(Web3.HTTPProvider(eth_local_http))
router_contract = w3.eth.contract(address=ROUTER_ADDRESS, abi=ROUTER_ABI)
DAI = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
WETH9 = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
payload = (
WETH9, # tokenIn
DAI, # tokenOut
3000, # fee
ACCOUNT_ADDRESS1, # recipient
round(time.time()) + 60 * 20, # deadline
int(Web3.toWei(0.01, "ether")), # amountIn
0, # amountOutMinimum
0, # sqrtPriceLimitX96
)
tx = router_contract.functions.exactInputSingle(payload).buildTransaction()
print(tx)
It always returns
Traceback (most recent call last):
File "/home/wpzhou/projects/moon_eth_v3/nets.py", line 607, in <module>
tx = router_contract.functions.exactInputSingle(payload).buildTransaction()
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/contract.py", line 1079, in buildTransaction
return build_transaction_for_function(
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/contract.py", line 1648, in build_transaction_for_function
prepared_transaction = fill_transaction_defaults(web3, prepared_transaction)
File "cytoolz/functoolz.pyx", line 250, in cytoolz.functoolz.curry.__call__
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/_utils/transactions.py", line 121, in fill_transaction_defaults
default_val = default_getter(web3, transaction)
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/_utils/transactions.py", line 67, in <lambda>
'gas': lambda web3, tx: web3.eth.estimate_gas(tx),
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/eth.py", line 759, in estimate_gas
return self._estimate_gas(transaction, block_identifier)
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/manager.py", line 198, in request_blocking
return self.formatted_response(response,
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/manager.py", line 170, in formatted_response
apply_error_formatters(error_formatters, response)
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/manager.py", line 70, in apply_error_formatters
formatted_resp = pipe(response, error_formatters)
File "cytoolz/functoolz.pyx", line 667, in cytoolz.functoolz.pipe
File "cytoolz/functoolz.pyx", line 642, in cytoolz.functoolz.c_pipe
File "/home/wpzhou/projects/moon_eth_v3/venv/lib/python3.9/site-packages/web3/_utils/method_formatters.py", line 576, in raise_solidity_error_on_revert
raise ContractLogicError(response['error']['message'])
web3.exceptions.ContractLogicError: execution reverted: STF
M
No
U
H
I had the same issue and the problem was, that i did not approve the token (maybe STF stands for SafeTransferFrom)
I am facing the same problem and used the uniswap app to approve the tokens i wanted to trade. But i am still facing this error. Am i missing something?
Have the same issue. But it works for me 50/50. eg: topic author syaringan357 case works fine.
but my example with params = { tokenIn: '0x6b175474e89094c44da98b954eedeac495271d0f', tokenOut: '0xbbbbca6a901c926f240b89eacb641d8aec7aeafd', fee: 3000, amountIn: '10000000000000000000' } failed(( with Error: call revert exception
Same issue here, removed the STF error by approving my contract on the token address. Still getting the gas estimation error with call revert exception
Same issue here, removed the STF error by approving my contract on the token address. Still getting the gas estimation error with call revert exception
Did you solve?
Maybe that pool is not initialized.
I just got this issue. So it was approved the wrong router instead of SwapRouter02.
Which is the right routing address, can you tell me your success code?
STF 的意思是 safeTransferFrom,如果出现Fail with error 'STF',需要授权代币给合约 STF means safeTransferFrom, if Fail with error 'STF' occurs, you need to approve tokens to the contract
STF 的意思是 safeTransferFrom,如果出现Fail with error 'STF',需要授权代币给合约 STF means safeTransferFrom, if Fail with error 'STF' occurs, you need to approve tokens to the contract
正解! Final solution!