4

I have a Python script using Brownie that occasionally triggers a swap on Uniswap by sending a transaction to Optimism Network.

It worked well for a few days (did multiple transactions successfully), but now each time it triggers a transaction, I get an error message:

TransactionError: Tx dropped without known replacement

Complete error message

However, the transaction goes through and get validated, but the script stops.

swap_router = interface.ISwapRouter(router_address)

params = (
            weth_address,
            dai_address,
            3000,
            account.address,
            time.time() + 86400,
            amount * 10 ** 18,
            0,
            0,
        )

amountOut = swap_router.exactInputSingle(params, {"from": account})
tseror
  • 41
  • 3
  • I think that is little information. Maybe in order to help you, you could add some code? Anyway, your transaction is being dropped. That can happen for various reasons (see more here: https://info.etherscan.com/transaction-dropped-replaced/). – Diego B Mar 08 '22 at 23:08
  • I added my code to the post. I'm not sure that the transaction gets dropped since it successfully goes through every time. I feel like it's brownie thinking it dropped when it didn't – tseror Mar 09 '22 at 22:38
  • Since Tx is dropped without known replacement you have to try again. I think, if there is another transaction sent with eact time they may collide and one of them would be dropped – alper Apr 13 '22 at 00:13

2 Answers2

3

There is a possibility that one of your methods seeks data off-chain and is being called prematurely before the confirmation is received. I had the same problem, and I managed to sort it out by adding

time.sleep(60)

at the end of the function that seeks for data off-chain

Martin Maati
  • 121
  • 1
  • 5
0

"Dropped and replaced" means the transaction is being replaced by a new one, Eth is being overloaded with a new gas fee. My guess is that you need to increase your gas costs in order to average the price.