0

Judging from https://github.com/ethereum/wiki/wiki/JSON-RPC the api client can synchronize on events such as:

  1. Transaction is received/pending: eth_gettransactionbyhash returns non-null with block number null
  2. Transaction is included in a block - eth_gettransactionbyhash returns non-null with block number non-null
  3. Transaction has been executed as a part of accepted block: eth_gettransactionreceipt returns non-null

But if I sent a transaction that turned out to be invalid - how do I know it's failed, is there anything to wait for/react on?

UPD: There are kinds of errors that prevent transactions from even being included e.g. Insufficient balance for transfer (for the first transfer, not the nested ones issued by contracts), nonce too low/high. By "invalid" I mean transactions that produce this kind of error.

2
  • What do you mean exactly with "invalid"?
    – Majd TL
    Oct 6, 2019 at 15:01
  • There are kinds of errors that prevent transactions from even being included e.g. Insufficient balance for transfer (for the first transfer, not the nested ones issued by contracts), nonce too low/high.
    – user51873
    Oct 6, 2019 at 15:03

1 Answer 1

0

If you are using a Javascript JSON RPC client library, like web3.js or ethjs, you will not get a transaction hash when you try to send a transaction that's invalid in the ways you describe (insufficient balance for gas, nonce out of order, address for which you don't have the private key or is not a test account, etc.)

Instead, you'll get a error that your code can either catch, or let propagate until it ends your program.

1
  • github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction Here it's stated that no transaction hash in response means that the transaction is "not yet available". Maybe, all eth implementations actually return the error right away, but it's not specified in the main standard.
    – user51873
    Oct 7, 2019 at 16:57

Your Answer

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