Chapter 15: Solidity Design Patterns
Solidity is a contract-based language. You might wonder what a language has to do with entity modeling. On the face of it, it does not sound right; however, after security, entity modeling is probably one of the most important activities for writing smart contracts. But why is entity modeling an important exercise for smart contracts? To understand this question, we must understand the purpose of smart contracts. Smart contracts comprise two important facets:
- Entities
- Logic
Data stored in smart contracts is stored permanently within Ethereum storage. The use of storage comes with the cost of reading and writing to it. It is for this reason that it is very important to store optimal data that is necessary for the functioning of the smart contract and use case. In this chapter, we will understand how entities should be modeled for smart contracts, the different data types used for storing data, the read and write patterns, the redundancy...