Multiple quick transactions leave some transactions indefinitely hanging?

Hi, I’ve been using web3.py to send multiple transactions within seconds of eachother and sometimes those transactions will all go through with a successful tx, while at other times a few transactions will just lead to an empty explorer page; no transaction error, just was never processed.

All transactions have more than enough gas, so I’m not sure what the issue is.

Let me know if you have an idea of what could be causing this. Thanks! :slight_smile:
(If helpful, transactions are being routed through a POKT harmony url)

1 Like

When you get a TX hash it does not guarantee that it has succeeded. It means it is sent…

It is best to wait for a receipt that will confirm that TX is completed.

I do this by polling until I find a receipt

def wait_for_receipt(t_hash: str, w3: web3) -> tuple:
    while 1:
        try:
            hash_info = w3.eth.getTransaction(t_hash)
            sent = w3.eth.getTransactionReceipt(t_hash)
            return sent, hash_info
        except exceptions.TransactionNotFound:
            pass
2 Likes

If you are sure it went through and you get a full reply from w3.eth.getTransaction(t_hash) like this:

blockHash : 0x4c4a4a183f2bb08a06b048ccfe4deb849fb3cfb0c9bd318f4b5f2f7fcefd2d5d
blockNumber : 20519757
from : 0xfAFfb33B924C33381dee35D445013D3200249572
gas : 25000
gasPrice : 1000000000
hash : 0x5445676300cc3c43c727c471c694bdb8312e69dd951b88e3ca27d74cb8fa96e2
input : 0x
nonce : 547
r : 0xbc550ef9a006b7ec437befdf31dec5c4714c6004d5092a39ad29751cad50155f
s : 0x0bff63feada86085d7c7e1860f358cf3e2603244ae2d165a9abedf6cd45fe310
timestamp : 0x61b9ec62
to : 0xfAFfb33B924C33381dee35D445013D3200249572
transactionIndex : 32
v : 3333200035
value : 100000000000000

Then it is most likely the RPC for explorer that is not updated…

2 Likes

Thanks! That’s very helpful.

Do you know what the source of a transaction not completing could be?

Afraid not but I experienced similar behaviour hence I wrote the above function. It is the same on other chains ime.

Rather than sending 1 at a time synchronously, try using async in your functions and wait for a receipt. This way you can send many tx at once and also confirm that they defo went through.

1 Like

Edit: Hanging quick succession transactions was found to be purely an RPC issue, not a code issue. To fix in your own code, connect web3 to a pokt network instead.