0

I want a make some transactions. Did like mentioned here

sendRawTransaction return me hash of transaction. But there is not any transaction. My pending transactions count is 0. When I call getTransaction method with that hash , the result is

{
   'blockHash': None, 
   'blockNumber': None, 
   'from': 'my address', 
   'gas': 118685, 
   'gasPrice': 1000000000, 
   'hash': HexBytes('some hash'), 
   'input': 'some long hash', 
   'nonce': 1254, 
   'r': HexBytes('...'), 
   's': HexBytes('...'), 
   'to': 'my contract address', 
   'transactionIndex': None, 
   'v': 42, 
   'value': 0
}

What can be the reason?

gjivanya
  • 519
  • 2
  • 6
  • 19
  • Likely the transaction was not accepted to the network. The reasons could include too low gas price, bad nonces, et. If you run your own Ethereum node like Geth in debug mode you can see from Geth logs why they did not accept your transaction. – Mikko Ohtamaa Feb 05 '21 at 09:42
  • this my params 'nonce': w3.eth.getTransactionCount(account_address), gas = cont.functions.my_function(...).estimateGas() + 10000 I'm using infura. When I'm running the same code twice I get ValueError: {'code': -32000, 'message': 'already known'} – gjivanya Feb 05 '21 at 10:44
  • You cannot reuse the same nonce twice. – Mikko Ohtamaa Feb 05 '21 at 14:45

1 Answers1

0

By the documentation of getTransaction, it returns a transaction only after the transaction is mined. You can wait for it to be mined using the waitForTransactionReceipt method.

Michael
  • 36
  • 3