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)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Solidity Programming Language
Solidity Programming Language

Written by Solidity Programming Language

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

No responses yet