LayerZeroFault
ERC-4337 & Safe CODE: AA40 Reviewed & Verified:

ERC-4337 Error AA40: Over VerificationGasLimit Revert Fix

Verified by Victor Vance • Lead Technical Analyst & Systems Researcher
Quick Diagnostic Answer (Executive Summary) GSC Snippet Verified

ERC-4337 error AA40 "over verificationGasLimit" occurs when the gas consumed during the UserOperation validation phase (including account and paymaster validation) exceeds the verificationGasLimit specified in the UserOp. This error frequently impacts smart accounts using computationally intensive signature schemes such as WebAuthn secp256r1 (P-256) precompiles, complex session key policies, or modular ERC-7579 validation hooks. Increase verificationGasLimit in your client SDK by 30% to 50% to safely accommodate validation gas execution surges.

# Root Cause & Technical Architecture

The ERC-4337 EntryPoint restricts the gas available to `validateUserOp` to prevent denial-of-service attacks on bundlers. It measures the gas consumed between the start of validation and its conclusion. If `gasUsed > verificationGasLimit`, the EntryPoint halts execution and reverts with `AA40 over verificationGasLimit`. This is especially common on L2s where WebAuthn RIP-7212 precompiles are missing, requiring fallback to software P-256 verifiers consuming ~300,000 gas.

# 4-Step Actionable Diagnostic Protocol

Step-by-Step Resolution
01

Check for Native RIP-7212 Precompile Availability

Verify if your target chain supports the native secp256r1 precompile at 0x100. Without it, software verifiers require at least 350,000 verification gas.

02

Profile Gas Consumption of Custom Validation Hooks

In ERC-7579 modular accounts, measure gas consumed by validation modules and policy hooks using Foundry or Tenderly simulation.

03

Double verificationGasLimit Parameter in Bundler Client

In your bundler configuration (e.g. Permissionless.js), apply a 1.3x to 1.5x multiplier to estimated verificationGasLimit before signing.

04

Audit Multi-Owner Signature Aggregation Loops

If validating multiple signers or nested ERC-1271 contracts, ensure signature parsing loops do not contain inefficient memory copies.

# Diagnostic Verification Code / Command

typescript
adjust-verification-gas.ts
// Apply Safety Buffer to verificationGasLimit in Viem/Bundler Client
async function estimateAndBufferUserOp(client: any, userOp: any) {
  const estimates = await client.request({
    method: 'eth_estimateUserOperationGas',
    params: [userOp, ENTRYPOINT_ADDRESS]
  });

  // Apply 30% safety buffer to prevent AA40 over verificationGasLimit
  const bufferedVerificationGas = (BigInt(estimates.verificationGasLimit) * 130n) / 100n;

  return {
    ...userOp,
    verificationGasLimit: bufferedVerificationGas,
    callGasLimit: estimates.callGasLimit,
    preVerificationGas: estimates.preVerificationGas
  };
}
Zero-Secrets Client Sandbox

Launch ERC-4337 UserOp Decoder

Execute client-side cryptographic simulation and parameter checks safely in your browser via native WebCrypto without sending private keys or mnemonics over the wire.

Open Sandbox →
Comprehensive In-Depth Guide

Read Full Investigation & Recovery Workflow

Explore complete architectural diagrams, edge-case failure trees, and detailed post-mortem analysis in our verified deep guide.

Read Guide →

# Related Diagnostic Codes in ERC-4337 & Safe

Related Hex Statuses

# Frequently Asked Questions

FAQ Schema

Why do WebAuthn passkey wallets consume more verification gas?

Secp256r1 (P-256) curve verification in pure Solidity requires modular exponentiation and scalar multiplication that consumes 250k–350k gas without precompiles.

Can bundlers reject transactions if verificationGasLimit is too high?

Yes. Bundlers enforce a maximum verification gas cap (typically 1.5M to 2M gas) to prevent transactions from consuming entire block limits.

Does AA40 consume real gas on-chain?

If the bundler simulates locally via eth_estimateUserOperationGas, no gas is spent. If submitted on-chain by a faulty bundler, the bundler incurs the loss.