# [技術] アカウントの設定

> ERC7579に準拠するコントラクトアカウントは、以下のアカウント設定用インターフェースを実装する必要があります。これは、アカウントの識別や対応モード、モジュールの互換性を外部から確認できるようにするインターフェースです。

- URL: https://cardene.dev/books/erc7579/e1e798
- 本: ERC7579 (https://cardene.dev/books/erc7579.md)
- 章: 8 / 16
- 前の章: https://cardene.dev/books/erc7579/a59d9b.md
- 次の章: https://cardene.dev/books/erc7579/9144f6.md
- 公開日: 2025-06-20
- 更新日: 2025-06-20
- トピック: Blockchain
- タグ: ブロックチェーン, solidity, ethereum, smartcontract

## 概要

**ERC7579**に準拠するコントラクトアカウントは、以下のアカウント設定用インターフェースを実装する必要があります。
これは、アカウントの識別や対応モード、モジュールの互換性を外部から確認できるようにするインターフェースです。

## IERC7579AccountConfig

```solidity:IERC7579AccountConfig.sol
interface IERC7579AccountConfig {
    /**
     * @dev Returns the account id of the smart account
     * @return accountImplementationId the account id of the smart account
     *
     * MUST return a non-empty string
     * The accountId SHOULD be structured like so:
     *        "vendorname.accountname.semver"
     * The id SHOULD be unique across all smart accounts
     */
    function accountId() external view returns (string memory accountImplementationId);

    /**
     * @dev Function to check if the account supports a certain execution mode (see above)
     * @param encodedMode the encoded mode
     *
     * MUST return true if the account supports the mode and false otherwise
     */
    function supportsExecutionMode(bytes32 encodedMode) external view returns (bool);

    /**
     * @dev Function to check if the account supports a certain module typeId
     * @param moduleTypeId the module type ID according to the ERC-7579 spec
     *
     * MUST return true if the account supports the module type and false otherwise
     */
    function supportsModule(uint256 moduleTypeId) external view returns (bool);
}
```

### `accountId`

```solidity
function accountId() external view returns (string memory accountImplementationId);
```

コントラクトアカウントの一意な識別子（account ID）を返す関数。
返される文字列は空であってはならず、フォーマットは `"ベンダー名.アカウント名.バージョン"` のように構成されることが推奨されます（例：`mywallet.safemodule.v1.0.0`）。
この識別子は、他のコントラクトアカウントと一意であることが望まれます。

このIDは、外部からそのコントラクトアカウントがどのような実装で構成されているかを識別する際に使われます。

### `supportsExecutionMode`

```solidity
function supportsExecutionMode(bytes32 encodedMode) external view returns (bool);
```

渡された実行モード（encodedMode）がこのコントラクトアカウントでサポートされているかを確認する関数。
実行モードの詳細は呼び出しの種類やエラーハンドリング方式をエンコードしたものです。
コントラクトアカウントがそのモードをサポートしていれば `true`、そうでなければ `false` を返します。
これにより、モジュールや外部アプリケーションが事前に互換性を確認できます。

### `supportsModule`

```solidity
function supportsModule(uint256 moduleTypeId) external view returns (bool);
```

指定されたモジュールタイプ（`moduleTypeId`）がコントラクトアカウントで使用可能かを返す関数。
`moduleTypeId` は**ERC7579**で定義されたモジュール種別（Validator, Executor, Fallback など）を表すIDです。
コントラクトアカウントがそのモジュールタイプを受け入れる設計になっていれば `true` を返します。
この関数により、モジュールの導入可否を事前に判別することができ、モジュールとアカウント間の安全な組み合わせを確保できます。
