UserOperation
UserOperation represents an ERC-4337 v0.6 user operation. User operations enable account abstraction by separating transaction validation from execution, allowing smart contract wallets with custom logic for signatures, gas payment, and access control.Quick Start
Type Definition
Fields
sender
Smart account address initiating the operation.nonce
Anti-replay nonce. Often encoded askey || sequence where:
key: High 192 bits - nonce key for parallel operationssequence: Low 64 bits - sequential counter per key
initCode
Account creation code (factory address + calldata). Empty if account already deployed.callData
Calldata to execute on the account contract.callGasLimit
Gas limit for the execution phase (after validation).verificationGasLimit
Gas limit for the validation phase (signature verification).preVerificationGas
Fixed gas overhead for bundler compensation (calldata costs, loop overhead).maxFeePerGas
Maximum total fee per gas (EIP-1559 format).maxPriorityFeePerGas
Maximum priority fee per gas (EIP-1559 tip).paymasterAndData
Paymaster address (20 bytes) + paymaster-specific data. Empty if self-paying.signature
Account signature over the userOpHash.API Reference
from
Create UserOperation from parameters.hash
Compute userOpHash for signing.keccak256(abi.encode(userOp, entryPoint, chainId))
pack
Convert UserOperation (v0.6) to PackedUserOperation (v0.7).User Operation Lifecycle
- Creation: Wallet creates unsigned user operation
- Gas estimation: Bundler simulates and estimates gas
- Signing: Wallet signs userOpHash
- Submission: Submit to bundler mempool
- Bundling: Bundler aggregates operations
- Execution: EntryPoint validates and executes
Usage Patterns
Basic Operation
With Paymaster
Account Deployment
Related Types
- PackedUserOperation - v0.7 packed format
- EntryPoint - Entry point contract
- Paymaster - Gas sponsorship
- Bundler - Operation bundler

