In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the structure of solidity code". In daily operation, I believe many people have doubts about the structure of solidity code. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what is the structure of solidity code?" Next, please follow the editor to study!
Contract structure
1. Specify the version number of solidity.
This line means that we are preventing our program from being compiled by a compiler older than 0.4.0 ^ for upward compatibility, but cannot be compiled by a compiler of 0.5.0 or above.
We do this to minimize the risk of errors that may occur when the code is compiled in an unexpected or incompatible manner.
2. Define a contract with different methods and attributes. Describe an object from two aspects: attribute and behavior, which is an important feature of object-oriented.
3. The methods and properties of declaring variables inside the contract.
4. Define different functions and belong to different function members.
Code structure
General form of function 1
Function () {public | internal | external} [pure | constant | view | payable] [returns ()]
Function
Function modifier
Public: anyone can call this function, including the consumer of DApp.
Private: only the contract itself can call this function (in another function).
Internal: only this contract and all contracts resulting therefrom can be called a contract.
External: this function can only be called externally, but not internally by the contract.
View: it can be called freely, because it only "views" the state of the block chain without changing it.
Pure: can also be called freely, neither reading nor writing to the block chain
Payable: often used to send tokens to the contract address.
Modifier
At this point, the study of "what is the structure of solidity code" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.