{"eip":7884,"title":"Operation Router","description":"A protocol that enables smart contracts to redirect write operations to external systems.","authors":["Lucas Picollo (@pikonha)","Alex Netto (@alextnetto)","Nick Johnson (@arachnid)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2025-01-23","discussionsTo":"https://ethereum-magicians.org/t/operation-router/22633","repo":"ERCs","label":"ERC-7884","officialUrl":"https://eips.ethereum.org/EIPS/eip-7884","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7884.md","url":"https://eips.huatuo.xyz/eip-7884/","tldr":{"en":"A write-side companion to CCIP-Read: a contract tells clients, via a reverting view call, whether an update should go to an L2 contract or to an off-chain gateway authenticated with an EIP-712 signature.","ja":"CCIP-Read の書き込み側の対となる仕様。コントラクトが、revert する view 呼び出しを通じて、更新を L2 コントラクトに送るべきか、EIP-712 署名で認証されるオフチェーンのゲートウェイに送るべきかをクライアントに伝える。","ko":"CCIP-Read의 쓰기 쪽 짝이 되는 표준. 컨트랙트가 revert되는 view 호출을 통해, 업데이트를 L2 컨트랙트로 보내야 하는지 EIP-712 서명으로 인증하는 오프체인 게이트웨이로 보내야 하는지 클라이언트에 알려 준다.","zh":"CCIP-Read 在写入方向上的配套标准：合约通过一次会 revert 的 view 调用，告诉客户端某次更新应当发往 L2 合约，还是发往以 EIP-712 签名认证的链下网关。"},"tags":["offchain","l2","ccip","routing","ens"],"explainers":{"en":{"lang":"en","tldr":"A write-side companion to CCIP-Read: a contract tells clients, via a reverting view call, whether an update should go to an L2 contract or to an off-chain gateway authenticated with an EIP-712 signature.","tags":["offchain","l2","ccip","routing","ens"],"related":[3668,712],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7884/","markdown":"## What problem does it solve?\n\n[ERC-3668](/eip-3668/) (CCIP-Read) gave contracts a standard way to say \"the data you want to *read* lives somewhere else\". Many systems, ENS resolvers in particular, now keep their records on an L2 or in an off-chain database. But there was no matching standard for *writes*: when a user wants to update a record, the client had no generic way to learn where the update should be sent.\n\nThe Operation Router lets an L1 contract act as a signpost for write operations. A client asks the contract \"where should this call go?\" and gets a machine-readable answer: a specific contract on a specific chain, or an HTTP gateway that accepts signed requests.\n\n## How it works\n\nThe L1 contract implements one view function:\n\n```solidity\nfunction getOperationHandler(bytes calldata encodedFunction) external view;\n```\n\nThe client passes the ABI-encoded call it *wants* to make (for example `setText(node, key, value)`). The function never returns normally; it always reverts with one of three custom errors:\n\n| Revert | Meaning |\n| --- | --- |\n| `OperationHandledOnchain(chainId, contractAddress)` | Send the same calldata as a transaction to `contractAddress` on `chainId` (L1 or an L2) |\n| `OperationHandledOffchain(DomainData, url, MessageData)` | Sign the request with [EIP-712](/eip-712/) and POST it to `url` |\n| `FunctionNotSupported()` | This selector is not routed |\n\nFor the off-chain case, `DomainData` is the EIP-712 domain (name, version, chainId, verifyingContract) and `MessageData` bundles the original calldata, the `sender` and an `expirationTimestamp`. The gateway URL follows the CCIP-Read `/{sender}/{data}.json` convention, so a server can behave like a contract, while the EIP-712 signature proves the user authorised the change.\n\nBecause routing is decided per encoded call, a `multicall` that touches several destinations cannot be routed in one go; the client must route each inner call separately.\n\n## Sample code\n\nRouter contract and a client loop (viem-style, as in the spec):\n\n```solidity\ncontract ProfileRouter {\n    error OperationHandledOnchain(uint256 chainId, address contractAddress);\n    error FunctionNotSupported();\n\n    address constant L2_RESOLVER = address(0); // set to your L2 contract\n\n    function getOperationHandler(bytes calldata encodedFunction) external view {\n        bytes4 selector = bytes4(encodedFunction[:4]);\n        if (selector == bytes4(keccak256(\"setAddr(bytes32,address)\"))) {\n            revert OperationHandledOnchain(10, L2_RESOLVER);\n        }\n        revert FunctionNotSupported();\n    }\n}\n```\n\n```ts\ntry {\n  await client.readContract({ address: router, abi, functionName: \"getOperationHandler\",\n                              args: [encodeFunctionData(call)] });\n} catch (err) {\n  const e = decodeErrorResult({ abi, data: getRevertData(err) });\n  if (e.errorName === \"OperationHandledOnchain\") {\n    const [chainId, target] = e.args;\n    await walletOn(Number(chainId)).writeContract({ ...call, address: target });\n  } else if (e.errorName === \"OperationHandledOffchain\") {\n    const [domain, url, message] = e.args;\n    const sig = await signer.signTypedData({ domain, types, primaryType: \"Message\", message });\n    await fetch(url, { method: \"POST\", body: JSON.stringify({ message, sig }) });\n  }\n}\n```\n\n## Things to know\n\n- **Status: Draft.** Error names and the message format may still change.\n- Using reverts to return data mirrors CCIP-Read's `OffchainLookup` pattern; clients must decode revert data rather than return values.\n- Off-chain gateways are trusted infrastructure: the spec asks them to verify EIP-712 signatures, enforce access control, handle concurrent updates, rate-limit and use HTTPS.\n- The `expirationTimestamp` in `MessageData` limits how long a signed off-chain request stays valid.\n"},"ja":{"lang":"ja","tldr":"CCIP-Read の書き込み側の対となる仕様。コントラクトが、revert する view 呼び出しを通じて、更新を L2 コントラクトに送るべきか、EIP-712 署名で認証されるオフチェーンのゲートウェイに送るべきかをクライアントに伝える。","tags":["offchain","l2","ccip","routing","ens"],"related":[3668,712],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7884/","markdown":"## 何を解決するのか\n\n[ERC-3668](/eip-3668/)（CCIP-Read）は、コントラクトが「*読み取り*たいデータは別の場所にある」と伝える標準的な方法を提供しました。多くのシステム、とりわけ ENS のリゾルバーは、現在レコードを L2 やオフチェーンのデータベースに保持しています。しかし、*書き込み*に対応する標準はありませんでした。ユーザーがレコードを更新したいとき、クライアントには、更新をどこに送るべきかを知る汎用的な方法がなかったのです。\n\nOperation Router を使うと、L1 のコントラクトが書き込み操作の道しるべとして機能できます。クライアントがコントラクトに「この呼び出しはどこに送るべきか」と尋ねると、機械可読な答えが返ります。特定のチェーン上の特定のコントラクト、または署名付きリクエストを受け付ける HTTP ゲートウェイです。\n\n## 仕組み\n\nL1 のコントラクトは 1 つの view 関数を実装します。\n\n```solidity\nfunction getOperationHandler(bytes calldata encodedFunction) external view;\n```\n\nクライアントは、*実行したい*呼び出し（たとえば `setText(node, key, value)`）を ABI エンコードして渡します。この関数は正常には返らず、常に次の 3 つのカスタムエラーのいずれかで revert します。\n\n| Revert | 意味 |\n| --- | --- |\n| `OperationHandledOnchain(chainId, contractAddress)` | 同じ calldata を、`chainId` 上の `contractAddress`（L1 または L2）にトランザクションとして送る |\n| `OperationHandledOffchain(DomainData, url, MessageData)` | リクエストに [EIP-712](/eip-712/) で署名し、`url` に POST する |\n| `FunctionNotSupported()` | この selector はルーティングされていない |\n\nオフチェーンの場合、`DomainData` は EIP-712 のドメイン（name、version、chainId、verifyingContract）で、`MessageData` は元の calldata、`sender`、`expirationTimestamp` をまとめたものです。ゲートウェイの URL は CCIP-Read の `/{sender}/{data}.json` の規約に従うため、サーバーはコントラクトのように振る舞えます。一方、EIP-712 署名は、ユーザーが変更を承認したことを証明します。\n\nルーティングはエンコードされた呼び出しごとに決まるため、複数の宛先に触れる `multicall` は一括ではルーティングできません。クライアントは内部の呼び出しをそれぞれ個別にルーティングする必要があります。\n\n## サンプルコード\n\nルーターコントラクトとクライアントのループ（仕様と同じ viem 風）:\n\n```solidity\ncontract ProfileRouter {\n    error OperationHandledOnchain(uint256 chainId, address contractAddress);\n    error FunctionNotSupported();\n\n    address constant L2_RESOLVER = address(0); // set to your L2 contract\n\n    function getOperationHandler(bytes calldata encodedFunction) external view {\n        bytes4 selector = bytes4(encodedFunction[:4]);\n        if (selector == bytes4(keccak256(\"setAddr(bytes32,address)\"))) {\n            revert OperationHandledOnchain(10, L2_RESOLVER);\n        }\n        revert FunctionNotSupported();\n    }\n}\n```\n\n```ts\ntry {\n  await client.readContract({ address: router, abi, functionName: \"getOperationHandler\",\n                              args: [encodeFunctionData(call)] });\n} catch (err) {\n  const e = decodeErrorResult({ abi, data: getRevertData(err) });\n  if (e.errorName === \"OperationHandledOnchain\") {\n    const [chainId, target] = e.args;\n    await walletOn(Number(chainId)).writeContract({ ...call, address: target });\n  } else if (e.errorName === \"OperationHandledOffchain\") {\n    const [domain, url, message] = e.args;\n    const sig = await signer.signTypedData({ domain, types, primaryType: \"Message\", message });\n    await fetch(url, { method: \"POST\", body: JSON.stringify({ message, sig }) });\n  }\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** エラー名やメッセージフォーマットはまだ変更される可能性があります。\n- revert でデータを返す方式は CCIP-Read の `OffchainLookup` パターンと同じです。クライアントは戻り値ではなく revert データをデコードする必要があります。\n- オフチェーンのゲートウェイは信頼されたインフラです。仕様は、EIP-712 署名の検証、アクセス制御の実施、同時更新の処理、レート制限、HTTPS の使用を求めています。\n- `MessageData` の `expirationTimestamp` は、署名されたオフチェーンのリクエストが有効でいられる期間を制限します。\n"},"ko":{"lang":"ko","tldr":"CCIP-Read의 쓰기 쪽 짝이 되는 표준. 컨트랙트가 revert되는 view 호출을 통해, 업데이트를 L2 컨트랙트로 보내야 하는지 EIP-712 서명으로 인증하는 오프체인 게이트웨이로 보내야 하는지 클라이언트에 알려 준다.","tags":["offchain","l2","ccip","routing","ens"],"related":[3668,712],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7884/","markdown":"## 어떤 문제를 해결하나요?\n\n[ERC-3668](/eip-3668/)(CCIP-Read)은 컨트랙트가 \"*읽으려는* 데이터가 다른 곳에 있다\"고 말하는 표준 방법을 제공했습니다. 많은 시스템, 특히 ENS 리졸버는 이제 레코드를 L2나 오프체인 데이터베이스에 보관합니다. 하지만 *쓰기*에 대응하는 표준은 없었습니다. 사용자가 레코드를 업데이트하려 할 때, 클라이언트는 업데이트를 어디로 보내야 하는지 알 수 있는 범용적인 방법이 없었습니다.\n\nOperation Router를 쓰면 L1 컨트랙트가 쓰기 작업의 이정표 역할을 할 수 있습니다. 클라이언트가 컨트랙트에 \"이 호출은 어디로 보내야 하나요?\"라고 물으면 기계가 읽을 수 있는 답을 받습니다. 특정 체인의 특정 컨트랙트, 또는 서명된 요청을 받는 HTTP 게이트웨이입니다.\n\n## 어떻게 동작하나요?\n\nL1 컨트랙트는 view 함수 하나를 구현합니다.\n\n```solidity\nfunction getOperationHandler(bytes calldata encodedFunction) external view;\n```\n\n클라이언트는 *하려는* 호출(예: `setText(node, key, value)`)을 ABI 인코딩해 넘깁니다. 이 함수는 정상적으로 반환하지 않고 항상 세 가지 커스텀 에러 중 하나로 revert됩니다.\n\n| Revert | 의미 |\n| --- | --- |\n| `OperationHandledOnchain(chainId, contractAddress)` | 같은 calldata를 `chainId`의 `contractAddress`(L1 또는 L2)로 트랜잭션으로 전송 |\n| `OperationHandledOffchain(DomainData, url, MessageData)` | 요청에 [EIP-712](/eip-712/)로 서명하고 `url`로 POST |\n| `FunctionNotSupported()` | 이 selector는 라우팅되지 않음 |\n\n오프체인의 경우 `DomainData`는 EIP-712 도메인(name, version, chainId, verifyingContract)이고, `MessageData`는 원래 calldata, `sender`, `expirationTimestamp`를 묶은 것입니다. 게이트웨이 URL은 CCIP-Read의 `/{sender}/{data}.json` 규약을 따르므로 서버가 컨트랙트처럼 동작할 수 있고, EIP-712 서명은 사용자가 변경을 승인했음을 증명합니다.\n\n라우팅은 인코딩된 호출마다 결정되므로, 여러 목적지를 건드리는 `multicall`은 한 번에 라우팅할 수 없습니다. 클라이언트는 내부 호출을 각각 따로 라우팅해야 합니다.\n\n## 샘플 코드\n\n라우터 컨트랙트와 클라이언트 루프(스펙과 같은 viem 스타일):\n\n```solidity\ncontract ProfileRouter {\n    error OperationHandledOnchain(uint256 chainId, address contractAddress);\n    error FunctionNotSupported();\n\n    address constant L2_RESOLVER = address(0); // set to your L2 contract\n\n    function getOperationHandler(bytes calldata encodedFunction) external view {\n        bytes4 selector = bytes4(encodedFunction[:4]);\n        if (selector == bytes4(keccak256(\"setAddr(bytes32,address)\"))) {\n            revert OperationHandledOnchain(10, L2_RESOLVER);\n        }\n        revert FunctionNotSupported();\n    }\n}\n```\n\n```ts\ntry {\n  await client.readContract({ address: router, abi, functionName: \"getOperationHandler\",\n                              args: [encodeFunctionData(call)] });\n} catch (err) {\n  const e = decodeErrorResult({ abi, data: getRevertData(err) });\n  if (e.errorName === \"OperationHandledOnchain\") {\n    const [chainId, target] = e.args;\n    await walletOn(Number(chainId)).writeContract({ ...call, address: target });\n  } else if (e.errorName === \"OperationHandledOffchain\") {\n    const [domain, url, message] = e.args;\n    const sig = await signer.signTypedData({ domain, types, primaryType: \"Message\", message });\n    await fetch(url, { method: \"POST\", body: JSON.stringify({ message, sig }) });\n  }\n}\n```\n\n## 알아둘 점\n\n- **상태: Draft.** 에러 이름과 메시지 형식은 아직 바뀔 수 있습니다.\n- revert로 데이터를 반환하는 방식은 CCIP-Read의 `OffchainLookup` 패턴과 같습니다. 클라이언트는 반환 값이 아니라 revert 데이터를 디코딩해야 합니다.\n- 오프체인 게이트웨이는 신뢰해야 하는 인프라입니다. 스펙은 게이트웨이가 EIP-712 서명을 검증하고, 접근 제어를 시행하고, 동시 업데이트를 처리하고, 속도 제한을 걸고, HTTPS를 사용하도록 요구합니다.\n- `MessageData`의 `expirationTimestamp`는 서명된 오프체인 요청이 유효한 기간을 제한합니다.\n"},"zh":{"lang":"zh","tldr":"CCIP-Read 在写入方向上的配套标准：合约通过一次会 revert 的 view 调用，告诉客户端某次更新应当发往 L2 合约，还是发往以 EIP-712 签名认证的链下网关。","tags":["offchain","l2","ccip","routing","ens"],"related":[3668,712],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7884/","markdown":"## 它解决什么问题？\n\n[ERC-3668](/eip-3668/)（CCIP-Read）为合约提供了一种标准方式来表达\"你想*读取*的数据存放在别处\"。许多系统，尤其是 ENS 解析器，如今把记录保存在 L2 或链下数据库中。但针对*写入*却没有对应的标准：当用户想更新某条记录时，客户端没有通用的办法得知更新应当发往何处。\n\nOperation Router 让 L1 合约充当写操作的路标。客户端问合约\"这次调用应该发往哪里？\"，得到一个机器可读的答案：某条特定链上的某个特定合约，或者一个接受签名请求的 HTTP 网关。\n\n## 它如何运作\n\nL1 合约实现一个 view 函数：\n\n```solidity\nfunction getOperationHandler(bytes calldata encodedFunction) external view;\n```\n\n客户端传入它*想要*发起的调用的 ABI 编码（例如 `setText(node, key, value)`）。该函数从不正常返回；它总是以三种自定义错误之一 revert：\n\n| Revert | 含义 |\n| --- | --- |\n| `OperationHandledOnchain(chainId, contractAddress)` | 将同样的 calldata 作为交易发送到 `chainId` 上的 `contractAddress`（L1 或某条 L2） |\n| `OperationHandledOffchain(DomainData, url, MessageData)` | 用 [EIP-712](/eip-712/) 对请求签名，并 POST 到 `url` |\n| `FunctionNotSupported()` | 这个 selector 没有被路由 |\n\n对于链下情形，`DomainData` 是 EIP-712 域（name、version、chainId、verifyingContract），`MessageData` 则包含原始 calldata、`sender` 和 `expirationTimestamp`。网关 URL 遵循 CCIP-Read 的 `/{sender}/{data}.json` 约定，因此服务器可以表现得像合约一样，而 EIP-712 签名则证明用户授权了这次更改。\n\n由于路由是按每次编码后的调用来决定的，涉及多个目的地的 `multicall` 无法一次性完成路由；客户端必须对每个内部调用分别进行路由。\n\n## 示例代码\n\n路由合约和客户端循环（viem 风格，与规范中一致）：\n\n```solidity\ncontract ProfileRouter {\n    error OperationHandledOnchain(uint256 chainId, address contractAddress);\n    error FunctionNotSupported();\n\n    address constant L2_RESOLVER = address(0); // set to your L2 contract\n\n    function getOperationHandler(bytes calldata encodedFunction) external view {\n        bytes4 selector = bytes4(encodedFunction[:4]);\n        if (selector == bytes4(keccak256(\"setAddr(bytes32,address)\"))) {\n            revert OperationHandledOnchain(10, L2_RESOLVER);\n        }\n        revert FunctionNotSupported();\n    }\n}\n```\n\n```ts\ntry {\n  await client.readContract({ address: router, abi, functionName: \"getOperationHandler\",\n                              args: [encodeFunctionData(call)] });\n} catch (err) {\n  const e = decodeErrorResult({ abi, data: getRevertData(err) });\n  if (e.errorName === \"OperationHandledOnchain\") {\n    const [chainId, target] = e.args;\n    await walletOn(Number(chainId)).writeContract({ ...call, address: target });\n  } else if (e.errorName === \"OperationHandledOffchain\") {\n    const [domain, url, message] = e.args;\n    const sig = await signer.signTypedData({ domain, types, primaryType: \"Message\", message });\n    await fetch(url, { method: \"POST\", body: JSON.stringify({ message, sig }) });\n  }\n}\n```\n\n## 需要注意\n\n- **状态：Draft。** 错误名称和消息格式仍可能变化。\n- 用 revert 返回数据与 CCIP-Read 的 `OffchainLookup` 模式如出一辙；客户端必须解码 revert 数据，而不是读取返回值。\n- 链下网关属于受信任的基础设施：规范要求它们验证 EIP-712 签名、执行访问控制、处理并发更新、限流并使用 HTTPS。\n- `MessageData` 中的 `expirationTimestamp` 限制了已签名的链下请求保持有效的时长。\n"}}}
