0

currently am using web3.py to send transactions in python which has led to some problems

web3 = Web3(Web3.HTTPProvider("https://mainnet.infura.io/v3/xxx"))
PA=web3.eth.account.from_key(private_key)
nonce = web3.eth.get_transaction_count(PA.address,'pending')

Code above gets nonce that is supposed to include pending transaction, which it doesnt, also yea i know i can just increment it manually and i do that, the issue is that this can be running like 2 threads at same time so i cant really manage it.

Is there any external wallet i can use for this ? instead of loading pk to web3 just use local api of that wallet or smt ?

Or maybe a node that shows pending nonces ?

Anything appreciated.

1 Answer 1

1

Why do you need multiple thread to handle one account?

In similar situation I separated the transaction creation from the signing.

There was a thread that managed signatures. It will read the nonce from pending once at the start and it will wait for signature requests. Using a queue it process signature requests update its internal pending nonce and return the signed transaction. Obviously this won't work if you have another process using the same account to send transactions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.