---
eip: 7679
label: ERC-7679
title: UserOperation Builder
status: Draft
type: Standards Track
category: ERC
created: 2024-04-05
requires: 4337
official: https://eips.ethereum.org/EIPS/eip-7679
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7679.md
canonical: https://eips.huatuo.xyz/ja/eip-7679/
lang: ja
tldr: 各 ERC-4337 スマートアカウントが、自身の nonce・calldata・署名のエンコード方法を持つオンチェーンの「builder」コントラクトを公開できるようにし、アカウント固有の SDK なしでどのウォレットや dapp でも UserOperation を組み立てられるようにする。
tags: [account-abstraction, smart-accounts, userop, interoperability]
---

# ERC-7679: UserOperation Builder

> Construct UserOperations without being coupled with account-specific logic.

**TL;DR:** 各 ERC-4337 スマートアカウントが、自身の nonce・calldata・署名のエンコード方法を持つオンチェーンの「builder」コントラクトを公開できるようにし、アカウント固有の SDK なしでどのウォレットや dapp でも UserOperation を組み立てられるようにする。

## 何を解決するのか

[ERC-4337](/eip-4337/) ではスマートアカウントが UserOperation（UserOp）を送れますが、`nonce`、`callData`、`signature` の 3 つのフィールドはアカウント実装ごとに任意となっています。あるアカウントは `executeFoo` を公開し、別のアカウントは `executeBar` を公開します。nonce にバリデーターのアドレスを詰め込むものもあれば、署名に追加データを被せるものもあります。

その結果、UserOp を送りたい dapp やウォレットは、相手がどのアカウント実装なのかを知り、そのベンダーの SDK を組み込む必要があります。これはベンダーロックインであり、アカウントアブストラクションのエコシステムを分断します。

ERC-7679 は、このアカウント固有のエンコードロジックを、共通の 1 つのインターフェースの背後でオンチェーンに移します。

## 仕組み

各スマートアカウント実装は、`IUserOperationBuilder` を実装する **UserOp builder** コントラクトを提供します。

| 関数 | 戻り値 |
| --- | --- |
| `entryPoint()` | アカウントが対応する ERC-4337 EntryPoint |
| `getNonce(account, context)` | 使用する nonce |
| `getCallData(account, executions, context)` | `(target, value, callData)` の実行バッチに対する `callData` |
| `formatSignature(account, userOp, context)` | 生の署名を、アカウントが期待する形式にラップしたもの |

`context` は、アカウントの所有者（またはそのウォレット）が組み立てる側に渡す不透明なバイト列です。委任の認可など、builder が必要とする情報を運びます。

組み立てる側の推奨フローは次のとおりです。

1. アカウントの所有者から builder のアドレスと `context` を取得する。
2. `getNonce` と `getCallData` を `eth_call` で呼ぶ（できればバッチで）。
3. 低い gas 値で UserOp を埋めて署名し、`formatSignature` を呼んで、gas 見積もり用の正しい形の**ダミー署名**を得る。
4. gas を見積もり、実際の gas 値を入れて再度署名し、もう一度 `formatSignature` を呼んで、最終的に有効な UserOp を得る。

その他の UserOp フィールド（gas、paymaster など）は対象外です。まだデプロイされていないアカウントについては、[ERC-6492](/eip-6492/) に着想を得た `CounterfactualCall` コントラクトが仕様で説明されています。これは `eth_call` の中でファクトリー経由でアカウントをデプロイし、その後 builder に問い合わせます。

## サンプルコード

ethers v6 で `callData` と `nonce` を組み立てる例:

```ts
import { Contract, JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const builder = new Contract(builderAddress, [
  "function entryPoint() view returns (address)",
  "function getNonce(address smartAccount, bytes context) view returns (uint256)",
  "function getCallData(address smartAccount, (address target, uint256 value, bytes callData)[] executions, bytes context) view returns (bytes)",
], provider);

const executions = [
  { target: tokenAddress, value: 0n, callData: transferData },
];

const [nonce, callData] = await Promise.all([
  builder.getNonce(account, context),
  builder.getCallData(account, executions, context),
]);
// Fill the rest of the UserOp, then call formatSignature(...) for the dummy and final signatures.
```

## 知っておくべきこと

- **ステータス: Draft。** インターフェースはまだ変更される可能性があります。
- このインターフェースは EntryPoint v0.7（`PackedUserOperation`）を対象としています。EntryPoint v0.6 のアカウントには、v0.6 の構造体を使うバリアントが必要です。
- ダミー署名は重要です。実際の署名とほぼ同じ量の gas を消費する必要があるため、固定値ではなくアカウント固有の builder から取得します。
- ダミー署名は公開されます。仕様では、傍受されても使い物にならないよう、非常に低い gas 値でダミー UserOp に署名することを推奨しています。
- [ERC-7579](/eip-7579/) のようなモジュラーアカウント標準を補完します。ERC-7579 は UserOp を外部からどう組み立てるかではなく、アカウント内部の実行とモジュールを標準化するものです。


---

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