Verify USDC Balance and NFT Meta Data with Proof

Leo Zhang
7 min readAug 17, 2022

In previous blog post of the series about Ethereum storage (see full list of posts at the end), we explained how Ethereum storage works for simple contract with fix sized variables.

In this blog post, I will continue explain how dynamic sized variables like map and array works, and we will also walk through real world examples to explain and test cases to verify the formula.

Dynamic Sized Data Structure

Ethereum storages values in 32 bytes wide slots. Slots are indexed by a uint256 number.

For static sized variables, they are stored sequentially in slots.

Note, the slot index is not a global index, but relative within a smart contract. Each contracts stores variables sequentially from slot 0 (slot index is 0):

Slot index is relative within a contract

However, for dynamic sized data structure like map or array, the storage position of their items can not be stored sequentially in slots. Instead, the slot position for items is calculated using some formulas based on item key in a map or item index in an array.

Let’s go through each of them.

Slot Index for Key Value Pair in a Map

For map, the slot index for each item (key-value pair) is calculated as:

--

--