---
eip: 7582
label: ERC-7582
title: Modular Accounts with Delegated Validation
status: Draft
type: Standards Track
category: ERC
created: 2023-12-25
requires: 4337
official: https://eips.ethereum.org/EIPS/eip-7582
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7582.md
canonical: https://eips.huatuo.xyz/ja/eip-7582/
lang: ja
tldr: ERC-4337 スマートアカウントにプラグインを追加する、ドラフトの最小限の方法。UserOperation の nonce の上位 192 ビットのキーが validator コントラクトを指名し、アカウントはその操作の検証をそのコントラクトに委ねる。
tags: [account-abstraction, erc4337, smart-accounts, plugins, modular]
---

# ERC-7582: Modular Accounts with Delegated Validation

> Extends ERC-4337 interface with nonce-based plugins

**TL;DR:** ERC-4337 スマートアカウントにプラグインを追加する、ドラフトの最小限の方法。UserOperation の nonce の上位 192 ビットのキーが validator コントラクトを指名し、アカウントはその操作の検証をそのコントラクトに委ねる。

## 何を解決するのか

スマートコントラクトアカウントは、原理的にはソーシャルリカバリー、支出制限、セッションキー、定期支払いなどを実現できます。しかし実際には、各機能に独自の検証ロジックが必要で、追加するにはたいていアカウントのアップグレードや移行が必要です。より大規模なモジュラーアカウント標準もありますが、多くの新しい関数や規約を追加します。

ERC-7582（「Modular Accounts with Delegated Validation」、MADV）は逆のアプローチを取ります。新しい関数をまったく追加しません。すでに [ERC-4337](/eip-4337/) の `IAccount` インターフェースを実装しているアカウントが、ERC-4337 にすでにあるフィールドだけを使って、検証をプラグインコントラクトに委譲できることを示します。

## 仕組み

ERC-4337 の EntryPoint は nonce を 192 ビットの**キー**と 64 ビットの**シーケンス**として管理します。キーごとに独自のカウンターを持つため、キーが異なる操作は互いをブロックしません。MADV はそのキーをポインターとして再利用します。

1. ユーザーは、`nonce` のキーがゼロでない（つまり nonce が `type(uint64).max` より大きい）UserOperation を作ります。
2. `validateUserOp` の中で、アカウントはキーから validator の識別子を取り出します。それは validator のアドレスそのものでも、ストレージ内のアドレスへのポインターでもかまいません。どうするかはアカウントが決めます。
3. アカウントは UserOperation（できれば全体）をその validator に転送します。
4. validator は標準的な ERC-4337 の `validationData` を返し、アカウントはそれを変更せずに EntryPoint に返します。
5. キーが 0 の nonce は、アカウント本来の署名チェックにフォールバックします。

なぜ `signature` フィールドではなく nonce なのか。追加の calldata がかからず、`getNonce(sender, key)` がすでに各プラグインに独自のリプレイカウンターを与えており、`UserOperationEvent` が nonce をログに残すため、既存のイベントからプラグインの利用を追跡できるからです。

## サンプルコード

簡略化した MADV アカウント（リファレンス実装は、先にオーナーの署名もチェックします）:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import {IAccount} from "account-abstraction/interfaces/IAccount.sol";
import {PackedUserOperation} from "account-abstraction/interfaces/PackedUserOperation.sol";

contract MADVAccount is IAccount {
    address public immutable entryPoint;

    constructor(address ep) { entryPoint = ep; }

    function validateUserOp(
        PackedUserOperation calldata userOp,
        bytes32 userOpHash,
        uint256 missingAccountFunds
    ) external returns (uint256 validationData) {
        require(msg.sender == entryPoint, "not EntryPoint");

        if (userOp.nonce > type(uint64).max) {
            uint192 key = uint192(userOp.nonce >> 64);
            address validator = address(uint160(key));   // key encodes the plugin
            // (a real account should check `validator` is installed/allowed)
            validationData = IAccount(validator).validateUserOp(userOp, userOpHash, missingAccountFunds);
        } else {
            validationData = _validateOwnerSignature(userOp, userOpHash);
        }

        if (missingAccountFunds > 0) {
            (bool ok, ) = payable(msg.sender).call{value: missingAccountFunds}("");
            (ok);
        }
    }

    function _validateOwnerSignature(PackedUserOperation calldata, bytes32)
        internal view virtual returns (uint256) { /* ECDSA check */ return 0; }
}
```

オフチェーンでは、プラグインの次の nonce は `entryPoint.getNonce(account, BigInt(validatorAddress))` です。

## 知っておくべきこと

- ステータス: **Draft**。
- 仕様は、識別子から validator へのマッピングも許可リストも、アカウント開発者に委ねています。キーの中のどんなアドレスでも盲目的に信頼するアカウントは、誰でも自分の操作の validator を選べてしまうため、使用できる validator を制限してください。
- validator は ERC-4337 の検証フェーズ内で動作し、そのルール（ストレージアクセスと opcode の制限）に従わなければなりません。従わないと Bundler が操作を破棄します。
- インストール、フック、実行モジュールを備えたより豊富なモジュールシステムについては、[ERC-7579](/eip-7579/) と [ERC-6900](/eip-6900/) を参照してください。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-7582
