ERC-4337 Error AA40: Over VerificationGasLimit Revert Fix
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 ResolutionCheck 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.
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.
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.
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// 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
};
} 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.
Read Full Investigation & Recovery Workflow
Explore complete architectural diagrams, edge-case failure trees, and detailed post-mortem analysis in our verified deep guide.
# Related Diagnostic Codes in ERC-4337 & Safe
Related Hex StatusesERC-4337 Error AA10: Sender Already Constructed UserOp Fix
Fix ERC-4337 error AA10 sender already constructed. Resolve non-empty initCode sent for deployed smart accounts, bundler estimation, and counterfactuals.
ERC-4337 Error AA20: Account Not Deployed EntryPoint Revert
Fix ERC-4337 error AA20 account not deployed. Troubleshoot empty initCode for counterfactual smart accounts, factory calldata, and pre-deployment.
ERC-4337 Error AA24: Signature Error UserOp Validation Fix
Fix ERC-4337 error AA24 signature error. Resolve validateUserOp signature mismatch, userOpHash EIP-712 hashing errors, and signature aggregator faults.
# Frequently Asked Questions
FAQ SchemaWhy 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.