2

I am sending a transaction using:

sign_txn = web3.eth.account.signTransaction(token_tx, private_key=private_key)
tx_hash = web3.eth.sendRawTransaction(sign_txn.rawTransaction)

and I want to wait for the confirmation of the transaction to continue the work of my script, how can I do this so as not to lose extra time waiting for verification when the transaction is already completed?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Wade
  • 21
  • 5

1 Answers1

0

I might misunderstand you,

but is web3.eth.get_transaction_receipt() what you are looking for?

https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.get_transaction_receipt

if not, please clarify what result you are expecting :)

dotheM
  • 140
  • 6
  • I need to pause until the transaction becomes Success or Fail, this function just checks the status of the transaction and if it has not been confirmed yet, it will return an error – Wade Jun 24 '22 at 11:00
  • 1
    i see! Maybe https://web3py.readthedocs.io/en/stable/web3.eth.html#web3.eth.Eth.wait_for_transaction_receipt works then? If not you could create a While loop, where it waits for the receipt to be confirmed. – dotheM Jun 24 '22 at 11:25
  • This function is also not suitable. I was also thinking about While loop, I wanted to find out if there is a built-in method in web3.py – Wade Jun 24 '22 at 11:33