Foundry Inspect Code

--

How many slots do we need ?

Explain your calculation!

We have 6 different uint variable in solidity programming and each of them has different byte sizes. Logic is simple “every uint8 variable is equal to 1 byte

uint8 : 1 bytes

uint16: 2 bytes

uint32 : 4 bytes

uint64 : 8 bytes

uint128 : 16 bytes

uint256 : 32 bytes

We start our code:

How many slots do we need ?

We use the following code in foundry. Please remember our contract’s name is Add.

forge inspect Add storage-layout — pretty

We see that only first five variables are in the first(0) slot and last variable goes to second(1) slot.

Ok! This is my illustration.

Associate Professor Engin YILMAZ (VeriDelisi)

--

--

Solidity Programming Language

Solidity basics for beginners: Learn the fundamentals of smart contract development and build your first DApp! #Solidity #Foundry #Ethereum #Opcodes #DApps