# A Cloud Microservices Architecture for Data Integrity Verifiability Based on Blockchain
## 7 Case Study: An Avocado Cloud System
### The Data Integrity Storing Process in the Experimental System  
The transaction users interact at different stages with the avocados and every interaction records information to provide traceability. Then, the system can monitor the avocados from each stage. Figure 7 illustrates a sequence diagram that, at the top, shows the operations, at the bottom the created user's type, at the center the smart contracts created after the operations and at the right part (last column) the resources generated.  
The smart contracts in the figure are represented with a rectangle split in three parts: at the top with its name; in the middle with two parts: the smart contract used to create the new smart contract and the user key; at the bottom the address of such smart contract. The figure also states a tree smart contract instance from the root creation until the generation of users resources, the general steps are as follows:  
* _Root creation:_ following the protocol in [36] the Root user is created with key \(K_{r}^{+}\). \(A_{sc}\) is the smart contract address generated in the blockchain; and \(A_{scb1}\) is the Root's Bitacora.
* _Administrators creation:_ root, through smart contract \(A_{sc}\), executes method \(addAdnor(A_{sc},K_{an}^{+})\) to create two administrators (\(Admor1\) and \(Admor2\)); \(K_{an}^{+}\) in this case are \(K_{an}^{+}\) and \(K_{an}^{+}\); and the smart contracts generated are \(A_{sc1}\) and \(A_{sc2}\) respectively. Their smart contracts Bitacoras are \(A_{scb2}\) and \(A_{scb3}\)
* _TUsers creation:_ the explanation of creating a TUser by an administrator is similar to that explained by the root creating administrators. In this case \(Admor1\) creates a \(Farmer\) and a \(Packer\) user; and \(Admor2\) creates a \(Carrier\) and a \(Merchant\) user.
* _Resources creation:_ resources are added via a TUser by executing method \(addResource(string)\). The figure shows resources created with addresses from \(A_{sc7}\) to \(A_{sc10}\). These resources will be used to manage harvests. For example, \(Farmer\) will register new hashed data of the harvest in the blockchain to start the traceability; \(Carriers\) will register the harvest transportation from one part to another; \(Packer\) will create a new harvest batch with the information reported by the \(Farmer\) and will carry out the selection procedures; \(Merchant\) will register data information about when the lot was received and when it is sent to the wholesalers, retailers or ready to be sell for the consumers. In each stage, a QR code is generated, containing the transaction address generated in each stage. The QR code might be used by the \(consumer\) or any user of each stage of the supply chain to obtain the traceability and verify the origin of the avocado.  
Figure 8 shows a dummy representation of the smart contracts executed in Figure 7. Note that each block contains three transactions represented by each of the smart contracts. This figure will be related with the below explanation of Figure 9 in the next subsection.  
Figure 7: Sequence diagram: stating an execution tree operations of the avocado supply chain with their smart contracts.