Bỏ qua điều hướng
Account Abstraction · ERC-4337
Trong ERC-4337, user không gửi transaction thẳng lên blockchain. Họ tạo một UserOperation — một object mô tả ý định — và gửi vào alt mempool. Bundler là node chuyên dụng nhặt các UserOps đó, kiểm tra tính hợp lệ, gom chúng lại, và submit một transaction duy nhất lên EntryPoint contract thay mặt cho tất cả.

Bundler Là Gì?
UserOperation, Alt Mempool và Bundle Economics

Lớp infrastructure ẩn phía sau mọi smart wallet transaction — không có Bundler, ERC-4337 không hoạt động.

📅 Cập nhật: 03/2026 ⏱ Đọc ~12 phút 🏷 ERC-4337 · Bundler · UserOp ✍ ZRO Research
📋 Tóm tắt — Đọc trong 60 giây

Bundler: Người Nhặt UserOps và Gửi Lên Chain

Bundler là node chuyên dụng trong hệ sinh thái ERC-4337 với nhiệm vụ: lắng nghe UserOperations từ alt mempool, simulate để kiểm tra tính hợp lệ, gom nhiều UserOps thành một bundle, và submit lên EntryPoint contract qua một transaction EOA thông thường. Bundler chịu gas cost của transaction và được hoàn trả từ EntryPoint sau khi execution.

UserOperation là "pseudo-transaction" — một struct gồm sender, calldata, gas parameters, signature, và Paymaster data. Nó mô tả ý định của user nhưng không phải là transaction on-chain hợp lệ — cần Bundler để relay nó lên chain.

01 · Role

Nhặt UserOps từ alt mempool, validate, bundle và submit

02 · Alt mempool

Mạng P2P riêng cho UserOps, song song với Ethereum mempool

03 · Economics

Kiếm phần chênh lệch gas — incentive để relay UserOps

04 · EntryPoint

Smart contract trung tâm nhận bundle và dispatch execution

01

Bundler Là Gì Trong ERC-4337

Trong kiến trúc blockchain truyền thống, khi bạn muốn thực hiện một giao dịch, bạn ký transaction với private key của EOA và broadcast nó trực tiếp lên Ethereum mempool. Validator nhặt transaction, đưa vào block, thực thi — xong.

ERC-4337 thêm một lớp trung gian: thay vì EOA transaction, user tạo một UserOperation — một object mô tả điều họ muốn làm — và gửi nó vào alt mempool. Bundler là loại node đặc biệt sống trong alt mempool này.

Nhiệm vụ của Bundler:

  • Monitor alt mempool: Nhận và relay UserOps từ các peers trong mạng P2P bundler.
  • Simulate & validate: Kiểm tra liệu UserOp có hợp lệ không — sẽ không revert khi execute, Paymaster có đủ deposit không, signature đúng.
  • Bundle: Gom nhiều UserOps lại thành một batch.
  • Submit: Gọi handleOps() trên EntryPoint contract bằng EOA của mình — đây là transaction Ethereum thật.
  • Được hoàn trả: EntryPoint trả lại gas cost cho Bundler từ deposit của các sender/Paymaster.
ERC-4337 — Bundler Flow Tổng Quan
User/dApp
↓ sendUserOperation(UserOp)
RPC endpoint (eth_sendUserOperation)
↓ relay to peers
Alt Mempool ← UserOp Pool (P2P network of bundlers)
↓ bundler picks up UserOps
Bundler Node
1. simulate_validation(UserOp)
2. simulate_execution(UserOp)
3. bundle [UserOp1, UserOp2, UserOp3]
↓ EOA transaction: handleOps([bundle])
EntryPoint Contract (0x5FF1...)
↓ execute each UserOp
Smart Wallet → executes calldata
↓ refund gas to bundler
✓ Transaction on-chain
02

UserOperation — Giao Dịch Của Tương Lai

UserOperation là một struct (không phải transaction) mô tả đầy đủ ý định của người dùng. Nó giống transaction nhưng linh hoạt hơn nhiều — không cần người dùng có ETH để trả gas, không cần user là EOA, có thể include Paymaster và initCode để deploy wallet.

// UserOperation Struct — ERC-4337 struct UserOperation { // === IDENTITY === address sender; // Smart wallet address (có thể chưa tồn tại) uint256 nonce; // Chống replay, quản lý bởi EntryPoint bytes initCode; // Deploy wallet nếu chưa tồn tại (factory + calldata) // === EXECUTION === bytes callData; // Calldata gửi đến smart wallet (execute gì) // === GAS === uint256 callGasLimit; // Gas limit cho execution phase uint256 verificationGasLimit;// Gas limit cho validation phase uint256 preVerificationGas; // Gas overhead (bundler compensation) uint256 maxFeePerGas; // EIP-1559 max fee (như maxFeePerGas) uint256 maxPriorityFeePerGas;// EIP-1559 tip (như maxPriorityFeePerGas) // === PAYMASTER === bytes paymasterAndData; // [paymaster address][paymaster data] — ai trả gas // === SIGNATURE === bytes signature; // Chữ ký của user (wallet tự validate) }

Điểm khác biệt so với transaction Ethereum thông thường

Tính năngEOA TransactionUserOperation
Ai trả gas?Phải là sender (EOA) có ETHSender, Paymaster, hoặc trả bằng ERC-20
Validation logicECDSA của EOA — cố địnhSmart wallet tự quyết (multisig, passkey, v.v.)
Deploy walletPhải deploy riêng trướcinitCode — deploy + execute trong 1 UserOp
Batch actionsKhông nativecallData có thể batch nhiều actions
On-chain representationTrực tiếp là block transactionExecute bên trong handleOps() call
Nonce managementSequential, globalMulti-dimensional (có thể parallel)
💡
initCode — Deploy on demand
initCode cho phép deploy smart wallet và thực hiện giao dịch trong cùng một UserOp. Bundler detect nếu sender chưa có code, sẽ gọi factory contract trong initCode để deploy wallet trước khi execute callData. User không cần fund wallet hay deploy riêng — mọi thứ trong một bước.
03

Alt Mempool — Tại Sao Cần Mempool Riêng

Ethereum mempool là nơi chứa các pending transactions chờ được validator đưa vào block. UserOperation không thể vào Ethereum mempool thông thường vì:

  • Validator không biết cách validate UserOp (cần simulate execution của Smart Wallet).
  • UserOp không phải transaction hợp lệ về mặt giao thức Ethereum.
  • Denial-of-service risk: UserOp validation có thể tốn compute không giới hạn nếu không có restrictions.

Alt mempool (hay UserOp mempool) là mạng P2P riêng của các bundler nodes. Khi user gọi eth_sendUserOperation lên một bundler RPC endpoint, bundler đó relay UserOp sang các bundler peers trong mạng. Các bundler validate và lưu UserOps trong pool của mình, chờ cơ hội bundle.

P2P Gossip Protocol

Alt mempool dùng gossip protocol tương tự Ethereum devp2p nhưng với validation rules riêng (ERC-7562 — UserOperation mempool rules). Các rules này giới hạn storage access pattern trong validation phase để prevent DoS attacks: ví dụ, validation code không được đọc storage slot ngoài của wallet/paymaster mình, không được gọi contract tùy ý.

⚠️
Alt mempool vẫn đang phát triển
Tính đến 2026, phần lớn production traffic của ERC-4337 không đi qua P2P alt mempool mà đi trực tiếp qua private RPC của bundler providers (Alchemy, Pimlico). P2P alt mempool là mục tiêu decentralization nhưng vẫn đang trong quá trình hoàn thiện spec. ERC-7562 định nghĩa rules cho mempool nhưng implementation vẫn chưa đồng nhất giữa các bundlers.
04

Bundler Kiếm Tiền Thế Nào — Bundle Economics

Bundler là economic actor — có incentive tài chính để relay UserOps. Mô hình kinh tế hoạt động như sau:

  1. Bundler submit transaction handleOps([userOps]) — trả gas cost từ EOA của mình.
  2. EntryPoint thực thi từng UserOp trong bundle.
  3. Với mỗi UserOp, EntryPoint charge sender/Paymaster theo actualGasUsed * effectiveGasPrice.
  4. EntryPoint refund bundler tổng gas đã charge từ tất cả UserOps.
  5. Profit = Refund từ EntryPoint − Gas thực tế đã trả cho validator
// Bundle economics example // 3 UserOps trong bundle UserOp1: maxFeePerGas = 20 gwei, actualGasUsed = 150,000 UserOp2: maxFeePerGas = 25 gwei, actualGasUsed = 200,000 UserOp3: maxFeePerGas = 18 gwei, actualGasUsed = 100,000 // Network base fee at time of submission: 15 gwei baseFee = 15 gwei priorityFee = 2 gwei // bundler's tip to validator effectiveGasPrice = baseFee + priorityFee = 17 gwei // Total gas consumed by handleOps transaction totalGas = 150000 + 200000 + 100000 + overhead = ~470,000 gasCost = 470,000 * 17 gwei = 7.99 ETH (×10⁻³) // Refund from EntryPoint (at each UserOp's maxFeePerGas) refund1 = 150,000 * 17 gwei = 2.55 MWEI // capped at maxFeePerGas refund2 = 200,000 * 17 gwei = 3.40 MWEI refund3 = 100,000 * 17 gwei = 1.70 MWEI profit ≈ refundTotal - gasCost + preVerificationGas_fees

Ngoài gas spread, Bundler còn có thể collect preVerificationGas fee — phần gas bù cho overhead bundler (network cost, simulation compute, storage). Đây là "bundler fee" mà developer phải tính vào khi ước tính transaction cost cho user.

05

Simulation và Validation — Trước Khi Bundle

Bundler không thể submit UserOp lên chain mà không biết nó có thành công không — nếu revert, Bundler mất gas mà không được hoàn trả. Do đó, mọi UserOp đều phải qua quá trình simulation trước.

Validation Simulation

Bundler gọi simulateValidation(UserOp) trên EntryPoint (chỉ là eth_call, không on-chain). Quá trình này:

  • Gọi validateUserOp() trên Smart Wallet → kiểm tra signature hợp lệ, nonce đúng.
  • Nếu có Paymaster, gọi validatePaymasterUserOp() → kiểm tra Paymaster có accept trả gas không, deposit đủ.
  • Deploy wallet nếu initCode non-empty → kiểm tra factory hợp lệ.
  • Kiểm tra storage access restrictions (ERC-7562) để prevent DoS.

Execution Simulation

Sau validation, Bundler simulate execution để ước tính gas dùng và đảm bảo không revert. Nếu cả hai simulation pass, UserOp được đưa vào bundle.

🚨
Time-of-check vs Time-of-use (TOCTOU)
Giữa lúc Bundler simulate và lúc transaction được mine, trạng thái blockchain có thể thay đổi. Ví dụ: Paymaster deposit giảm do một transaction khác được mine trước. Bundler có thể bị "griefed" — tốn gas mà UserOp revert khi execute thật. Đây là một bài toán phức tạp, ERC-7562 cố gắng giảm thiểu rủi ro này bằng cách restrict storage access trong validation.
06

EntryPoint Contract — Nơi Mọi Thứ Hội Tụ

EntryPoint là singleton Smart Contract — một contract duy nhất được deploy trên mỗi chain, xử lý tất cả UserOps. Địa chỉ: 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789 (v0.6) và 0x0000000071727De22E5E9d8BAf0edAc6f37da032 (v0.7) trên tất cả EVM chains.

handleOps() — Entry point của bundle

Bundler gọi handleOps(UserOperation[] ops, address payable beneficiary). EntryPoint xử lý từng UserOp tuần tự:

  1. Validate phase: Gọi validateUserOp() trên Smart Wallet, gọi validatePaymasterUserOp() nếu có Paymaster.
  2. Execute phase: Gọi Smart Wallet với callData của UserOp.
  3. Post-op phase (nếu có Paymaster): Gọi postOp() trên Paymaster để settlement.
  4. Refund bundler: Tính toán gas đã dùng và transfer ETH cho beneficiary.
EntryPoint là audited và immutable
EntryPoint contract được audit bởi OpenZeppelin và Ackee Blockchain, và là immutable contract — không có upgrade mechanism. Đây là thiết kế có chủ ý: EntryPoint giữ deposits của tất cả Smart Wallets và Paymasters, nên cần độ tin cậy tuyệt đối. Nếu cần upgrade, sẽ deploy EntryPoint version mới và migrate dần — đây là lý do tồn tại v0.6 và v0.7.

Để hiểu đầy đủ về Paymaster và cách EntryPoint xử lý gas sponsorship, xem bài Paymaster Là Gì? Gas Sponsorship trong ERC-4337.

07

Chạy Bundler Node — Kỹ Thuật và Yêu Cầu

Bundler node là một process riêng biệt chạy song song với (hoặc connect tới) Ethereum node. Các implementation phổ biến:

ImplementationNgôn ngữMaintainerGhi chú
InfinitismTypeScriptERC-4337 authorsReference implementation, đầy đủ nhất
AltoTypeScriptPimlicoProduction-grade, dùng cho Pimlico service
SiliusRustVid KersicPerformance-focused, P2P mempool support tốt
SkandhaTypeScriptEtherspotModular architecture

Yêu cầu để tự chạy bundler

  • Ethereum node access: Full node (geth/nethermind/reth) hoặc archive node RPC cho simulation. Infura/Alchemy RPC cũng hoạt động với hạn chế.
  • Bundler EOA: Một address có ETH — đây là address sẽ call handleOps(). Cần đủ ETH để cover gas của bundle transactions.
  • Server: VPS hoặc dedicated server (RAM 4GB+, stable network).
  • Config: Chain ID, EntryPoint address, supported ERC-4337 version, min/max gas settings.
# Ví dụ config: Alto bundler (Pimlico implementation) alto start \ --rpc-url http://localhost:8545 # ETH node RPC --executor-private-keys 0xYOUR_BUNDLER_PRIVATE_KEY # Bundler EOA --entry-points 0x0000000071727De22E5E9d8BAf0edAc6f37da032 # EntryPoint v0.7 --chain-id 1 # Ethereum mainnet --min-balance 0.1ether # Minimum ETH để operate --max-bundle-size 10 # Tối đa 10 UserOps per bundle --port 3000 # RPC port expose
08

Bundler Services — Alchemy, Pimlico, Stackup

Trong thực tế, phần lớn developer dùng bundler-as-a-service thay vì tự chạy. So sánh các provider phổ biến:

ProviderStrengthsEntryPoint supportNotable
AlchemyScale lớn, reliability cao, ecosystem tools (Gas Manager)v0.6, v0.7Bundler + Paymaster trong 1 suite
PimlicoDeveloper UX tốt, permissionless Paymaster, open source bundlerv0.6, v0.7Alto bundler, Verifying Paymaster mạnh
StackupMulti-chain rộng, đơn giảnv0.6Docs tốt cho người mới
BiconomyFull AA stack — bundler + paymaster + smart accounts SDKv0.6, v0.7End-to-end solution cho dApp
Self-hostedFull control, privacy, no rate limitsTùy implementationCần maintain, cần ETH buffer

Kết nối Bundler từ dApp

// Sử dụng Pimlico bundler với viem import { createPublicClient, http } from "viem" import { createBundlerClient } from "permissionless" import { pimlico } from "permissionless/actions/pimlico" const bundlerClient = createBundlerClient({ transport: http("https://api.pimlico.io/v2/1/rpc?apikey=YOUR_KEY"), entryPoint: "0x0000000071727De22E5E9d8BAf0edAc6f37da032", // v0.7 }) // Gửi UserOperation const userOpHash = await bundlerClient.sendUserOperation({ userOperation: { sender: smartWalletAddress, nonce: nonce, callData: encodedCallData, // ... other fields } }) // Wait for receipt const receipt = await bundlerClient.waitForUserOperationReceipt({ hash: userOpHash })

Để hiểu đầy đủ hơn về toàn bộ ERC-4337 stack, xem bài ERC-4337 Là Gì? Account Abstraction Từ A–Z.

Câu Hỏi Thường Gặp — Bundler

Node Ethereum thông thường xử lý transactions từ EOA thông qua public mempool. Bundler là một loại node đặc biệt lắng nghe UserOperations từ alt mempool riêng — một mạng P2P song song với mempool Ethereum. Bundler không mine block; thay vào đó nó gom UserOps, simulate tính hợp lệ, bundle chúng lại và submit một transaction thông thường lên EntryPoint contract thay mặt cho tất cả UserOps trong bundle. Bundler là EOA có ETH để trả gas cho transaction bundle.
UserOperation không phải là transaction blockchain hợp lệ nên không thể vào public Ethereum mempool. Hơn nữa, validation rules của UserOperation phức tạp hơn EOA transaction: cần simulate execution của Smart Wallet để kiểm tra liệu Paymaster sẽ trả gas và liệu Smart Wallet sẽ accept. Nếu dùng public mempool, validators sẽ không biết cách validate UserOps. Alt mempool là mạng P2P riêng của các bundler nodes — chỉ bundler nodes mới hiểu và relay UserOps.
Bundler kiếm phần chênh lệch giữa gas được reimbursed từ EntryPoint và gas thực tế đã trả cho miner/validator. Trong UserOperation, sender (hoặc Paymaster) set maxFeePerGas và maxPriorityFeePerGas. Sau khi execution, EntryPoint refund bundler phần gas đã dùng. Nếu bundler submit transaction lúc gas base fee thấp hơn maxFeePerGas, phần chênh lệch là lợi nhuận. Bundler cũng collect preVerificationGas fee như overhead compensation.
Có — bundler là open source và bất kỳ ai có ETH để trả gas có thể chạy. Các implementation phổ biến là Infinitism (reference implementation), Silius (Rust), Alto (TypeScript, của Pimlico), Skandha (TypeScript). Yêu cầu: Ethereum full node (hoặc RPC endpoint), một EOA có đủ ETH làm gas buffer, server stable để chạy bundler software. Trong thực tế, tự chạy bundler không có nhiều lợi ích kinh tế so với dùng bundler-as-a-service — trừ khi cần customization hoặc privacy.

Tài liệu tham khảo

EIP chính thức, documentation kỹ thuật và papers về ERC-4337 stack.

  1. Buterin, V. et al. EIP-4337: Account Abstraction Using Alt Mempool. eips.ethereum.org/EIPS/eip-4337. — Specification chính thức ERC-4337.
  2. ERC-4337 Team. ERC-7562: Account Abstraction Validation Scope Rules. eips.ethereum.org/EIPS/eip-7562. — Rules cho alt mempool validation, DoS protection.
  3. Infinitism. Account Abstraction Reference Bundler. github.com/eth-infinitism/bundler. — Reference implementation TypeScript bundler.
  4. Pimlico. Alto Bundler Documentation. docs.pimlico.io/bundler. — Production bundler documentation và API reference.
  5. ERC-4337.io. ERC-4337 Resources and Docs. erc4337.io. — Community hub, stats, và links.
  6. ZRO Research. ERC-4337 Là Gì? Account Abstraction — TWT.VN. twt.vn/erc-4337-la-gi/. — Bài tổng quan ERC-4337 đầy đủ.
  7. ZRO Research. Wallet Infrastructure & Key Management. twt.vn/. — Pillar page toàn bộ cluster.
₿ TWT.VN · Knowledge Base

Khám Phá Thêm — Wallet Infrastructure

Mỗi bài đi sâu vào một chủ đề kỹ thuật — cùng nhau tạo thành bộ tài liệu Wallet Infrastructure đầy đủ nhất tiếng Việt.