Rules for Storage Location in Solidity
Mohammad Haseeb
Generative AI & Language Models | Blockchain | Ethereum | Node Js | AWS | Nestjs | Expressjs | React | Next | Postgresql | Mongodb
Rule No. 1
State variables are always stored in the storage data location.
Rule No. 2
Whenever a variable is declared as a function parameter, it is stored into the memory data location.
Rule No. 3
Whenever a variable is declared as a function parameter, it is stored into the memory data location. But now, we have two cases here :
Rule No. 4
The arguments supplied by callers to function parameters are always stored in call data locations.
Rule No. 5
Whenever you assign a state variable to another state variable, even inside of functions, you create a new copy.
Rule No. 6
A new copy is made whenever a storage variable is assigned from another memory variable.
Rule No. 7
A new copy is always created when a memory variable is assigned from another state variable.
Rule No. 8
Memory variables assigned from another memory variable do not create copies for reference types. However, they do create copies for value types
Sr. React Native (Lead) Eng. ?? 6 yrs ?? Message for Projects ?? RN Advanced Guide Book (1.8K+ ??) ?? Author → #NotJustDev ?? (42K+ Devs)
2 年Great job bro