# Blockchain-Based Model to Improve the Performance of the Next-Generation Digital Supply Chain
## 5 Work-Flow Analysis  
We now take the example of supplying rice from farmer to consumer. In this example, first, farmers buy seeds from the seed supplier. Then he grows seeds on his farm. After cutting the crops he will upload the cropped detail (CD) document which contains details like seed type, seed supplier and crops, etc. on the IPFS. Information related to this document will be stored on the blockchain in the form of a transaction. Then rice processor can place a buy order (BO) directly to the farmer after checking all the details of seeds and crops. After receiving the unprocessed rice, the processor processes the rice and uploads the document which contains the processing details. The distributor places a BO to the processor. After receiving the processed rice, the distributor checks for a BO from the retailer. Then the distributor ships the order to various retailers. The distributor uploads a document that contains shipment details of the order. After receiving the rice, the retailer sells the rice to the consumer. The consumer can check the complete data related to the rice from its beginning date to end date. Each entity can communicate with another entity with the help of a smart contract. This model will use the proof of authority consensus mechanism. According to this consensus, only selected nodes are given the responsibility of validating the transactions. For example, if any entity wants to upload data, then the request will be sent to the validator node to validate the transaction. The validator node will receive a notification regarding the transaction. If the validator finds it to be a legitimate transaction, then he approves the transaction. If the validator finds it to be non-authentic then he can decline the transaction. The entity-relationship diagram is shown in Figure 4.  
The sequence diagram for the proposed model is shown in Figure 5. This diagram shows the sequence of function execution during the supply chain process of rice from its origin to its delivery to the consumer. Two algorithms for communication between seed supplier, farmer, and rice processor are given below. Algorithm 1 illustrates the smart contract communication between the seed supplier and the farmer. Seed is requested from the seed supplier. If the seed sale is agreed and seed prices are paid then the seed request is granted and a notification is sent to the farmer. Otherwise, the request is rejected, and notification of the cancelled request is sent to the farmer. In Algorithm 2, smart contract communication between the farmer and the rice processor is shown. In this algorithm a similar process is followed. If the raw rice sale is agreed and the price is paid then request of the rice processor is granted or else rejected. Figure 4: Entity Relationship Diagram for the proposed model. Figure 5: Sequence Diagram for the proposed model. ```
The ID of Registered Seed Supplier, Seed Brand, Seed ID Certifying agency Farmer ID, Field ID, Chemical used, Lot ID, Quantity, purchase date 1 Contract state is buy Seed From Seed Supplier 2 State of the Farmer is Seed Requested 3 Seed Supplier state is Wait for Sell Seed To Farmer 4. Restrict access to only registered Seed Supplier 5 if Seed Sale is agreed and Seed Price paid then 6 Contract state changes to Seed Requested Agreed 7 Change State of the Farmer to Wait For Seed from Seed Supplier 8 Seed Supplier state is Sell Seed to Farmer 9 Send a notification of seed sale to the farmer 10 end 11 else 12 Contract state changes to Seed Request Failed 13 State of a farmer is Request Failed 14 Seed Supplier state is Cancel Request of Farmer 15 Send a notification stating request failure 16 end 17 else 18 Reset contract and displays an error message.