Writing a simple contract
A contract is declared using the contract
keyword along with an identifier, as shown in the following code snippet:
contract SampleContract { }
Within the brackets comes the declaration of state variables and function definitions. A complete definition of contract was discussed in Chapter 3, Introducing Solidity, and I am providing it again for quick reference. This contract has state variables, struct definitions, enum declarations, function definitions, modifiers, and events. State variables, structs, and enums were discussed in detail in Chapter 4, Global Variables and Functions. Functions, modifiers, and events will be discussed in detail over the next two chapters. Take a look at the following screenshot of a code snippet depicting contract: