Solidity Data Storage Location Comparison:

storage vs memory vs calldata.

A ๐Ÿงต to help you better understand solidity and write gas-efficient smart contracts
In Solidity, variables can be stored in three different locations: storage, memory, and calldata.

Each of these locations has its own unique characteristics, and it is important for Solidity developers to understand how each of them works.

Let's break them one by one:
Storage

Storage is a permanent storage location that is written to the blockchain.

Variables stored in storage are persistent and can be accessed by any function within the contract. However, accessing variables in storage is more expensive than accessing variables in memory. Image
๐— ๐—ฒ๐—บ๐—ผ๐—ฟ๐˜†

Memory is a temporary storage location that is used to store variables during contract execution

Variables stored in memory are not persistent and are lost when the function execution ends

Accessing variables in memory is less expensive than in storage Image
๐—–๐—ฎ๐—น๐—น๐—ฑ๐—ฎ๐˜๐—ฎ

Calldata is a temporary storage location that is used to pass arguments to a function.

You should try to use it wherever possible but keep in mind is read-only and can't be modified by the function.

Accessing variables in calldata is least expensive. Image
๐—–๐—ผ๐—ป๐—ฐ๐—น๐˜‚๐˜€๐—ถ๐—ผ๐—ป

Storage is a permanent storage location that is written to the blockchain and is the most expensive to access.

Memory is a temporary storage location that is used to store variables during contract execution and is less expensive to access than storage. Image
Calldata is a temporary storage location that is used to pass arguments to a function and is the least expensive to access.

By understanding the differences between these storage locations, Solidity developers can write more efficient and effective smart contracts.
That's it for this one.

If you liked this ๐Ÿงต, give it a โค๏ธ + RT.
I put out content in web3 world.

Follow @MoyezRabbani for more threads like this.

#Web3 #Developer #Solidity
That's it for this one.

If you liked this ๐Ÿงต, give it a โค๏ธ + RT.
I put out content in web3 world.

Follow
@MoyezRabbani
for more threads like this.

#Web3 #Developer #Solidity

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Moyez | Web3 Dev ( Open for Freelance Work )

Moyez | Web3 Dev ( Open for Freelance Work ) Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @MoyezRabbani

Mar 16
Day 2 of Learning Web Design and Mastering React.

Couldn't do anything in React as I had my College Exams today

Nonetheless here's what I learned in two hours today๐Ÿ‘‡
Today I learned about TYPOGRAPHY in design.

Typography isnโ€™t just about choosing the right font. Itโ€™s about choosing the right combination of those fonts. Choosing the right type of faces, font-weight on the right occasion, and contexts.
Each typeface comes with a personality.

A typeface can broadly be divided into two categories: Serif and Sans-serif where sans in french simply means 'non'.

We can also use 'Display' typeface but only for headlines. Image
Read 7 tweets
Mar 15
I spent an hour pursuing the Complete Web Design Course by Vako Shvili on Udemy today.

So far the course seems to be great and completely value packed.

Here's what I have learned today:
1. In web design, It all starts with alignment and grid.

Everything that is orderly, symmetric, and organized will be perceived as more beautiful than anything that is chaotic and disorderly.

Just as you would perceive a clean room better than a messy one. Image
2. One should start web design by using imaginary grids (not necessary though).

As a standard, the entire webpage should be divided into 12 grid columns with each column being separated by the other by a gap(gutter) of 30px Image
Read 5 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(