In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
The main content of this article is to explain "what is the difference between memory and storage when solidity develops an intelligent contract in Ethernet Square". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "what is the difference between memory and storage when solidity develops an intelligent contract in Ethernet Square"!
When using solidity to develop ethernet smart contracts, you can declare the memory and storage keywords for variables. So, what's the difference between them? If you do not use the memory keyword when declaring a contract variable, Solidity tries to store the variable in storage.
What is storage?
According to Chriseth, chief engineer of Solidity, "you can think of storage as a large array that has its own structure, which is determined by the state variables in your contract, so it cannot be changed at run time."
That is, the structure of the storage is fixed when the contract deployment is created, based on the declaration of the state variable in your contract, and cannot be changed in future contract method calls. However, the content in storage can be changed through transactions. These transaction calls will therefore modify the status of the contract, which is why variables in the contract are called state variables. So a storage variable of type uint8 declared at the contract level can be changed to any valid uint8 value between 0and 255, but the position of the variable in the storage structure will never change.
Variables in a function
If you do not use the memory keyword when you declare a variable in a contract function, then solidity will try to use the storage structure, which, for now, can be compiled, but may lead to unexpected results. The memory keyword tells solidity that a space should be created for the variable while the function is running so that its size and structure meet the needs of the function.
You cannot apply the memory keyword to variables at the contract level.
At this point, I believe you have a deeper understanding of "what is the difference between memory and storage when solidity develops an intelligent contract in Ethernet Square?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.