Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC-5568, which proposes allowing smart contracts to signal required actions to wallets through a standardized interface.

This article translates, summarizes, and supplements the material linked below.

The original article recorded ERC-5568 as being in the Review stage on October 3, 2023.

Overview

This ERC defines part of a standard mechanism for communicating information about blockchain transactions and operations to wallets.

When a wallet user needs to take an action, the proposal provides a minimal machine-readable binary format for communicating that requirement.

The format is designed to accommodate future versions and extensions without changing its fundamental structure. It can accommodate up to 64 kB of data.

Consider approving a token for use on an exchange. The exchange's contract can use this mechanism to inform the wallet that token approval is required. The wallet can then present the requested action to the user.

Other examples include requesting an HTTP operation or asking a user to configure a new key after a specified period.

The proposal establishes common rules for exchanging information between applications and services and notifying wallet users of required actions. Its extensibility is intended to support a broad range of blockchain applications.

Motivation

Smart contracts may need wallets to perform additional actions, such as signing a transaction or sending an HTTP request to a specified URL.

Traditionally, these requirements had to be embedded directly in application or wallet frontend logic.

With ERC-5568, the smart contract itself can signal that an action is required.

Consider an exchange or marketplace that needs a user to approve a token.

Previously, the exchange frontend had to contain the logic for requesting approval. Under the proposed mechanism, the smart contract can signal the action directly to a compatible wallet, reducing application-specific frontend logic.

The objective is to improve coordination between contracts and wallets. A compatible wallet can interpret required actions and present or perform them according to the applicable rules and user authorization.

Specification

Action Detection

javascript
interface IERC5568 {
    function walletSignal24(bytes32 selector, bytes function_data) view returns (uint24 instruction_id, bytes instruction_data);
}

An ERC defining an instruction should normally use its own ERC number as the instruction number, unless there is a specific reason to use a different value.

An ERC may define zero or one instruction number, but must not define multiple numbers.

When an instruction_id is defined, the format of its associated instruction_data must also be defined within the same ERC.

When an action is required, the interface returns the instruction number and data, communicating the operation to the wallet or another relevant component.

If no action is required, the instruction number is zero and the instruction data may contain an arbitrary value.

Each ERC defining an instruction specifies its rules and data format. The instruction ID identifies the corresponding instruction specification.

Custom Revert Reason

A conforming contract uses the following custom error to signal that a required action has not been performed.

javascript
error WalletSignal24(uint24 instruction_id, bytes instruction_data)

The instruction number normally corresponds to the number of the ERC defining it. Exceptions require a specific justification.

Each ERC may define zero or one instruction number. If it defines an instruction_id, it must also define the associated instruction_data format.

These conventions establish a consistent way for contracts and wallets to identify and interpret the required action.

Handling Reverts

Before submitting a transaction to the mempool, the wallet must locally simulate the walletSignal24 function using the relevant transaction context.

A nonzero instruction_id indicates that an action is required.

The wallet obtains instruction_id and instruction_data from the simulation and evaluates the instruction according to the applicable ERC.

If the wallet does not support the instruction, it displays an error to the user and reevaluates the transaction unless reevaluation is prohibited by the applicable instruction.

  • Evaluation

    Evaluation means interpreting an instruction, checking its validity, and performing the appropriate authorized action, such as constructing or modifying a transaction.

  • Reevaluation

    Reevaluation means considering the transaction again after the first evaluation, for example when conditions have changed or additional information has become available. The transaction may be updated or adjusted as a result.

Evaluation processes the initial instruction, whereas reevaluation revisits the transaction in light of later information or conditions.

If the instruction is invalid or its instruction_id and instruction_data cannot be interpreted, the wallet displays an error and must not reevaluate the transaction.

Before submission, the wallet simulates walletSignal24 and retrieves the instruction ID and data.

The original article's summary groups unsupported and invalid instructions together. The preceding rules distinguish them: unsupported instructions can permit reevaluation under the applicable rules, whereas invalid or undecodable instructions must not be reevaluated.

Additional Notes

The proposal emphasizes simplicity and minimizing contract deployment costs. Supporting libraries may be developed to make the format easier to use.

It does not require ERC-165, because the interface is simple enough to detect by attempting to call its function.

Backward Compatibility

Human-Readable Revert Messages

Human-readable revert messages communicate the reason for a revert in a form users can understand.

ERC3668

ERC-3668 can be used alongside this proposal, but it uses a different revert-based mechanism for off-chain lookup.

Security Considerations

Revert Reason Collisions

A custom error selector can theoretically collide with another error selector. Such a collision is unlikely to cause a problem unless the accompanying data also happens to correspond to a valid instruction.

Wallets must validate instruction data and apply appropriate user authorization rather than treating a matching error selector as sufficient authority.

Citation

Gavin John (@Pandapip1), "ERC-5568: Well-Known Format for Required Actions [DRAFT]," Ethereum Improvement Proposals, no. 5568, August 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5568.

Conclusion

ERC-5568 proposes a standardized mechanism for smart contracts to signal required actions to wallets.

If you have questions, feel free to contact me on Twitter.

Twitter @cardene777

I also publish articles on the following platforms.

https://chaldene.net/