Hackernoon logoEnsuring Food Quality with Blockchain by@Aman

Ensuring Food Quality with Blockchain

Aman Ali Hacker Noon profile picture

Aman Ali

We buy groceries on a weekly basis from stores near our home. We often prefer buying from popular superstores than small shops. This happens because we trust the bigger established brands more than the new entrants in the market.

The bias is logically flawed because none of the stores manufactures what it sells. They just purchase it from the distributors, add the price tag and sell it. We cannot be certain that the stock we buy is unadulterated. It is unfortunate that sometimes there is no check for the food being expired.

For example, few days ago I had purchased “Frozen Chicken Wings” from a famous store near my apartment. Upon taking a bite (after microwaving it), the meat was sticky. I had to throw the whole dish. I should consider myself really lucky that the food did not damage my health.

Consuming food with synthetic substances and preservatives is unhealthy. Such food will damage your immune system and make you vulnerable. Consumption of such commodities over a long period of time can have an impact on the children of the next generation.

In this article, I intend to solve this problem.


Process Description

  1. From the raw materials to the final product, our food changes so many hands.
  2. Let me call these Agencies as A1, A2, A3… and so on. Each Agency will have its unique digital signature which is represented by S1, S2, S3… and so on.
  3. While the food is changing hands there will be two QR codes that would be printed on the packaging that contains the food/intermediate product. The first QR code, Q1, will contain the signature of the agent who just finished his task on the product. And the second QR code, Q2, generated with a function which taken input as the cumulative sum of the signature of current agent and all the previous agents in the supply chain. For example, when the agent A6 completes his job, the second QR code will have the signature as sig(A1+A2+A3+A4+A5+A6). Where sig() is the signature function. All this information will be saved on a Blockchain. Blockchains are tamper resistant and will be helpful to enforce the rules on this food supply chain.
  4. After A1 does his job on a batch of shipment. Q1 = sig(A1) and Q2 = sig(A1).
  5. Now when A2 receives this batch from A1, he will verify the Q1 and Q2 with the help of a scanner. This scanner will retrieve data from the blockchain and check the integrity of the shipment. If the data doesn’t match with the blockchain, then the shipped batch is discarded. After confirming its authenticity, A2 will do the required changes on this shipment. Now the values of Q1 and Q2 are Q1=sig(A1) and Q2 = sig(A1+A2).
  6. And the process continues. When it reaches the final agent “AL”, only one QR code Q will be attached to the final food product. Q is defined as : Q = sig(A1+A2+A3 …+AL+Batch_Number+Expiry_Date), where batch number and expiry date is with respect to the particular batch of food.
  7. This is now shipped to Stores M1, M2, M3 …and so on.
  8. As a customer, we will be scanning the food product’s QR code “Q”. If the “current” system time is more than the date of expiry, there will be a mismatch with the data stored on the blockchain. There will be an output on the machine saying that the food product has expired. We can then select another piece of the same product. By this, the quality of the food is never compromised.

Protection From Bad Actors

There is a good chance for an agent to go selfish and add impurities to the shipment. I intend to avoid this by giving incentive points to the agent after completion of every batch. If the agent goes selfish and the batch is rejected because of him(we will know this when the next agent in the chain rejects this batch), the blockchain decreases some points. This process can be automated with the help of Autonomous Smart Contracts. These incentive points can be used as a metric to get further contracts with other agencies in other food supply chains.

We will also ensure that the stores will play fair. Every time the consumer detects an expired food product, there will be some decrease in the points of the store(Because the store should have removed that batch from the aisle). Points of these stores can be accessed by the public. This will make us trust even the new entrants thus democratizing the market.

Hence, both the agents/agencies and stores will be working towards the benefit of the network.


  1. This ecosystem can be offered as “blockchain as a service” with the help of cloud.
  2. Agents and Stores can participate in this ecosystem by paying a fee. This fee is required for maintaining the cloud architecture.
  3. A website that will display the incentive points of agents and stores. This will help “stores to trust the agents” and “customers to trust the stores”.
  4. For sake of simplicity, a cross-platform mobile app can also be developed so that the track record of the stores can be checked on the fly.

This will help us have an open market where the quality of the food consumed is never compromised.

The following quote motivated me to write this article:

“Blockchains combine the openness of democracy and the Internet with the merit of markets.”~Naval Ravikant

Thank you for reading my article.

This article comes under research work done at Wright State University’s SMART Lab under the guidance of Dr. Yong Pei.

Wright State University: https://www.wright.edu/ 
Department of Computer Science and Engineering : https://www.wright.edu/degrees-and-programs/profile/computer-science 
Dr. Yong Pei : https://people.wright.edu/yong.pei

If you have any questions, please feel free to send me an email. You can also contact me via Linkedin. You can also follow me on Twitter.

In order to get started with Blockchain read my article published on Hackernoon.


Join Hacker Noon

Create your free account to unlock your custom reading experience.