A “solidity contract” is different from a “product” or “service” contract. What makes a solidity contract different is that it resides on the Ethereum blockchain. On the blockchain, all transactions are permanent and cannot be reversed. Once I sign the contract, I cannot back out of it and deliver the money to you because then there would be no record of the transaction on the blockchain. Also, since everything is on the blockchain, the money you give me can never be stolen by hackers. All these factors combine to make a “solidity.
A Solidity contract consists of functions, data, and states, which reside on the Ethereum blockchain at a specific address.
A “function” is simply an action or a task. For example, in the case of the solidity contract, one function of the contract is to display the current temperature in Los Angeles. Another function of the contract could be to display the date. And, another function could be to record a person’s birthdate. All these are examples of “functions.” Functions can be made as complex or as simple as required. In the previous example of the solidity contract, we had only two functions. However, if you are working on a more complex project, you could have tens or hundreds of functions in your contract.
The term “data” refers to any information that can be input into a computer. The data for the previous example of the solidity contract would be the name of the city, the name of the weather station, the date, the time, and the current temperature in that specific location.
A “state” is simply a condition or a status of something. A condition is a state-related to a specific condition or a state when it relates to one particular condition. In the previous example, the current temperature, the state of the weather at a specific location was recorded.
Classes in object-oriented languages can compare solidity contracts to classes in object-oriented languages. Every contract consists of:
1. Declarations of State Variables,
3. Function Modifiers,
6. Struct Types and
7. Enum Types.
A contract may also inherit features from another contract.
Furthermore, a special type of contract exists known as a library or an interface.