ERC-7884 Write Redirection Router (Operation Router)

Draft · Other · created 2025-01-23

A protocol by which a smart contract, upon receiving a write request, announces in a standardized way that the handling of that request should be delegated to L1, to another contract on an L2 chain, or to an off-chain server.

Why it is needed

As the Ethereum ecosystem grows, data increasingly needs to be split across multiple locations such as L1, L2, and off-chain databases. Without a common way to indicate which write requests should go where, each contract handles this differently, and wallets or clients cannot automatically recognize and process it. There is also no standard way to authenticate that a request delegating storage off-chain really came from a legitimate user, forcing each service to build its own authentication scheme, which is inefficient.

What to implement

In depth

A Structure That Uses revert as a Return Value

Although getOperationHandler is a view function, it conveys information not through an actual return value but by always reverting with an error. If the function is unsupported, it reverts with FunctionNotSupported; if a handling location exists, it reverts with OperationHandledOnchain or OperationHandledOffchain. The client wraps this call in a try/catch and reads the type and arguments of the reverted error to decide the next action. This applies the same pattern used in CCIP-Read (ERC-3668) to write operations.

On-chain Routing: OperationHandledOnchain

Used when a request must be handled by a contract on L1 itself or on another L2 chain. Only two values are returned, chainId and contractAddress, and the client uses this information to connect to that chain and send the actual write transaction to that contract. In the implementation example, when the selector is setAddress(bytes32,address), it routes to chain ID 10 (L2) and a specific address.

Off-chain Routing: OperationHandledOffchain and Authentication

When routing to an off-chain database, DomainData (the EIP-712 domain), url (the address to request), and MessageData (the original encoded data, the requester's address, and expiration time) are all returned together. The client signs this MessageData using EIP-712 and sends the request to that URL. The HTTP request path follows the /{sender}/{data}.json format used by ERC-3668, so the API behaves as if it were a contract.

Limitations with multicall

Because getOperationHandler determines the destination by looking at only a single encoded function it is given, transactions that need to go to different contracts at once, such as those bundled together via multicall, cannot be processed in a single call. In such cases, getOperationHandler must be called first for each call to determine its destination, and then the actual transactions must be sent sequentially to those destinations.

Backward compatibility

This standard adds only new interfaces that do not conflict with existing interfaces, uses only view functions for information queries, and can be implemented alongside existing storage methods, making it fully backward compatible.

Proposal status

This ERC is currently in Draft status, a proposal whose content may still change or be discussed further.

Things to watch out for

Original ERC · ← ERCs