Solidity Panic 0x32: Out-of-Bounds Array Index Access Fix
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 ResolutionAudit 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.
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.
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.
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// 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];
} 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 EVM & JSON-RPC
Related Hex StatusesJSON-RPC Error -32000: Insufficient Funds for Gas * Price + Value
Fix JSON-RPC error -32000 insufficient funds for gas * price + value. Resolve native token balance shortages, fee estimation surges, and gas caps.
JSON-RPC Error -32000: Replacement Transaction Underpriced Fix
Fix JSON-RPC error -32000 replacement transaction underpriced. Apply mandatory 10%+ maxPriorityFeePerGas bump on same nonce to replace stuck mempool txs.
JSON-RPC Error -32000: Nonce Too Low Stale Wallet State Fix
Fix JSON-RPC error -32000 nonce too low. Troubleshoot stale local wallet nonce caches, pending mempool transactions, and reset account state.
# Frequently Asked Questions
FAQ SchemaWhat 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).