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.
๐ ๐ฒ๐บ๐ผ๐ฟ๐
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
๐๐ฎ๐น๐น๐ฑ๐ฎ๐๐ฎ
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.
๐๐ผ๐ป๐ฐ๐น๐๐๐ถ๐ผ๐ป
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.
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.
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.