Anti-Counterfeit Product Identification System using Blockchain (full code available + live demo)

Lo Yen Xuan
4 min readFeb 21, 2024
Photo by Shubham Dhage on Unsplash

Combating counterfeit products is always a global concern for manufacturers, suppliers, and consumers alike. Fortunately, innovative technologies like blockchain offer a promising solution by providing enhanced transparency, traceability, and security throughout the supply chain. In this article, we’ll explore a practical approach to building an anti-counterfeiting product identification system using blockchain.

The Concept: Leveraging Blockchain for Product Authentication

At its core, the application harnesses the immutable nature of blockchain to create an tamper-proof record of a product’s journey from manufacturer to consumer. By utilizing blockchain technology, we ensure that the data stored within it remains tamper-proof, serving as a solid evidence of a product’s authenticity.

Operational Workflow: How It Works

System Model Diagram

The system involves five main entities: administrator, manufacturer, supplier, retailer, and consumers. Each user has different access privileges in our system based on role-based access control.

1) Administrator

The administrator holds the highest level of privilege and is the only role responsible for account creation and modification to ensure that all accounts are verified.

2) Manufacturer

Manufacturers act as first point of contact of products and are responsible to register and add a product to the blockchain. Once the block containing product information is added to the blockchain, the system generates a QR code to be pasted onto the product.

3) Supplier (Intermediaries)

The product is expected to pass through multiple intermediaries which are represented by the supplier role in our system. Suppliers have the privilege of updating the product information which is automatically captured by our system to the blockchain.

4) Retailer

The retailer represents the final point of contact for a product before it is sold to a customer. Retailers have privileges similar to those of suppliers, with the additional privilege to update the status of a product to reflect whether it has been sold.

5) Consumers

Consumers do not hold accounts in our system. Instead, they can directly use our system’s QR scanner to scan the QR code of the product to determine its authenticity.

System Workflow

Combating Counterfeiting: Key Features

Our system incorporates several features designed to thwart counterfeit attempts:

  • Duplicate QR Code Detection: Consumers can verify a product’s authenticity by comparing its history on the blockchain. Discrepancies, such as conflicting location data, serve as red flags for potential counterfeits. For instance, if an authorised retailer logs a product’s location as Retailer Shop ABC but a customer scans its QR code at Retailer Shop XYZ, they will know that it is counterfeit. This feature discourages unauthorized retailers from duplicating QR codes since doing so would not be sufficient to show that their counterfeit products are authentic.
  • Incentive for Authenticity: Authorized retailers are incentivized to uphold authenticity, as duplicating QR codes provides no advantage. By maintaining accurate records on the blockchain, they build trust with consumers and safeguard their reputation.

Technical Implementation

Now, let’s discuss the technical aspects of developing our anti-counterfeiting solution:

System Architecture
  1. Smart Contract Development: Using platforms like Hardhat, Foundry, or Truffle, we write our business logic in Solidity. Our smart contract contains functions for registering products, updating their history, and retrieving data from the blockchain.
  2. Deployment on Ethereum Testnet: To mitigate costs, we deploy our smart contract on the Ethereum Testnet, such as Sepolia. This allows for seamless testing and development without incurring expenses associated with the Mainnet.
  3. Client-side Application: Using React, we develop a user-friendly interface for interacting with the blockchain. Through tools like ethers.js, users can access and manage their transactions on the Sepolia Testnet, ensuring a seamless experience.

Results: Simulating Real-world Scenario

Suppose we have the following product:

Serial Number: c12345

Name: Classic Handbag

Brand: Chanel

Description: Lambskin, Black

The manufacturer logs this information into the system and registers the product on the blockchain and a QR code is generated for the particular product. Next, CK Supplier receives the product and logs into the system to scan the QR code. They update the product information with their personal details, current location, and timestamp. This process is repeated when RE Retailer receives the product. Lastly, when a customer purchases the product, RE Retailer updates the product’s status.

If a customer scans the QR code of the product after purchasing it from RE Retailer, they will see these results:

Or else,

Full code can be obtained on my github: https://github.com/yenxuan1381/anti-counterfeit-product-identification-system-using-blockchain

A complete live demo of the project is also available on YouTube:

If you like my project, give me a star on GitHub 😁

Cheers!

--

--

Lo Yen Xuan

Top CS Graduate | MSc Fintech | Blockchain Enthusiast | Cybersecurity