New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EIP-5568: Required Action Signals Using Revert Reasons #5568
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b849962
Create eip-signal.md
Pandapip1 3bd4fc0
Assign EIP-5568
Pandapip1 96539f9
Add missing EIP number
Pandapip1 b097d33
Add discussions-to link
Pandapip1 a6cd41c
Expand specification
Pandapip1 d0a393b
Finish the signal response section
Pandapip1 46e265d
Update title
Pandapip1 0c913de
Expand abstract
Pandapip1 95ff689
TIL how hygiene is actually spelt
Pandapip1 df72436
Add security considerations
Pandapip1 39b997a
-0 to compliant but here it is anyways
Pandapip1 ad2a50d
Use simpler format
Pandapip1 bc5dd73
eip-5568: remove extraneous character
lightclient File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
eip: 5568 | ||
title: Required Action Signals Using Revert Reasons | ||
description: Signal to wallets that an action is needed by returning a custom revert code | ||
author: Pandapip1 (@Pandapip1) | ||
discussions-to: https://ethereum-magicians.org/t/eip-5568-revert-signals/10622 | ||
status: Draft | ||
type: Standards Track | ||
category: Interface | ||
created: 2022-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: | ||
|
||
```solidity | ||
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](#revert-reason-collisions). | ||
|
||
### [EIP-3668](./eip-3668.md) | ||
|
||
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 | ||
|
||
Copyright and related rights waived via [CC0](../LICENSE.md). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if
error
is a proper solidity here. I wonder if there is a typo here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error
is proper solidity as of 0.8.4: https://blog.soliditylang.org/2021/04/21/custom-errors/