TransactionError when using Brownie on Optimism - Tx dropped without known replacement

Viewed 297

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})

2 Answers

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

"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.

Related