⚠️ This EIP is not recommended for general use or implementation as it is likely to change.

EIP-5568: Required Action Signals Using Revert Reasons Source

Signal to wallets that an action is needed by returning a custom revert code

AuthorPandapip1
Discussions-Tohttps://ethereum-magicians.org/t/eip-5568-revert-signals/10622
StatusDraft
TypeStandards Track
CategoryInterface
Created2022-08-31
Requires 140

Abstract

This EIP introduces a minimalistic machine-readable (binary) format to signal to wallets that an action needs to be taken by the user using a well-known revert reason. This custom revert reason contains just enough data to be extendable by future EIPs and to take in arbitrary parameters (up to 64 kB of data). Example use cases could include approving a token for an exchange, sending an HTTP request, or requesting the user to rotate their keys after a certain period of time to enforce good hygiene.

Motivation

Oftentimes, a smart contract needs to signal to a wallet that an action needs to be taken, such as to sign a transaction or send an HTTP request to a URL. Traditionally, this has been done by hard-coding the logic into the frontend, but this EIP allows the smart contract itself to request the action.

This means that, for example, an exchange or a market can directly tell the wallet to approve the smart contract to spend the token, vastly simplifying the front-end code.

Specification

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

Custom Revert Reason

To send a signal to a wallet, a compliant smart contract MUST revert with the following error:

error WalletSignal24(uint8 number_hint, uint24 instruction_id, bytes instruction_data)

The number_hint is an estimate of the number of signals that will be sent after the current signal. If a guess is availabe, number_hint MUST be that estimate. If a guess is unavailable, number_hint MUST be 0.

The instruction_id of an instruction defined by an EIP MUST be its EIP number unless there are exceptional circumstances (be reasonable). An EIP MUST define exactly zero or one instruction_id. The structure of the instruction data for any instruction_id MUST be defined by the EIP that defines the instruction_id.

Signal Response

Before submitting a transaction to the mempool, it MUST be evaluated locally. If it reverts and the revert signature matches the custom error, then it MUST be treated as a signal. (It is RECOMMENDED for wallets to show a warning if the transaction reverts, even if the revert is not a signal).

The number_hint, instruction_id, and instruction_data MUST be parsed from the revert data. It is RECOMMENDED for wallets to show a progress indicator using the number_hint. The instruction SHOULD be evaluated as per the relevant EIP. If the instruction is not supported by the wallet, it MUST display an error to the user indicating that is the case. The wallet MUST then re-evaluate the transaction, except if an instruction explicitly states that the transaction MUST NOT be re-evaluated.

If an instruction is invalid, or the number_hint, instruction_id, and instruction_data cannot be parsed, then an error MUST be displayed to the user indicating that is the case.

Rationale

This EIP was explicitly optimized for deployment gas cost and simplicity. It is expected that libraries will eventually be developed that makes sending and receiving signals more developer-friendly.

Backwards Compatibility

Human-Readable Revert Messages

See Revert Reason Collisions.

EIP-3668

EIP-3668 can be used alongside this EIP, but it uses a different mechanism than this EIP.

Security Considerations

Revert Reason Collisions

It is unlikely that the signature of the custom error matches any custom errors in the wild. In the case that it does, no harm is caused unless the data happen to be a valid instruction, which is even more unlikely.

Copyright and related rights waived via CC0.

Citation

Please cite this document as:

Pandapip1, "EIP-5568: Required Action Signals Using Revert Reasons [DRAFT]," Ethereum Improvement Proposals, no. 5568, August 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5568.