0

I am using web3.py. Given a transaction hash, is there any way to determine if a transaction was dropped and replaced by another transaction with the same nonce? Currently i am looping w3.eth.getTransactionReceipt(tx_hash) in a try/except to detect when the transaction has been confirmed.

while(True):
    try:
        tx = w3.eth.getTransactionReceipt(tx_hash)
    except:
        continue

    break

If the transaction is still pending, it returns an error and reloops, trying again. If it succeeds, the loop is exited. However, if the owner of the transaction sends a new transaction with the same nonce, the tx hash i have will never be confirmed and this loop will never exit. How can i detect if this occurs?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.