{"eip":4337,"title":"Account Abstraction Using Alt Mempool","description":"Account abstraction without consensus-layer protocol changes, instead relying on higher-layer infrastructure.","authors":["Vitalik Buterin (@vbuterin)","Yoav Weiss (@yoavw)","Dror Tirosh (@drortirosh)","Shahaf Nacson (@shahafn)","Alex Forshtat (@forshtat)","Kristof Gazso (@kristofgazso)","Tjaden Hess (@tjade273)"],"status":"Final","type":"Standards Track","category":"ERC","created":"2021-09-29","requires":[712,7702],"discussionsTo":"https://ethereum-magicians.org/t/erc-4337-account-abstraction-via-entry-point-contract-specification/7160","repo":"ERCs","label":"ERC-4337","officialUrl":"https://eips.ethereum.org/EIPS/eip-4337","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-4337.md","url":"https://eips.huatuo.xyz/eip-4337/","tldr":{"en":"Account abstraction without changing the protocol - smart-contract wallets send UserOperations through a separate mempool, bundlers put them on-chain via the EntryPoint contract, and paymasters can sponsor gas.","ja":"プロトコルを変えずに実現するアカウント抽象化。スマートコントラクトウォレットが UserOperation を専用 mempool に送り、Bundler が EntryPoint コントラクト経由でオンチェーンに載せ、Paymaster がガス代を肩代わりできる。","ko":"프로토콜을 바꾸지 않는 계정 추상화. 스마트 컨트랙트 지갑이 UserOperation을 별도 멤풀로 보내고, Bundler가 EntryPoint 컨트랙트를 통해 온체인에 올리며, Paymaster가 가스비를 대신 낼 수 있다.","zh":"不改协议的账户抽象：智能合约钱包通过独立内存池发送 UserOperation，Bundler 经由 EntryPoint 合约将其上链，Paymaster 可以代付 gas。"},"tags":["account-abstraction","smart-wallet","bundler","paymaster","gasless"],"explainers":{"en":{"lang":"en","tldr":"Account abstraction without changing the protocol - smart-contract wallets send UserOperations through a separate mempool, bundlers put them on-chain via the EntryPoint contract, and paymasters can sponsor gas.","tags":["account-abstraction","smart-wallet","bundler","paymaster","gasless"],"related":[7702,712,1271,2771,7579],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-4337/","markdown":"## What problem does it solve?\n\nOrdinary Ethereum accounts (EOAs) are rigid: one secp256k1 private key, no recovery if you lose it, no spending limits, one call per transaction, and you must hold ETH to pay gas. Smart-contract wallets can do all of that, but a contract cannot start a transaction on its own; someone with an EOA has to trigger it and pay.\n\nEarlier proposals wanted to fix this inside the protocol, which requires a hard fork and consensus. ERC-4337 achieves \"account abstraction\" purely with contracts and off-chain infrastructure, so it works on any EVM chain today.\n\n## How it works\n\n1. **UserOperation**. Instead of a transaction, the user signs a `UserOperation` object: `sender` (the smart account), `nonce`, `callData`, gas limits, fee fields, an optional `paymaster` and a `signature` of any format.\n2. **Alt mempool \u0026 Bundlers**. UserOperations go to a dedicated mempool. *Bundlers* pick them up, simulate them, bundle several into one normal transaction and call `EntryPoint.handleOps(...)`, paying the gas.\n3. **EntryPoint**. A single audited singleton contract. For each op it calls `validateUserOp` on the sender account (which checks the signature and pays the EntryPoint for gas), then executes `callData`, then reimburses the bundler.\n4. **Paymaster** (optional). A contract that agrees to pay gas for the op: sponsoring onboarding, accepting ERC-20 tokens instead of ETH, etc.\n5. **Factory** (optional). If the account does not exist yet, `initCode` / `factory` deploys it in the same operation, so a user's first action can be from a counterfactual address.\n\nThe result: wallets with passkeys, multisig, social recovery, session keys, batched calls and gasless onboarding, with no protocol change.\n\n## Sample code\n\nThe interface every ERC-4337 account implements (v0.7):\n\n```solidity\nstruct PackedUserOperation {\n    address sender;\n    uint256 nonce;\n    bytes   initCode;            // factory address ++ factoryData, or empty\n    bytes   callData;\n    bytes32 accountGasLimits;    // verificationGasLimit (16 bytes) ++ callGasLimit (16 bytes)\n    uint256 preVerificationGas;\n    bytes32 gasFees;             // maxPriorityFeePerGas (16 bytes) ++ maxFeePerGas (16 bytes)\n    bytes   paymasterAndData;    // paymaster ++ gas limits ++ paymasterData, or empty\n    bytes   signature;\n}\n\ninterface IAccount {\n    /// Return 0 if the signature is valid, 1 (SIG_VALIDATION_FAILED) otherwise.\n    /// Must transfer `missingAccountFunds` to the EntryPoint when non-zero.\n    function validateUserOp(\n        PackedUserOperation calldata userOp,\n        bytes32 userOpHash,\n        uint256 missingAccountFunds\n    ) external returns (uint256 validationData);\n}\n```\n\nA deliberately minimal account owned by one EOA key:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport {MessageHashUtils} from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\n\ncontract SimpleAccount is IAccount {\n    address public immutable entryPoint;\n    address public owner;\n\n    constructor(address _entryPoint, address _owner) { entryPoint = _entryPoint; owner = _owner; }\n\n    function validateUserOp(PackedUserOperation calldata op, bytes32 opHash, uint256 missing)\n        external returns (uint256)\n    {\n        require(msg.sender == entryPoint, \"only EntryPoint\");\n        address signer = ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(opHash), op.signature);\n        if (missing != 0) payable(entryPoint).call{value: missing}(\"\");\n        return signer == owner ? 0 : 1;\n    }\n\n    function execute(address to, uint256 value, bytes calldata data) external {\n        require(msg.sender == entryPoint, \"only EntryPoint\");\n        (bool ok, bytes memory ret) = to.call{value: value}(data);\n        require(ok, string(ret));\n    }\n}\n```\n\nSending an operation from a client (viem's account-abstraction module):\n\n```ts\nimport { createBundlerClient } from \"viem/account-abstraction\";\nimport { http } from \"viem\";\nimport { sepolia } from \"viem/chains\";\n\nconst bundler = createBundlerClient({\n  account,                       // a SmartAccount object (e.g. toCoinbaseSmartAccount / toSimpleSmartAccount)\n  chain: sepolia,\n  transport: http(\"https://your-bundler.example/rpc\"),\n});\n\nconst hash = await bundler.sendUserOperation({\n  calls: [{ to: \"0x...\", value: 0n, data: \"0x...\" }],\n  // paymaster: true,            // let a paymaster sponsor the gas\n});\nconst receipt = await bundler.waitForUserOperationReceipt({ hash });\n```\n\nUnder the hood this calls the bundler's JSON-RPC method `eth_sendUserOperation(userOp, entryPoint)`.\n\n## Things to know\n\n- The EntryPoint is a shared contract with a fixed address per version (v0.6 `0x5FF1…2789`, v0.7 `0x0000000071727De22E5E9d8BAf0edAc6f37da032`). Accounts and bundlers must agree on the version.\n- Validation code is restricted: no banned opcodes like `TIMESTAMP` in ways that let simulation diverge from execution, and limited storage access (see [ERC-7562](/eip-7562/)). This is what keeps the mempool spam-resistant.\n- You need a bundler service (Alchemy, Pimlico, Biconomy, Candide, self-hosted…) and typically a paymaster service; they are infrastructure, not part of the chain.\n- [EIP-7702](/eip-7702/) lets an existing EOA behave like a smart account; ERC-4337 supports 7702 accounts natively, so the two are complementary rather than competing.\n"},"ja":{"lang":"ja","tldr":"プロトコルを変えずに実現するアカウント抽象化。スマートコントラクトウォレットが UserOperation を専用 mempool に送り、Bundler が EntryPoint コントラクト経由でオンチェーンに載せ、Paymaster がガス代を肩代わりできる。","tags":["account-abstraction","smart-wallet","bundler","paymaster","gasless"],"related":[7702,712,1271,2771,7579],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-4337/","markdown":"## 何を解決するのか\n\n通常の Ethereum アカウント（EOA）は融通が利きません。secp256k1 の秘密鍵 1 本だけ、紛失しても復旧できず、支出制限もなく、1 トランザクションにつき 1 呼び出し、しかもガス代のために ETH を保有する必要があります。スマートコントラクトウォレットならすべて実現できますが、コントラクトは自分からトランザクションを開始できません。EOA を持つ誰かが起動し、ガス代を払う必要があります。\n\n以前の提案はこれをプロトコル内で解決しようとしましたが、ハードフォークと合意形成が必要です。ERC-4337 はコントラクトとオフチェーンのインフラだけで「アカウント抽象化」を実現するため、どの EVM チェーンでも今すぐ動きます。\n\n## 仕組み\n\n1. **UserOperation**。トランザクションの代わりに、ユーザーは `UserOperation` オブジェクトに署名します。`sender`（スマートアカウント）、`nonce`、`callData`、ガス上限、手数料フィールド、任意の `paymaster`、そして任意形式の `signature` を含みます。\n2. **代替 mempool と Bundler**。UserOperation は専用の mempool に送られます。*Bundler* がそれを拾い、シミュレーションし、複数をまとめて 1 本の通常トランザクションとして `EntryPoint.handleOps(...)` を呼び、ガス代を支払います。\n3. **EntryPoint**。監査済みの単一シングルトンコントラクト。各 op について送信元アカウントの `validateUserOp` を呼び（署名を検証し、ガス代を EntryPoint に支払う）、`callData` を実行し、Bundler に精算します。\n4. **Paymaster**（任意）。op のガス代を肩代わりすることに同意するコントラクト。オンボーディングのスポンサー、ETH の代わりに ERC-20 トークンでの支払いなどに使われます。\n5. **Factory**（任意）。アカウントが未デプロイなら、`initCode` / `factory` が同じ操作内でデプロイします。ユーザーの最初のアクションを counterfactual なアドレスから実行できます。\n\n結果として、パスキー、マルチシグ、ソーシャルリカバリー、セッションキー、バッチ呼び出し、ガスレスオンボーディングを備えたウォレットが、プロトコル変更なしで実現します。\n\n## サンプルコード\n\nすべての ERC-4337 アカウントが実装するインターフェース（v0.7）:\n\n```solidity\nstruct PackedUserOperation {\n    address sender;\n    uint256 nonce;\n    bytes   initCode;            // factory アドレス ++ factoryData、または空\n    bytes   callData;\n    bytes32 accountGasLimits;    // verificationGasLimit (16 bytes) ++ callGasLimit (16 bytes)\n    uint256 preVerificationGas;\n    bytes32 gasFees;             // maxPriorityFeePerGas (16 bytes) ++ maxFeePerGas (16 bytes)\n    bytes   paymasterAndData;    // paymaster ++ ガス上限 ++ paymasterData、または空\n    bytes   signature;\n}\n\ninterface IAccount {\n    /// 署名が有効なら 0、無効なら 1 (SIG_VALIDATION_FAILED) を返す。\n    /// missingAccountFunds が 0 でなければ EntryPoint へ送金すること。\n    function validateUserOp(\n        PackedUserOperation calldata userOp,\n        bytes32 userOpHash,\n        uint256 missingAccountFunds\n    ) external returns (uint256 validationData);\n}\n```\n\n1 本の EOA 鍵が所有する、あえて最小限にしたアカウント:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport {MessageHashUtils} from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\n\ncontract SimpleAccount is IAccount {\n    address public immutable entryPoint;\n    address public owner;\n\n    constructor(address _entryPoint, address _owner) { entryPoint = _entryPoint; owner = _owner; }\n\n    function validateUserOp(PackedUserOperation calldata op, bytes32 opHash, uint256 missing)\n        external returns (uint256)\n    {\n        require(msg.sender == entryPoint, \"only EntryPoint\");\n        address signer = ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(opHash), op.signature);\n        if (missing != 0) payable(entryPoint).call{value: missing}(\"\");\n        return signer == owner ? 0 : 1;\n    }\n\n    function execute(address to, uint256 value, bytes calldata data) external {\n        require(msg.sender == entryPoint, \"only EntryPoint\");\n        (bool ok, bytes memory ret) = to.call{value: value}(data);\n        require(ok, string(ret));\n    }\n}\n```\n\nクライアントから操作を送る（viem の account-abstraction モジュール）:\n\n```ts\nimport { createBundlerClient } from \"viem/account-abstraction\";\nimport { http } from \"viem\";\nimport { sepolia } from \"viem/chains\";\n\nconst bundler = createBundlerClient({\n  account,                       // SmartAccount オブジェクト（toCoinbaseSmartAccount / toSimpleSmartAccount など）\n  chain: sepolia,\n  transport: http(\"https://your-bundler.example/rpc\"),\n});\n\nconst hash = await bundler.sendUserOperation({\n  calls: [{ to: \"0x...\", value: 0n, data: \"0x...\" }],\n  // paymaster: true,            // Paymaster にガス代を肩代わりさせる\n});\nconst receipt = await bundler.waitForUserOperationReceipt({ hash });\n```\n\n内部では Bundler の JSON-RPC メソッド `eth_sendUserOperation(userOp, entryPoint)` が呼ばれます。\n\n## 知っておくべきこと\n\n- EntryPoint はバージョンごとに固定アドレスを持つ共有コントラクトです（v0.6 `0x5FF1…2789`、v0.7 `0x0000000071727De22E5E9d8BAf0edAc6f37da032`）。アカウントと Bundler はバージョンを揃える必要があります。\n- 検証コードには制約があります。シミュレーションと実行の結果がずれるような `TIMESTAMP` 等の使い方は禁止され、ストレージアクセスも制限されます（[ERC-7562](/eip-7562/) 参照）。これが mempool をスパムから守っています。\n- Bundler サービス（Alchemy、Pimlico、Biconomy、Candide、自前ホストなど）と、通常は Paymaster サービスが必要です。これらはインフラであってチェーンの一部ではありません。\n- [EIP-7702](/eip-7702/) は既存の EOA をスマートアカウントのように振る舞わせます。ERC-4337 は 7702 アカウントをネイティブにサポートしており、両者は競合ではなく補完関係にあります。\n"},"ko":{"lang":"ko","tldr":"프로토콜을 바꾸지 않는 계정 추상화. 스마트 컨트랙트 지갑이 UserOperation을 별도 멤풀로 보내고, Bundler가 EntryPoint 컨트랙트를 통해 온체인에 올리며, Paymaster가 가스비를 대신 낼 수 있다.","tags":["account-abstraction","smart-wallet","bundler","paymaster","gasless"],"related":[7702,712,1271,2771,7579],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-4337/","markdown":"## 어떤 문제를 해결하나요?\n\n일반 이더리움 계정(EOA)은 경직되어 있습니다. secp256k1 개인키 하나뿐이고, 잃어버리면 복구할 수 없고, 지출 한도도 없고, 트랜잭션당 호출 하나뿐이며, 가스비를 내려면 ETH를 보유해야 합니다. 스마트 컨트랙트 지갑은 이 모든 것을 할 수 있지만, 컨트랙트는 스스로 트랜잭션을 시작할 수 없습니다. EOA를 가진 누군가가 트리거하고 비용을 내야 합니다.\n\n이전 제안들은 이를 프로토콜 안에서 해결하려 했는데, 그러려면 하드포크와 합의가 필요합니다. ERC-4337은 컨트랙트와 오프체인 인프라만으로 \"계정 추상화\"를 달성하므로 오늘날 어떤 EVM 체인에서도 동작합니다.\n\n## 어떻게 동작하나요?\n\n1. **UserOperation**. 사용자는 트랜잭션 대신 `UserOperation` 객체에 서명합니다. `sender`(스마트 계정), `nonce`, `callData`, 가스 한도, 수수료 필드, 선택적 `paymaster`, 그리고 임의 형식의 `signature`를 담습니다.\n2. **대체 멤풀과 Bundler**. UserOperation은 전용 멤풀로 갑니다. *Bundler*가 이를 가져와 시뮬레이션하고, 여러 개를 묶어 하나의 일반 트랜잭션으로 `EntryPoint.handleOps(...)`를 호출하며 가스비를 냅니다.\n3. **EntryPoint**. 감사를 거친 단일 싱글턴 컨트랙트. 각 op마다 발신 계정의 `validateUserOp`를 호출하고(서명을 검증하고 EntryPoint에 가스비를 지불), `callData`를 실행한 뒤 Bundler에 정산합니다.\n4. **Paymaster**(선택). op의 가스비를 대신 내기로 동의하는 컨트랙트입니다. 온보딩 후원, ETH 대신 ERC-20 토큰 수취 등에 쓰입니다.\n5. **Factory**(선택). 계정이 아직 없으면 `initCode` / `factory`가 같은 작업 안에서 배포합니다. 사용자의 첫 동작을 반사실적(counterfactual) 주소에서 시작할 수 있습니다.\n\n결과적으로 패스키, 멀티시그, 소셜 리커버리, 세션 키, 배치 호출, 가스리스 온보딩을 갖춘 지갑이 프로토콜 변경 없이 가능해집니다.\n\n## 샘플 코드\n\n모든 ERC-4337 계정이 구현하는 인터페이스(v0.7):\n\n```solidity\nstruct PackedUserOperation {\n    address sender;\n    uint256 nonce;\n    bytes   initCode;            // factory 주소 ++ factoryData, 또는 비어 있음\n    bytes   callData;\n    bytes32 accountGasLimits;    // verificationGasLimit (16 bytes) ++ callGasLimit (16 bytes)\n    uint256 preVerificationGas;\n    bytes32 gasFees;             // maxPriorityFeePerGas (16 bytes) ++ maxFeePerGas (16 bytes)\n    bytes   paymasterAndData;    // paymaster ++ 가스 한도 ++ paymasterData, 또는 비어 있음\n    bytes   signature;\n}\n\ninterface IAccount {\n    /// 서명이 유효하면 0, 아니면 1 (SIG_VALIDATION_FAILED)을 반환.\n    /// missingAccountFunds가 0이 아니면 그 금액을 EntryPoint로 보내야 함.\n    function validateUserOp(\n        PackedUserOperation calldata userOp,\n        bytes32 userOpHash,\n        uint256 missingAccountFunds\n    ) external returns (uint256 validationData);\n}\n```\n\nEOA 키 하나가 소유하는, 의도적으로 최소화한 계정:\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport {MessageHashUtils} from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\n\ncontract SimpleAccount is IAccount {\n    address public immutable entryPoint;\n    address public owner;\n\n    constructor(address _entryPoint, address _owner) { entryPoint = _entryPoint; owner = _owner; }\n\n    function validateUserOp(PackedUserOperation calldata op, bytes32 opHash, uint256 missing)\n        external returns (uint256)\n    {\n        require(msg.sender == entryPoint, \"only EntryPoint\");\n        address signer = ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(opHash), op.signature);\n        if (missing != 0) payable(entryPoint).call{value: missing}(\"\");\n        return signer == owner ? 0 : 1;\n    }\n\n    function execute(address to, uint256 value, bytes calldata data) external {\n        require(msg.sender == entryPoint, \"only EntryPoint\");\n        (bool ok, bytes memory ret) = to.call{value: value}(data);\n        require(ok, string(ret));\n    }\n}\n```\n\n클라이언트에서 작업 보내기(viem의 account-abstraction 모듈):\n\n```ts\nimport { createBundlerClient } from \"viem/account-abstraction\";\nimport { http } from \"viem\";\nimport { sepolia } from \"viem/chains\";\n\nconst bundler = createBundlerClient({\n  account,                       // SmartAccount 객체 (toCoinbaseSmartAccount / toSimpleSmartAccount 등)\n  chain: sepolia,\n  transport: http(\"https://your-bundler.example/rpc\"),\n});\n\nconst hash = await bundler.sendUserOperation({\n  calls: [{ to: \"0x...\", value: 0n, data: \"0x...\" }],\n  // paymaster: true,            // Paymaster가 가스비를 대신 내게 함\n});\nconst receipt = await bundler.waitForUserOperationReceipt({ hash });\n```\n\n내부적으로는 Bundler의 JSON-RPC 메서드 `eth_sendUserOperation(userOp, entryPoint)`가 호출됩니다.\n\n## 알아둘 점\n\n- EntryPoint는 버전마다 고정 주소를 가진 공유 컨트랙트입니다(v0.6 `0x5FF1…2789`, v0.7 `0x0000000071727De22E5E9d8BAf0edAc6f37da032`). 계정과 Bundler는 버전을 맞춰야 합니다.\n- 검증 코드에는 제약이 있습니다. 시뮬레이션과 실제 실행이 달라지게 하는 방식의 `TIMESTAMP` 등 옵코드 사용은 금지되고, 스토리지 접근도 제한됩니다([ERC-7562](/eip-7562/) 참고). 이것이 멤풀을 스팸으로부터 지켜줍니다.\n- Bundler 서비스(Alchemy, Pimlico, Biconomy, Candide, 자체 호스팅 등)와 보통 Paymaster 서비스가 필요합니다. 이들은 인프라이지 체인의 일부가 아닙니다.\n- [EIP-7702](/eip-7702/)는 기존 EOA가 스마트 계정처럼 동작하게 합니다. ERC-4337은 7702 계정을 기본 지원하므로 둘은 경쟁이 아니라 보완 관계입니다.\n"},"zh":{"lang":"zh","tldr":"不改协议的账户抽象：智能合约钱包通过独立内存池发送 UserOperation，Bundler 经由 EntryPoint 合约将其上链，Paymaster 可以代付 gas。","tags":["account-abstraction","smart-wallet","bundler","paymaster","gasless"],"related":[7702,712,1271,2771,7579],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-4337/","markdown":"## 它解决什么问题？\n\n普通以太坊账户（EOA）非常僵硬：只有一把 secp256k1 私钥，丢了无法找回，没有消费限额，一笔交易只能做一次调用，而且必须持有 ETH 支付 gas。智能合约钱包可以做到这一切，但合约无法自己发起交易，必须有人用 EOA 触发并付费。\n\n早期提案希望在协议内部解决，这需要硬分叉和共识。ERC-4337 仅用合约和链下基础设施实现了\"账户抽象\"，因此今天就能在任何 EVM 链上运行。\n\n## 它如何运作\n\n1. **UserOperation**。用户不再签交易，而是签一个 `UserOperation` 对象：`sender`（智能账户）、`nonce`、`callData`、gas 上限、费用字段、可选的 `paymaster` 和任意格式的 `signature`。\n2. **独立内存池与 Bundler**。UserOperation 进入专用内存池。*Bundler* 取出它们、模拟执行、把多个打包进一笔普通交易并调用 `EntryPoint.handleOps(...)`，由 Bundler 支付 gas。\n3. **EntryPoint**。一个经过审计的单例合约。它对每个操作调用发送账户的 `validateUserOp`（验证签名并向 EntryPoint 支付 gas），然后执行 `callData`，最后补偿 Bundler。\n4. **Paymaster**（可选）。同意为操作支付 gas 的合约：赞助新用户、接受 ERC-20 代币代替 ETH 等。\n5. **Factory**（可选）。如果账户尚不存在，`initCode` / `factory` 会在同一操作中部署它，用户的第一个动作就可以从一个反事实地址发出。\n\n结果是：支持 passkey、多签、社交恢复、会话密钥、批量调用和无 gas 入门的钱包，而无需任何协议改动。\n\n## 示例代码\n\n每个 ERC-4337 账户实现的接口（v0.7）：\n\n```solidity\nstruct PackedUserOperation {\n    address sender;\n    uint256 nonce;\n    bytes   initCode;            // factory 地址 ++ factoryData，或为空\n    bytes   callData;\n    bytes32 accountGasLimits;    // verificationGasLimit (16 bytes) ++ callGasLimit (16 bytes)\n    uint256 preVerificationGas;\n    bytes32 gasFees;             // maxPriorityFeePerGas (16 bytes) ++ maxFeePerGas (16 bytes)\n    bytes   paymasterAndData;    // paymaster ++ gas 上限 ++ paymasterData，或为空\n    bytes   signature;\n}\n\ninterface IAccount {\n    /// 签名有效返回 0，否则返回 1 (SIG_VALIDATION_FAILED)。\n    /// missingAccountFunds 非零时必须把该金额转给 EntryPoint。\n    function validateUserOp(\n        PackedUserOperation calldata userOp,\n        bytes32 userOpHash,\n        uint256 missingAccountFunds\n    ) external returns (uint256 validationData);\n}\n```\n\n一个刻意精简、由单个 EOA 密钥控制的账户：\n\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.20;\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport {MessageHashUtils} from \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\n\ncontract SimpleAccount is IAccount {\n    address public immutable entryPoint;\n    address public owner;\n\n    constructor(address _entryPoint, address _owner) { entryPoint = _entryPoint; owner = _owner; }\n\n    function validateUserOp(PackedUserOperation calldata op, bytes32 opHash, uint256 missing)\n        external returns (uint256)\n    {\n        require(msg.sender == entryPoint, \"only EntryPoint\");\n        address signer = ECDSA.recover(MessageHashUtils.toEthSignedMessageHash(opHash), op.signature);\n        if (missing != 0) payable(entryPoint).call{value: missing}(\"\");\n        return signer == owner ? 0 : 1;\n    }\n\n    function execute(address to, uint256 value, bytes calldata data) external {\n        require(msg.sender == entryPoint, \"only EntryPoint\");\n        (bool ok, bytes memory ret) = to.call{value: value}(data);\n        require(ok, string(ret));\n    }\n}\n```\n\n从客户端发送操作（viem 的 account-abstraction 模块）：\n\n```ts\nimport { createBundlerClient } from \"viem/account-abstraction\";\nimport { http } from \"viem\";\nimport { sepolia } from \"viem/chains\";\n\nconst bundler = createBundlerClient({\n  account,                       // SmartAccount 对象（如 toCoinbaseSmartAccount / toSimpleSmartAccount）\n  chain: sepolia,\n  transport: http(\"https://your-bundler.example/rpc\"),\n});\n\nconst hash = await bundler.sendUserOperation({\n  calls: [{ to: \"0x...\", value: 0n, data: \"0x...\" }],\n  // paymaster: true,            // 让 Paymaster 代付 gas\n});\nconst receipt = await bundler.waitForUserOperationReceipt({ hash });\n```\n\n底层调用的是 Bundler 的 JSON-RPC 方法 `eth_sendUserOperation(userOp, entryPoint)`。\n\n## 需要注意\n\n- EntryPoint 是共享合约，每个版本有固定地址（v0.6 `0x5FF1…2789`，v0.7 `0x0000000071727De22E5E9d8BAf0edAc6f37da032`）。账户和 Bundler 必须使用同一版本。\n- 验证代码受到限制：不能以会让模拟与实际执行不一致的方式使用 `TIMESTAMP` 等操作码，存储访问也受限（见 [ERC-7562](/eip-7562/)）。这正是内存池抗垃圾操作的关键。\n- 你需要一个 Bundler 服务（Alchemy、Pimlico、Biconomy、Candide、自建……），通常还需要 Paymaster 服务；它们是基础设施，不是链的一部分。\n- [EIP-7702](/eip-7702/) 让已有 EOA 表现得像智能账户；ERC-4337 原生支持 7702 账户，二者是互补而非竞争关系。\n"}},"requiredBy":[6662,6900,7522,7555,7579,7582,7656,7677,7679,7715,7766,7769,7897,8196]}
