Skip to content
PenyuOnCore
Menu
  • Home
  • Core Ecosystem Analysis
  • Personal Finance & Investing
  • Make Money Online
  • Bitcoin
  • About Us
Menu
panic code 0x32 array out-of-bounds access error with revert data 0x4e487b71

Panic Code 0x32 in Solidity: “Array Out-of-Bounds Access” Explained and Fixed

Posted on November 21, 2026

Panic code 0x32 means a Solidity contract tried to read or write an array, bytesN value, or calldata slice at an index that does not exist, usually i >= length. You’ll see the revert data 0x4e487b71 followed by ...32. The fix is almost always a bounds check, such as i < arr.length instead of i <= arr.length, or allocating a memory array before you write to it.

Below you’ll find what the error looks like in different tools, the six code patterns that cause it, and how to find the exact line. We reproduced each example this week with Foundry (solc 0.8.30) on a local Anvil node, and ran one read-only eth_call against Core mainnet (chain ID 1116) to see what a real Core node returns.

What Panic Code 0x32 Means

Since Solidity 0.8.0, the compiler adds checks that revert with a built-in error, Panic(uint256), when code hits a state that bug-free code should never reach. The Solidity documentation defines code 0x32 as: “If you access an array, bytesN or an array slice at an out-of-bounds or negative index (i.e. x[i] where i >= x.length or i < 0).”

The same docs say a correctly working contract should never produce a Panic, even on bad external input. So a 0x32 is a bug signal, not a normal “you don’t have enough balance” style rejection. Before 0.8.0, out-of-bounds access used the invalid opcode and consumed all remaining gas. Modern versions revert cleanly with the Panic error instead.

If you have already met its sibling panic code 0x11 (arithmetic underflow or overflow), the encoding is identical. Only the last byte changes.

How the error shows up in different tools

  • Raw revert data: 0x4e487b71 + 0000...0032. 0x4e487b71 is the selector of Panic(uint256), and 0x32 is 50 in decimal.
  • Core mainnet RPC (rpc.coredao.org): execution reverted: out-of-bounds access of an array or bytesN, with error code 3 and the panic data attached (we tested this on 21 Nov 2026).
  • Anvil / Foundry: execution reverted: panic: array out-of-bounds access (0x32).
  • Hardhat: reverted with panic code 0x32 (Array accessed at an out-of-bounds or negative index), as quoted in this Ethereum Stack Exchange thread.
  • ethers.js v6: Panic due to ARRAY_RANGE_ERROR(50), from the PanicReasons map in the ethers abi-coder source.

Wallets often show only a generic “execution reverted” error. If that happens, decode the data yourself:

cast decode-error 0x4e487b710000000000000000000000000000000000000000000000000000000000000032
# Panic(uint256)
# 50

Common Causes of Panic Code 0x32 (and Fixes)

Side-by-side Solidity code patterns that revert with panic 0x32 and their fixed versions: loop bounds, last element, memory allocation, push, bytes32 index

Each of the patterns below reverted with 0x32 in our local tests. The contract stored three scores (40, 25, 35).

1. Off-by-one loop: <= instead of <

This is the most common cause. Valid indexes run from 0 to length - 1, so the last loop step reads one slot past the end.

// Reverts with Panic(0x32)
for (uint256 i = 0; i <= scores.length; i++) s += scores[i];

// Works: returned 100 in our test
for (uint256 i = 0; i < scores.length; i++) s += scores[i];

2. Reading the “last” element with the wrong index

scores[scores.length] always points one slot past the end. Use scores[scores.length - 1], and check that the array is not empty first. On an empty array, length - 1 underflows and reverts with 0x11 instead. We confirmed that as well.

require(scores.length > 0, "No scores");
return scores[scores.length - 1];

3. Writing to a memory array you never allocated

A declaration like uint256[] memory a; has length zero, so a[0] = 1 reverts. Allocate the size first. Memory arrays cannot use push.

// Reverts
uint256[] memory a;
a[0] = 1;

// Works
uint256[] memory a = new uint256[](1);
a[0] = 1;

This exact mistake shows up in another Stack Exchange question, where a library function returned an unallocated array.

4. Assigning to a storage index instead of pushing

Storage arrays don’t grow when you assign past the end. scores[3] = 1 on a three-item array reverted in our test. Overwriting index 1 worked. To append, use scores.push(value).

5. Indexing a bytesN beyond its size

Fixed-size byte types are indexable too. A bytes32 has valid indexes 0 to 31, so b[32] reverts with 0x32. The same thing happens with bytes4 at index 4 or higher.

6. Calldata slices that are shorter than expected

Array slices such as x[2:] are bounds-checked as well. In our test, x[2:][0] returned 3 for [1,2,3] but reverted with 0x32 for [1,2]. Validate the input length before you slice user-supplied data.

How to Find the Line That Throws Panic 0x32

  1. Reproduce locally. Run the same call against a local node. If the bug depends on live contract state, fork Core mainnet with Anvil so the arrays hold the same data.
  2. Trace the call. Foundry’s debugging tools (forge test -vvvv, forge test --debug, or cast run <txhash> for a mined transaction) show which function reverted. Our Foundry cast commands for Core guide covers the RPC flags.
  3. Look for indexing in that function. Search for [i], [length], slices, and unallocated memory arrays. Pay extra attention to any index that comes from a function argument.
  4. Write a regression test. forge-std includes stdError.indexOOBError, so you can assert the exact panic: vm.expectRevert(stdError.indexOOBError);

Panic 0x32 vs Similar Errors

Error Trigger Typical fix
Panic 0x32 Index >= length on an array, bytesN, or slice Use < length; allocate memory arrays; use push
Panic 0x31 .pop() on an empty array Check length > 0 before popping
Panic 0x11 Arithmetic under/overflow, e.g. length - 1 on an empty array Guard the subtraction
Empty revert (0x) Out-of-range index on an auto-generated public array getter Read length first, or add a custom getter

That last row matters. When we called the compiler-generated getter scores(5), the call reverted with no data, not Panic 0x32. If a front end shows “missing revert data” when it reads an array by index, an out-of-range index on a public getter is a likely cause.

Preventing Panic Code 0x32 in Production

  • Validate external indexes with a clear message or custom error, for example if (id >= items.length) revert InvalidIndex(id);. Users get a readable reason instead of a Panic.
  • Treat length as an exclusive upper bound everywhere: in loops, in slices, and in pagination math such as start + count.
  • Prefer mappings or push-based storage when items are added over time.
  • Fuzz test functions that take indexes. Foundry fuzzing will quickly try values at and beyond length.

Core runs the same EVM bounds checks as Ethereum, so a contract that panics on a local node will panic the same way on Core mainnet. Our read-only eth_call of a constructor that writes a[2] on a two-item memory array came back from rpc.coredao.org with exactly 0x4e487b71...32.

FAQ

Does a reverted panic 0x32 transaction still cost gas?

Yes. A mined transaction that reverts still pays for the gas used up to the revert, but state changes are rolled back. Since Solidity 0.8.0 the panic doesn’t burn all remaining gas the way the old invalid opcode did. Simulate first with eth_call or cast call to catch the error for free.

Can a negative index cause panic code 0x32?

Array indexes are unsigned in practice. The docs list i < 0 as a trigger, but the usual “negative” case is an unsigned value that wrapped or underflowed somewhere else. In checked 0.8 code, that underflow usually reverts with 0x11 first.

Is panic code 0x32 a problem with my wallet or the Core network?

No. The contract code reverted on purpose because an index was out of range. Changing the RPC or raising the gas limit won’t fix it. Either the input you sent or the contract logic needs to change.

Disclaimer: This article is for educational purposes only and is not financial or investment advice. Always test smart contract changes on a local node or testnet before deploying.

Recent Posts

  • Min Relay Fee Not Met: What This Bitcoin Error Means and How to Fix It
  • Medium Partner Program Payout: Schedule, $10 Minimum and Stripe Setup (2026)
  • How to Replace Lost Savings Bonds (FS Form 1048 Guide, 2026)
  • Pond5 Contributor Payout: Minimum, Payout Date and Methods (2026)
  • Child Pays for Parent (CPFP): How to Speed Up a Stuck Bitcoin Transaction
Subscription form is not available at the moment
  • Altcoin News
  • Bitcoin
  • Blog
  • Core Ecosystem Analysis
  • DeFi
  • Free Crypto Signals
  • Make Money Online
  • Personal Finance & Investing
  • Token Analysis
  • About Us
  • Contact
  • Privacy Policy
  • Disclaimer
©2026 PenyuOnCore | Design: Newspaperly WordPress Theme