Skip to main content

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 as key || sequence where:
  • key: High 192 bits - nonce key for parallel operations
  • sequence: 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.
Formula: keccak256(abi.encode(userOp, entryPoint, chainId))

pack

Convert UserOperation (v0.6) to PackedUserOperation (v0.7).

User Operation Lifecycle

  1. Creation: Wallet creates unsigned user operation
  2. Gas estimation: Bundler simulates and estimates gas
  3. Signing: Wallet signs userOpHash
  4. Submission: Submit to bundler mempool
  5. Bundling: Bundler aggregates operations
  6. Execution: EntryPoint validates and executes

Usage Patterns

Basic Operation

With Paymaster

Account Deployment

References