I am currently in a situation where I need to send multiple transactions simultaneously. I see that it is possible as some accounts can send 10 or even more transactions per second, and their transactions end up in every block. Right now, I am using the following method with threading:
for txn in group:
thread = threading.Thread(target=send_transaction_in_thread, args=(client, txn, signers))
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
send_transaction_in_thread function is simply this:
def send_transaction_in_thread(client, txn, signers):
client.send_transaction(txn, *signers, opts=TxOpts(skip_preflight=True))
These are all different transactions. However, even though I use this method, it does not yield the desired result, even when I use multiple RPCs to bypass limits and adjust the priority fee according to network congestion. Currently, I am sending 30 transactions in threads, but still, sometimes these transactions can have a small interval between them, and sometimes a very large one, with a distance of ~10 blocks between them. I feel that the threading method is not ideal. What is the best approach for me to use? Or do I need to use even more transactions for sending (more than 30)?"