{"eip":5568,"title":"Well-Known Format for Required Actions","description":"Signal to wallets that an action is needed through a well-known function and revert reason","authors":["Gavin John (@Pandapip1)"],"status":"Review","type":"Standards Track","category":"ERC","created":"2022-08-31","requires":[140],"discussionsTo":"https://ethereum-magicians.org/t/eip-5568-revert-signals/10622","repo":"ERCs","label":"ERC-5568","officialUrl":"https://eips.ethereum.org/EIPS/eip-5568","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5568.md","url":"https://eips.huatuo.xyz/eip-5568/","tldr":{"en":"A standard way for a contract to tell a wallet \"the user must do something first\" (approve a token, make an HTTP request, rotate keys) via a well-known view function and a custom revert error.","ja":"コントラクトがウォレットに「ユーザーが先に何かをしなければならない」（トークンの承認、HTTP リクエスト、鍵のローテーションなど）と伝えるための標準的な方法。よく知られた view 関数とカスタム revert エラーを使う。","ko":"컨트랙트가 잘 알려진 view 함수와 커스텀 revert 에러를 통해 지갑에 \"사용자가 먼저 무언가를 해야 한다\"(토큰 승인, HTTP 요청, 키 교체)고 알리는 표준 방법.","zh":"一种让合约通过一个众所周知的 view 函数和自定义 revert 错误，告诉钱包“用户必须先做某件事”（批准代币、发起 HTTP 请求、轮换密钥）的标准方法。"},"tags":["wallet","revert","ux","interface"],"explainers":{"en":{"lang":"en","tldr":"A standard way for a contract to tell a wallet \"the user must do something first\" (approve a token, make an HTTP request, rotate keys) via a well-known view function and a custom revert error.","tags":["wallet","revert","ux","interface"],"related":[140,3668,5269,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-5568/","markdown":"## What problem does it solve?\n\nOften a transaction will fail unless the user does something first: approve an [ERC-20](/eip-20/) allowance, fetch data from a server, sign something. Today that knowledge lives in each dApp's frontend, which must hard-code every prerequisite.\n\nERC-5568 lets the **contract itself** tell the wallet what action is needed, in a compact machine-readable form, so a wallet can handle it generically.\n\n## How it works\n\nTwo pieces:\n\n1. **Detection function**, which the wallet simulates before sending:\n\n   ```solidity\n   function walletSignal24(bytes32 selector, bytes function_data)\n       view returns (uint24 instruction_id, bytes instruction_data);\n   ```\n\n   `instruction_id = 0` means nothing is needed. A non-zero value names an instruction, and `instruction_data` holds its parameters.\n\n2. **Custom revert error**, used when an action was not taken (revert data relies on [EIP-140](/eip-140/) `REVERT`):\n\n   ```solidity\n   error WalletSignal24(uint24 instruction_id, bytes instruction_data);\n   ```\n\nRules:\n\n- An instruction's `instruction_id` should be the number of the ERC that defines it, and each ERC defines at most one. That ERC also defines the data layout.\n- The wallet must simulate `walletSignal24` locally before broadcasting, treating it as able to change state.\n- If the wallet does not support the instruction, it must show an error. Otherwise it performs the instruction and re-evaluates the transaction, unless the instruction says not to.\n- Invalid or unparsable instructions must produce an error, with no re-evaluation.\n\nERC-165 is not used; a wallet detects support by simply calling the function.\n\n## Sample code\n\nWallet-side check before sending a transaction (ethers v6):\n\n```ts\nimport { Contract, JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst abi = [\n  \"function walletSignal24(bytes32 selector, bytes function_data) view returns (uint24, bytes)\",\n];\n\nasync function requiredAction(to: string, data: string) {\n  const c = new Contract(to, abi, provider);\n  const selector = data.slice(0, 10).padEnd(66, \"0\"); // 4-byte selector, right-padded to bytes32\n  try {\n    const [id, payload] = await c.walletSignal24.staticCall(selector, \"0x\" + data.slice(10));\n    return id === 0n ? null : { id: Number(id), payload };\n  } catch {\n    return null; // contract does not implement ERC-5568\n  }\n}\n```\n\nHow the selector is packed into `bytes32` and whether `function_data` includes it are not spelled out in the spec; this example is one reasonable reading.\n\n## Things to know\n\n- Status is **Review**; the format may still change.\n- This ERC defines only the signalling envelope. Concrete instructions (and their data formats) must be defined by other ERCs.\n- [ERC-3668](/eip-3668/) (CCIP Read) solves a related problem, fetching off-chain data, with a different revert-based mechanism; the two can coexist.\n- The spec considers collisions with existing custom errors unlikely and mostly harmless.\n"},"ja":{"lang":"ja","tldr":"コントラクトがウォレットに「ユーザーが先に何かをしなければならない」（トークンの承認、HTTP リクエスト、鍵のローテーションなど）と伝えるための標準的な方法。よく知られた view 関数とカスタム revert エラーを使う。","tags":["wallet","revert","ux","interface"],"related":[140,3668,5269,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-5568/","markdown":"## 何を解決するのか\n\nトランザクションが、ユーザーが先に何かをしない限り失敗することはよくあります。[ERC-20](/eip-20/) の allowance の承認、サーバーからのデータ取得、何かへの署名などです。現状では、この知識は各 dApp のフロントエンドにあり、あらゆる前提条件をハードコードしなければなりません。\n\nERC-5568 は、**コントラクト自身**がどんなアクションが必要かを、コンパクトで機械可読な形でウォレットに伝えられるようにし、ウォレットが汎用的に処理できるようにします。\n\n## 仕組み\n\n2 つの要素があります。\n\n1. **検出関数**。ウォレットは送信前にこれをシミュレーションします。\n\n   ```solidity\n   function walletSignal24(bytes32 selector, bytes function_data)\n       view returns (uint24 instruction_id, bytes instruction_data);\n   ```\n\n   `instruction_id = 0` は何も必要ないことを意味します。0 以外の値は命令を指し、`instruction_data` がそのパラメーターを保持します。\n\n2. **カスタム revert エラー**。アクションが実行されなかったときに使われます（revert データは [EIP-140](/eip-140/) の `REVERT` に依存します）。\n\n   ```solidity\n   error WalletSignal24(uint24 instruction_id, bytes instruction_data);\n   ```\n\nルール:\n\n- 命令の `instruction_id` は、それを定義する ERC の番号にすべきで、各 ERC が定義する命令は最大 1 つです。その ERC がデータのレイアウトも定義します。\n- ウォレットは、ブロードキャストする前に `walletSignal24` をローカルでシミュレーションしなければならず、これが状態を変更しうるものとして扱います。\n- ウォレットがその命令をサポートしていない場合は、エラーを表示しなければなりません。そうでなければ、命令を実行し、命令が不要と示していない限り、トランザクションを再評価します。\n- 無効な、または解析できない命令はエラーにしなければならず、再評価は行いません。\n\nERC-165 は使いません。ウォレットは単に関数を呼び出すことでサポートを検出します。\n\n## サンプルコード\n\nトランザクション送信前のウォレット側のチェック（ethers v6）:\n\n```ts\nimport { Contract, JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst abi = [\n  \"function walletSignal24(bytes32 selector, bytes function_data) view returns (uint24, bytes)\",\n];\n\nasync function requiredAction(to: string, data: string) {\n  const c = new Contract(to, abi, provider);\n  const selector = data.slice(0, 10).padEnd(66, \"0\"); // 4-byte selector, right-padded to bytes32\n  try {\n    const [id, payload] = await c.walletSignal24.staticCall(selector, \"0x\" + data.slice(10));\n    return id === 0n ? null : { id: Number(id), payload };\n  } catch {\n    return null; // contract does not implement ERC-5568\n  }\n}\n```\n\nセレクターを `bytes32` にどう詰めるか、`function_data` にそれを含めるかどうかは、仕様では明記されていません。この例は 1 つの妥当な解釈です。\n\n## 知っておくべきこと\n\n- ステータスは **Review** で、形式はまだ変わる可能性があります。\n- この ERC が定義するのはシグナリングの外枠だけです。具体的な命令（とそのデータ形式）は他の ERC が定義しなければなりません。\n- [ERC-3668](/eip-3668/)（CCIP Read）は、関連する問題であるオフチェーンデータの取得を、revert に基づく別の仕組みで解決します。両者は共存できます。\n- 仕様は、既存のカスタムエラーとの衝突はありそうになく、たいていは無害だと考えています。\n"},"ko":{"lang":"ko","tldr":"컨트랙트가 잘 알려진 view 함수와 커스텀 revert 에러를 통해 지갑에 \"사용자가 먼저 무언가를 해야 한다\"(토큰 승인, HTTP 요청, 키 교체)고 알리는 표준 방법.","tags":["wallet","revert","ux","interface"],"related":[140,3668,5269,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-5568/","markdown":"## 어떤 문제를 해결하나요?\n\n트랜잭션은 사용자가 먼저 무언가를 하지 않으면 실패하는 경우가 많습니다. [ERC-20](/eip-20/) allowance 승인, 서버에서 데이터 가져오기, 무언가에 서명하기 등입니다. 지금은 이런 지식이 각 dApp의 프론트엔드에 있어, 모든 전제 조건을 하드코딩해야 합니다.\n\nERC-5568은 **컨트랙트 자체**가 필요한 동작을 간결하고 기계가 읽을 수 있는 형태로 지갑에 알려, 지갑이 이를 범용적으로 처리할 수 있게 합니다.\n\n## 어떻게 동작하나요?\n\n두 가지 요소가 있습니다.\n\n1. **감지 함수**. 지갑은 전송 전에 이를 시뮬레이션합니다.\n\n   ```solidity\n   function walletSignal24(bytes32 selector, bytes function_data)\n       view returns (uint24 instruction_id, bytes instruction_data);\n   ```\n\n   `instruction_id = 0`은 아무것도 필요 없다는 뜻입니다. 0이 아닌 값은 명령을 가리키며, `instruction_data`가 그 파라미터를 담습니다.\n\n2. **커스텀 revert 에러**. 필요한 동작이 수행되지 않았을 때 사용됩니다(revert 데이터는 [EIP-140](/eip-140/)의 `REVERT`에 의존).\n\n   ```solidity\n   error WalletSignal24(uint24 instruction_id, bytes instruction_data);\n   ```\n\n규칙:\n\n- 명령의 `instruction_id`는 그것을 정의하는 ERC의 번호여야 하며, 각 ERC는 최대 하나의 명령을 정의합니다. 그 ERC가 데이터 레이아웃도 정의합니다.\n- 지갑은 브로드캐스트하기 전에 `walletSignal24`를 로컬에서 시뮬레이션해야 하며, 이를 상태를 바꿀 수 있는 것으로 취급해야 합니다.\n- 지갑이 해당 명령을 지원하지 않으면 오류를 표시해야 합니다. 그렇지 않으면 명령을 수행하고, 명령이 그럴 필요가 없다고 하지 않는 한 트랜잭션을 다시 평가합니다.\n- 유효하지 않거나 파싱할 수 없는 명령은 오류를 내야 하며, 재평가하지 않습니다.\n\nERC-165는 사용하지 않습니다. 지갑은 함수를 단순히 호출해 지원 여부를 감지합니다.\n\n## 샘플 코드\n\n트랜잭션을 보내기 전 지갑 측 확인(ethers v6):\n\n```ts\nimport { Contract, JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst abi = [\n  \"function walletSignal24(bytes32 selector, bytes function_data) view returns (uint24, bytes)\",\n];\n\nasync function requiredAction(to: string, data: string) {\n  const c = new Contract(to, abi, provider);\n  const selector = data.slice(0, 10).padEnd(66, \"0\"); // 4-byte selector, right-padded to bytes32\n  try {\n    const [id, payload] = await c.walletSignal24.staticCall(selector, \"0x\" + data.slice(10));\n    return id === 0n ? null : { id: Number(id), payload };\n  } catch {\n    return null; // contract does not implement ERC-5568\n  }\n}\n```\n\n셀렉터를 `bytes32`에 어떻게 담는지, `function_data`가 그것을 포함하는지는 명세에 명시되어 있지 않습니다. 이 예시는 합리적인 해석 중 하나입니다.\n\n## 알아둘 점\n\n- 상태는 **Review**이며 형식이 아직 바뀔 수 있습니다.\n- 이 ERC는 시그널링 봉투만 정의합니다. 구체적인 명령(과 그 데이터 형식)은 다른 ERC가 정의해야 합니다.\n- [ERC-3668](/eip-3668/)(CCIP Read)은 관련된 문제인 오프체인 데이터 가져오기를 다른 revert 기반 메커니즘으로 해결하며, 둘은 공존할 수 있습니다.\n- 명세는 기존 커스텀 에러와의 충돌 가능성이 낮고 대부분 무해하다고 봅니다.\n"},"zh":{"lang":"zh","tldr":"一种让合约通过一个众所周知的 view 函数和自定义 revert 错误，告诉钱包“用户必须先做某件事”（批准代币、发起 HTTP 请求、轮换密钥）的标准方法。","tags":["wallet","revert","ux","interface"],"related":[140,3668,5269,20],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-5568/","markdown":"## 它解决什么问题？\n\n交易常常会失败，除非用户先做某件事：批准 [ERC-20](/eip-20/) 的 allowance、从服务器获取数据、签署某些内容。目前这些知识存在于每个 dApp 的前端中，前端必须硬编码每一个前置条件。\n\nERC-5568 让**合约本身**以紧凑、机器可读的形式告诉钱包需要什么操作，从而使钱包能够通用地处理。\n\n## 它如何运作\n\n分为两部分：\n\n1. **检测函数**，钱包在发送前会模拟调用它：\n\n   ```solidity\n   function walletSignal24(bytes32 selector, bytes function_data)\n       view returns (uint24 instruction_id, bytes instruction_data);\n   ```\n\n   `instruction_id = 0` 表示不需要任何操作。非零值指明一条指令，`instruction_data` 保存其参数。\n\n2. **自定义 revert 错误**，在未执行所需操作时使用（revert 数据依赖 [EIP-140](/eip-140/) 的 `REVERT`）：\n\n   ```solidity\n   error WalletSignal24(uint24 instruction_id, bytes instruction_data);\n   ```\n\n规则：\n\n- 指令的 `instruction_id` 应当是定义它的 ERC 的编号，每个 ERC 最多定义一条指令。该 ERC 同时定义数据布局。\n- 钱包在广播之前必须在本地模拟 `walletSignal24`，并把它视为可能改变状态。\n- 如果钱包不支持该指令，必须显示错误。否则它会执行该指令并重新评估交易，除非指令声明不需要这样做。\n- 无效或无法解析的指令必须产生错误，且不重新评估。\n\n不使用 ERC-165；钱包只需调用该函数即可检测是否支持。\n\n## 示例代码\n\n钱包端在发送交易前的检查（ethers v6）：\n\n```ts\nimport { Contract, JsonRpcProvider } from \"ethers\";\n\nconst provider = new JsonRpcProvider(process.env.RPC_URL);\nconst abi = [\n  \"function walletSignal24(bytes32 selector, bytes function_data) view returns (uint24, bytes)\",\n];\n\nasync function requiredAction(to: string, data: string) {\n  const c = new Contract(to, abi, provider);\n  const selector = data.slice(0, 10).padEnd(66, \"0\"); // 4-byte selector, right-padded to bytes32\n  try {\n    const [id, payload] = await c.walletSignal24.staticCall(selector, \"0x\" + data.slice(10));\n    return id === 0n ? null : { id: Number(id), payload };\n  } catch {\n    return null; // contract does not implement ERC-5568\n  }\n}\n```\n\n规范没有明确说明选择器如何打包进 `bytes32`，也没有说明 `function_data` 是否包含它；这个示例只是一种合理的解读。\n\n## 需要注意\n\n- 状态为 **Review**；格式仍可能变化。\n- 这个 ERC 只定义信号传递的外壳。具体的指令（及其数据格式）必须由其他 ERC 定义。\n- [ERC-3668](/eip-3668/)（CCIP Read）用另一种基于 revert 的机制解决一个相关问题，即获取链下数据；两者可以共存。\n- 规范认为与现有自定义错误发生冲突的可能性不大，且大多无害。\n"}},"requiredBy":[5289]}
