How a json-rpc client can tell that a transaction it's sent has been rejected?
How a json-rpc client can tell that a transaction it's sent has been rejected?
Loading saved threads...
user51873 · External communityPost link
External question — Ethereum Stack Exchange
Author: user51873
Original post: https://ethereum.stackexchange.com/questions/76515
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Judging from
https://github.com/ethereum/wiki/wiki/JSON-RPC
the api client can synchronize on events such as:
Transaction is received/pending:
eth_gettransactionbyhash
returns non-
null
with block number
null
Transaction is included in a block -
eth_gettransactionbyhash
returns non-
null
with block number non-
null
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.
Quote
Report
Paul Pham · External communityPost link
External answer — Ethereum Stack Exchange
Author: Paul Pham
Original post: https://ethereum.stackexchange.com/a/76532
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
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.
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Ethereum Stack Exchange Author: user51873 Source score (net votes, not local likes): 0 Original post: https://ethereum.stackexchange.com/questions/76515 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Judging from https://github.com/ethereum/wiki/wiki/JSON-RPC the api client can synchronize on events such as: Transaction is received/pending: eth_gettransactionbyhash returns non- null with block number null Transaction is included in a block - eth_gettransactionbyhash returns non- null with block number non- null 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.
Checking account access…