LayerZeroFault
EVM & JSON-RPC CODE: Panic 0x32 Reviewed & Verified:

Solidity Panic 0x32: Out-of-Bounds Array Index Access Fix

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

Solidity Panic 0x32 (selector 0x4e487b71) indicates an out-of-bounds or negative array index access error. This occurs when a smart contract attempts to access an element of a fixed or dynamic array using an index greater than or equal to array.length (or on an empty array). Off-by-one errors in loop conditions (using <= instead of <) and querying empty storage arrays are the most frequent causes. Ensure index is strictly less than array.length.

# Root Cause & Technical Architecture

In Solidity, all array reads and writes perform automatic bounds checking. If `index >= array.length`, the runtime aborts execution and emits `Panic(0x32)`. Unlike C or lower-level languages that permit memory reading past buffers, EVM bytecode validates indices against the 32-byte length slot preceding dynamic array data in storage or memory. Attempting to pop an empty array also triggers Panic 0x32.

# 4-Step Actionable Diagnostic Protocol

Step-by-Step Resolution
01

Audit Loop Boundary Conditions for Off-by-One Errors

Verify that for-loops iterate using i < array.length rather than i <= array.length. Remember that array indexing is 0-based.

02

Check Empty Array Access Preconditions

Before accessing array[0] or calling array.pop(), assert that array.length > 0 to prevent instant Panic 0x32 reverts on empty arrays.

03

Verify Merkle Proof Leaf Array Sizing

In airdrop and whitelist verifiers, ensure that user-supplied proof arrays match the exact tree depth required by the contract.

04

Trace Array Length in Foundry Simulation

Log array.length and the target index before the reverting line using console.log() in Foundry to inspect dynamic length values.

# Diagnostic Verification Code / Command

solidity
array-bounds-guard.sol
// Safe Array Element Retrieval Guarding Against Panic(0x32)
function getElementSafely(uint256[] memory items, uint256 index) public pure returns (uint256) {
    // If index >= items.length -> Triggers Panic(0x32)
    require(index < items.length, "Index out of bounds");
    return items[index];
}
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 EVM & JSON-RPC

Related Hex Statuses

# Frequently Asked Questions

FAQ Schema

What does Panic code 0x32 mean?

Panic code 0x32 indicates that a contract tried to access an array index at or beyond the current length of the array.

Can calling .pop() on an empty array cause Panic 0x32?

Yes. Calling array.pop() on an array whose length is zero causes an underflow on the length counter, triggering Panic 0x32.

How do I decode Panic 0x32 from a transaction receipt?

The return data will begin with 0x4e487b71 followed by 32 bytes encoding the value 0x32 (decimal 50).