ERC-2400 Transaction receipt URI

Stagnant · Other · created 2019-11-05

A standard for representing a transaction receipt as a URI that includes the chain ID, the called function, and the emitted events, in order to solve the problem that a transaction hash alone reveals nothing about its contents.

Why it is needed

A transaction hash by itself is just a meaningless string, so looking at it alone gives no indication of which network the transaction belongs to, which function was called, or what events were emitted. Sharing transaction results across different applications such as wallets, explorers, chat apps, and vending machines requires a common URI format. Without a standard, each service ends up creating its own link format or simply sending the bare transaction hash, forcing the recipient to separately find the right chain and explorer and re-search for the transaction. There is also no common way to verify whether the method called or events emitted as claimed by the sender actually match the real transaction content, making it hard to trust a shared receipt as is.

In depth

URI syntax

The URI consists of the scheme part "ethereum:tx-" followed by a 64 digit hexadecimal transaction_hash starting with "0x", optionally followed by "@" and a decimal chain_id. After that, parameters may follow starting with "?" and separated by "&", where the key may only be method or events. The method value is a function signature made up of a function_name and a list of TYPEs, and the events value is one or more event_signatures separated by ";".

Rules for looking up transaction_hash

transaction_hash is required and is first looked up in the transaction records of the specified chain_id. If not found there, the pending transaction queue is checked, and the lookup is retried until it is found. If it is never found, an error equivalent to "transaction not found error" must be shown instead of the transaction. If the transaction is pending, checking continues until it is included in a block and reaches an "unrevertable" state (typically 12 blocks after inclusion).

Default chain_id

chain_id is the decimal chain ID defined by EIP-155, and is optional. It is included so that transactions on testnets or private networks can also be represented; if chain_id is absent, it is assumed to be Ethereum mainnet (1).

Validating the method parameter

If method is absent, it means the receipt URI does not specify details, or the transaction has no calldata. If method is present, it must be verified by comparing the first 4 bytes of the transaction's calldata with the first 4 bytes of the keccak256 hash of the method string; if they do not match, an error equivalent to "method validation error" must be shown. The format of the method value is function_name("(" TYPE, TYPE, ... ")").

Validating the events parameter

If events is absent, it means no details are specified, or the transaction emitted no events. Pending or failed transactions are not checked against events. If the transaction succeeded (or changed from pending to succeeded) and events is specified, each event in the event_list must appear at least once in the transaction receipt's event logs; otherwise an error of the form "event validation error: {event(s) [...] not found}" must be shown. The URI may specify all, some, or none of the emitted events, and a "!" before event_type indicates that parameter is indexed.

Future extensions and backward compatibility

Future upgrades that are partially or fully incompatible with this proposal must use a prefix other than "tx-", and that prefix must be separated from what follows it by a dash (-) character.

Standard status

This proposal is currently in Stagnant status. Standardization work has stalled, it has not yet been finalized, and its content may change or see no further progress.

Original ERC · ← ERCs