{"eip":7821,"title":"Minimal Batch Executor Interface","description":"A minimal batch executor interface for delegations","authors":["Vectorized (@Vectorized)","Jake Moxey (@jxom)","Hadrien Croubois (@Amxx)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2024-11-21","requires":[7579],"discussionsTo":"https://ethereum-magicians.org/t/erc-7821-minimal-batch-executor-interface/21776","repo":"ERCs","label":"ERC-7821","officialUrl":"https://eips.ethereum.org/EIPS/eip-7821","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7821.md","url":"https://eips.huatuo.xyz/eip-7821/","tldr":{"en":"A minimal execute(mode, data) interface for atomic batched calls, so dapps can send approve + swap in one transaction to any EIP-7702-delegated EOA or smart account.","ja":"アトミックなバッチ呼び出しのための最小限の execute(mode, data) インターフェース。dapp は、EIP-7702 で委任された EOA でもスマートアカウントでも、approve + swap を 1 つのトランザクションで送れる。","ko":"원자적 배치 호출을 위한 최소한의 execute(mode, data) 인터페이스. dapp이 EIP-7702로 위임된 모든 EOA나 스마트 계정에 approve + swap을 한 트랜잭션으로 보낼 수 있게 한다.","zh":"一个用于原子批量调用的极简 execute(mode, data) 接口，让 dapp 可以在一笔交易中向任何经 EIP-7702 委托的 EOA 或智能账户发送 approve + swap。"},"tags":["account-abstraction","batching","eip-7702","smart-account","wallet"],"explainers":{"en":{"lang":"en","tldr":"A minimal execute(mode, data) interface for atomic batched calls, so dapps can send approve + swap in one transaction to any EIP-7702-delegated EOA or smart account.","tags":["account-abstraction","batching","eip-7702","smart-account","wallet"],"related":[7702,7579,5792],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7821/","markdown":"## What problem does it solve?\n\nWith [EIP-7702](/eip-7702/), an ordinary EOA can delegate to smart-contract code and gain features like atomic batching: \"approve, then swap\" in one transaction instead of two. But each wallet vendor ships its own delegation contract. If every one exposes a different batch function, a dapp has to special-case each wallet, and users might be pushed to switch delegations, which costs gas and carries risk.\n\nERC-7821 defines the smallest possible common interface for batch execution, borrowing `execute` and `supportsExecutionMode` from [ERC-7579](/eip-7579/) so existing modular smart accounts are compatible too. It complements the wallet-side `wallet_sendCalls` API from [EIP-5792](/eip-5792/).\n\n## How it works\n\nTwo functions:\n\n- `execute(bytes32 mode, bytes executionData)` runs a list of `Call { to, value, data }` in order. If any call fails, the whole batch reverts. A `to` of `address(0)` means \"this account\", which saves calldata.\n- `supportsExecutionMode(bytes32 mode)` tells callers which modes are supported.\n\nModes (first 10 bytes shown):\n\n| Mode | Meaning |\n| --- | --- |\n| `0x01000000000000000000…` | Single batch, `executionData = abi.encode(calls)` |\n| `0x01000000000078210001…` | Single batch, optionally `abi.encode(calls, opData)` |\n| `0x01000000000078210002…` | Batch of batches (`abi.encode(bytes[])`), optional |\n\nAuthorization: with no `opData`, the implementation should require `msg.sender == address(this)`, which is exactly the case when an EIP-7702 EOA sends a transaction to itself. With `opData`, the implementation should verify a signature carried inside it, which allows relayers or entry points to submit on the user's behalf. The batch-of-batches mode lets one transaction carry batches signed by different signers.\n\n## Sample code\n\nCheck support, then send approve + swap from a delegated EOA to itself (ethers v6):\n\n```ts\nimport { AbiCoder, Contract, Interface } from \"ethers\";\n\nconst MODE_BATCH = \"0x0100000000000000000000000000000000000000000000000000000000000000\";\n\nconst account = new Contract(userAddress, [\n  \"function supportsExecutionMode(bytes32) view returns (bool)\",\n  \"function execute(bytes32 mode, bytes executionData) payable\",\n], signer); // signer is the EOA itself\n\nif (!(await account.supportsExecutionMode(MODE_BATCH))) throw new Error(\"no batch support\");\n\nconst erc20 = new Interface([\"function approve(address,uint256)\"]);\nconst router = new Interface([\"function swap(uint256 amountIn, uint256 minOut)\"]);\n\nconst calls = [\n  { to: tokenAddr,  value: 0n, data: erc20.encodeFunctionData(\"approve\", [routerAddr, amountIn]) },\n  { to: routerAddr, value: 0n, data: router.encodeFunctionData(\"swap\", [amountIn, minOut]) },\n];\nconst executionData = AbiCoder.defaultAbiCoder().encode(\n  [\"tuple(address to,uint256 value,bytes data)[]\"], [calls],\n);\nawait (await account.execute(MODE_BATCH, executionData)).wait();\n```\n\n## Things to know\n\n- **Status: Draft**, and it requires ERC-7579, which is also a Draft.\n- The `swap` signature above is a placeholder; use your DEX router's real ABI.\n- Access control is the implementer's job. An `execute` that skips the `msg.sender == address(this)` check, or validates `opData` signatures poorly, lets anyone drain the account.\n- Batches are atomic only in the \"revert on any failure\" sense; there is no partial-success mode in this standard.\n"},"ja":{"lang":"ja","tldr":"アトミックなバッチ呼び出しのための最小限の execute(mode, data) インターフェース。dapp は、EIP-7702 で委任された EOA でもスマートアカウントでも、approve + swap を 1 つのトランザクションで送れる。","tags":["account-abstraction","batching","eip-7702","smart-account","wallet"],"related":[7702,7579,5792],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7821/","markdown":"## 何を解決するのか\n\n[EIP-7702](/eip-7702/) を使うと、通常の EOA がスマートコントラクトのコードに委任し、アトミックなバッチ処理のような機能を得られます。「approve してから swap する」を 2 つのトランザクションではなく 1 つで行えます。しかし、ウォレットベンダーごとに独自の委任コントラクトを提供しています。それぞれが異なるバッチ関数を公開していると、dapp はウォレットごとに個別対応が必要になり、ユーザーは委任の切り替えを迫られるかもしれません。それにはガスがかかり、リスクも伴います。\n\nERC-7821 は、バッチ実行のための可能な限り小さな共通インターフェースを定義します。[ERC-7579](/eip-7579/) から `execute` と `supportsExecutionMode` を借りているため、既存のモジュラー型スマートアカウントとも互換性があります。[EIP-5792](/eip-5792/) のウォレット側 API である `wallet_sendCalls` を補完するものです。\n\n## 仕組み\n\n2 つの関数があります。\n\n- `execute(bytes32 mode, bytes executionData)` は `Call { to, value, data }` のリストを順番に実行します。いずれかの呼び出しが失敗すると、バッチ全体が revert します。`to` が `address(0)` の場合は「このアカウント自身」を意味し、calldata を節約できます。\n- `supportsExecutionMode(bytes32 mode)` は、呼び出し側にどのモードがサポートされているかを伝えます。\n\nモード（先頭 10 バイトを表示）:\n\n| モード | 意味 |\n| --- | --- |\n| `0x01000000000000000000…` | 単一バッチ、`executionData = abi.encode(calls)` |\n| `0x01000000000078210001…` | 単一バッチ、任意で `abi.encode(calls, opData)` |\n| `0x01000000000078210002…` | バッチのバッチ（`abi.encode(bytes[])`）、任意 |\n\n認可: `opData` がない場合、実装は `msg.sender == address(this)` を要求すべきです。これは、EIP-7702 の EOA が自分自身にトランザクションを送る場合にまさに当てはまります。`opData` がある場合、実装はその中に含まれる署名を検証すべきで、これによりリレイヤーやエントリーポイントがユーザーに代わって送信できます。バッチのバッチモードでは、異なる署名者が署名したバッチを 1 つのトランザクションで運べます。\n\n## サンプルコード\n\nサポートを確認してから、委任された EOA が自分自身に approve + swap を送ります（ethers v6）:\n\n```ts\nimport { AbiCoder, Contract, Interface } from \"ethers\";\n\nconst MODE_BATCH = \"0x0100000000000000000000000000000000000000000000000000000000000000\";\n\nconst account = new Contract(userAddress, [\n  \"function supportsExecutionMode(bytes32) view returns (bool)\",\n  \"function execute(bytes32 mode, bytes executionData) payable\",\n], signer); // signer is the EOA itself\n\nif (!(await account.supportsExecutionMode(MODE_BATCH))) throw new Error(\"no batch support\");\n\nconst erc20 = new Interface([\"function approve(address,uint256)\"]);\nconst router = new Interface([\"function swap(uint256 amountIn, uint256 minOut)\"]);\n\nconst calls = [\n  { to: tokenAddr,  value: 0n, data: erc20.encodeFunctionData(\"approve\", [routerAddr, amountIn]) },\n  { to: routerAddr, value: 0n, data: router.encodeFunctionData(\"swap\", [amountIn, minOut]) },\n];\nconst executionData = AbiCoder.defaultAbiCoder().encode(\n  [\"tuple(address to,uint256 value,bytes data)[]\"], [calls],\n);\nawait (await account.execute(MODE_BATCH, executionData)).wait();\n```\n\n## 知っておくべきこと\n\n- **ステータス: Draft。** さらに、同じく Draft である ERC-7579 が必要です。\n- 上の `swap` のシグネチャはプレースホルダーです。実際の DEX ルーターの ABI を使ってください。\n- アクセス制御は実装者の責任です。`msg.sender == address(this)` のチェックを省いた `execute` や、`opData` の署名検証が不十分な `execute` は、誰でもアカウントを空にできてしまいます。\n- バッチがアトミックなのは「いずれかが失敗したら revert」という意味においてのみです。この標準には部分的成功のモードはありません。\n"},"ko":{"lang":"ko","tldr":"원자적 배치 호출을 위한 최소한의 execute(mode, data) 인터페이스. dapp이 EIP-7702로 위임된 모든 EOA나 스마트 계정에 approve + swap을 한 트랜잭션으로 보낼 수 있게 한다.","tags":["account-abstraction","batching","eip-7702","smart-account","wallet"],"related":[7702,7579,5792],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7821/","markdown":"## 어떤 문제를 해결하나요?\n\n[EIP-7702](/eip-7702/)를 사용하면 일반 EOA가 스마트 컨트랙트 코드에 위임해 원자적 배치 같은 기능을 얻을 수 있습니다. \"approve 후 swap\"을 두 트랜잭션이 아니라 한 트랜잭션으로 처리합니다. 하지만 지갑 벤더마다 자체 위임 컨트랙트를 내놓습니다. 각자 서로 다른 배치 함수를 노출하면 dapp은 지갑마다 예외 처리를 해야 하고, 사용자는 위임을 바꾸도록 떠밀릴 수 있는데, 이는 가스가 들고 위험도 따릅니다.\n\nERC-7821은 배치 실행을 위한 가능한 한 가장 작은 공통 인터페이스를 정의합니다. [ERC-7579](/eip-7579/)에서 `execute`와 `supportsExecutionMode`를 가져왔으므로 기존 모듈형 스마트 계정과도 호환됩니다. [EIP-5792](/eip-5792/)의 지갑 측 API인 `wallet_sendCalls`를 보완합니다.\n\n## 어떻게 동작하나요?\n\n함수는 두 개입니다.\n\n- `execute(bytes32 mode, bytes executionData)`는 `Call { to, value, data }` 목록을 순서대로 실행합니다. 하나라도 호출이 실패하면 배치 전체가 revert됩니다. `to`가 `address(0)`이면 \"이 계정 자신\"을 뜻하며 calldata를 절약합니다.\n- `supportsExecutionMode(bytes32 mode)`는 호출자에게 어떤 모드가 지원되는지 알려 줍니다.\n\n모드(앞 10바이트만 표시):\n\n| 모드 | 의미 |\n| --- | --- |\n| `0x01000000000000000000…` | 단일 배치, `executionData = abi.encode(calls)` |\n| `0x01000000000078210001…` | 단일 배치, 선택적으로 `abi.encode(calls, opData)` |\n| `0x01000000000078210002…` | 배치의 배치(`abi.encode(bytes[])`), 선택 사항 |\n\n인가: `opData`가 없으면 구현은 `msg.sender == address(this)`를 요구해야 하며, 이는 EIP-7702 EOA가 자기 자신에게 트랜잭션을 보내는 경우에 정확히 해당합니다. `opData`가 있으면 구현은 그 안에 담긴 서명을 검증해야 하며, 이를 통해 릴레이어나 엔트리 포인트가 사용자를 대신해 제출할 수 있습니다. 배치의 배치 모드는 서로 다른 서명자가 서명한 배치를 한 트랜잭션에 실을 수 있게 합니다.\n\n## 샘플 코드\n\n지원 여부를 확인한 뒤, 위임된 EOA가 자기 자신에게 approve + swap을 보냅니다(ethers v6).\n\n```ts\nimport { AbiCoder, Contract, Interface } from \"ethers\";\n\nconst MODE_BATCH = \"0x0100000000000000000000000000000000000000000000000000000000000000\";\n\nconst account = new Contract(userAddress, [\n  \"function supportsExecutionMode(bytes32) view returns (bool)\",\n  \"function execute(bytes32 mode, bytes executionData) payable\",\n], signer); // signer is the EOA itself\n\nif (!(await account.supportsExecutionMode(MODE_BATCH))) throw new Error(\"no batch support\");\n\nconst erc20 = new Interface([\"function approve(address,uint256)\"]);\nconst router = new Interface([\"function swap(uint256 amountIn, uint256 minOut)\"]);\n\nconst calls = [\n  { to: tokenAddr,  value: 0n, data: erc20.encodeFunctionData(\"approve\", [routerAddr, amountIn]) },\n  { to: routerAddr, value: 0n, data: router.encodeFunctionData(\"swap\", [amountIn, minOut]) },\n];\nconst executionData = AbiCoder.defaultAbiCoder().encode(\n  [\"tuple(address to,uint256 value,bytes data)[]\"], [calls],\n);\nawait (await account.execute(MODE_BATCH, executionData)).wait();\n```\n\n## 알아둘 점\n\n- **상태: Draft**이며, 역시 Draft인 ERC-7579가 필요합니다.\n- 위의 `swap` 시그니처는 자리 표시자입니다. 실제 DEX 라우터의 ABI를 사용하세요.\n- 접근 제어는 구현자의 몫입니다. `msg.sender == address(this)` 검사를 건너뛰거나 `opData` 서명을 부실하게 검증하는 `execute`는 누구든 계정을 털어 갈 수 있게 합니다.\n- 배치는 \"하나라도 실패하면 revert\"라는 의미에서만 원자적입니다. 이 표준에는 부분 성공 모드가 없습니다.\n"},"zh":{"lang":"zh","tldr":"一个用于原子批量调用的极简 execute(mode, data) 接口，让 dapp 可以在一笔交易中向任何经 EIP-7702 委托的 EOA 或智能账户发送 approve + swap。","tags":["account-abstraction","batching","eip-7702","smart-account","wallet"],"related":[7702,7579,5792],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7821/","markdown":"## 它解决什么问题？\n\n借助 [EIP-7702](/eip-7702/)，普通 EOA 可以委托给智能合约代码，获得原子批处理等功能：把\"先 approve，再 swap\"放进一笔交易，而不是两笔。但每个钱包厂商都发布自己的委托合约。如果每个合约暴露的批量函数各不相同，dapp 就得为每个钱包做特殊处理，用户也可能被迫切换委托，而这既要花 gas，又有风险。\n\nERC-7821 定义了批量执行的最小公共接口，从 [ERC-7579](/eip-7579/) 借用了 `execute` 和 `supportsExecutionMode`，因此现有的模块化智能账户也能兼容。它与 [EIP-5792](/eip-5792/) 中钱包端的 `wallet_sendCalls` API 互为补充。\n\n## 它如何运作\n\n两个函数：\n\n- `execute(bytes32 mode, bytes executionData)` 按顺序执行一组 `Call { to, value, data }`。只要有一个调用失败，整个批次就会 revert。`to` 为 `address(0)` 表示\"本账户\"，可以节省 calldata。\n- `supportsExecutionMode(bytes32 mode)` 告诉调用者支持哪些模式。\n\n模式（显示前 10 个字节）：\n\n| 模式 | 含义 |\n| --- | --- |\n| `0x01000000000000000000…` | 单个批次，`executionData = abi.encode(calls)` |\n| `0x01000000000078210001…` | 单个批次，可选 `abi.encode(calls, opData)` |\n| `0x01000000000078210002…` | 批次的批次（`abi.encode(bytes[])`），可选 |\n\n授权：没有 `opData` 时，实现应当要求 `msg.sender == address(this)`，这恰好就是 EIP-7702 的 EOA 向自己发送交易的情形。有 `opData` 时，实现应当验证其中携带的签名，这样中继者或入口点就可以代表用户提交。批次的批次模式允许一笔交易携带由不同签名者签署的批次。\n\n## 示例代码\n\n检查是否支持，然后由被委托的 EOA 向自己发送 approve + swap（ethers v6）：\n\n```ts\nimport { AbiCoder, Contract, Interface } from \"ethers\";\n\nconst MODE_BATCH = \"0x0100000000000000000000000000000000000000000000000000000000000000\";\n\nconst account = new Contract(userAddress, [\n  \"function supportsExecutionMode(bytes32) view returns (bool)\",\n  \"function execute(bytes32 mode, bytes executionData) payable\",\n], signer); // signer is the EOA itself\n\nif (!(await account.supportsExecutionMode(MODE_BATCH))) throw new Error(\"no batch support\");\n\nconst erc20 = new Interface([\"function approve(address,uint256)\"]);\nconst router = new Interface([\"function swap(uint256 amountIn, uint256 minOut)\"]);\n\nconst calls = [\n  { to: tokenAddr,  value: 0n, data: erc20.encodeFunctionData(\"approve\", [routerAddr, amountIn]) },\n  { to: routerAddr, value: 0n, data: router.encodeFunctionData(\"swap\", [amountIn, minOut]) },\n];\nconst executionData = AbiCoder.defaultAbiCoder().encode(\n  [\"tuple(address to,uint256 value,bytes data)[]\"], [calls],\n);\nawait (await account.execute(MODE_BATCH, executionData)).wait();\n```\n\n## 需要注意\n\n- **状态：Draft**，并且它依赖同样处于 Draft 状态的 ERC-7579。\n- 上面的 `swap` 签名只是占位；请使用你的 DEX 路由合约真实的 ABI。\n- 访问控制是实现者的责任。如果 `execute` 跳过了 `msg.sender == address(this)` 检查，或者对 `opData` 签名的验证不严，任何人都可以掏空该账户。\n- 批次只有在\"任一失败即 revert\"的意义上才是原子的；此标准中没有部分成功的模式。\n"}}}
