Skip to content

A decentralized supply chain tracking solution for preventing the distribution of fake Paracetamol

License

Notifications You must be signed in to change notification settings

chidubemokeke/pharma-supply-chain-tracking

Repository files navigation

Pharmaceutical Supply Chain Tracker

Overview

MediChain is a decentralized solution designed to revolutionize supply chain tracking for large-scale distribution companies. Leveraging advanced blockchain technologies, The Graph, Chainlink, and Substreams, MediChain provides a transparent, secure, and efficient way to track goods from production to delivery. This prototype gives an overview of our solution using the pharmaceutical industry and paracetamol as a use case.

Table of Contents

  1. Overview
  2. Technologies Used
  3. Getting Started
  4. Usage
  5. GraphQL Queries

Technologies Used

  • Solidity: Smart contract language for Ethereum.
  • Hardhat: Development environment for Ethereum.
  • Chainlink: Decentralized oracle network.
  • The Graph: Decentralized querying protocol.
  • Express.js: Backend server framework.
  • React: Frontend library for building user interfaces.
  • Apollo Client: GraphQL client for React.

Getting Started

Prerequisites

  • Node.js
  • npm or yarn
  • Hardhat
  • A Web3 wallet (e.g., MetaMask)
  • Infura project for Ethereum access

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/pharma-supply-chain-tracker.git
    cd pharma-supply-chain-tracker
  2. Install dependencies for backend and frontend:

   cd backend
npm install
cd ../frontend
npm install
cd ../subgraph
npm install

Configuration

  1. Create a .env file in the backend folder with the following content:

    INFURA_PROJECT_URL=https://rinkeby.infura.io/v3/your_infura_project_id
    PRIVATE_KEY=your_private_key
    CONTRACT_ADDRESS=your_contract_address
    PORT=3000
    
  2. Create a .env file in the frontend folder with the following content:

REACT_APP_SUBGRAPH_URL=https://api.thegraph.com/subgraphs/name/yourusername/medi-chain

Deploying the Smart Contract

  1. Compile the smart contract:

    npx hardhat compile
  2. Deploy the smart contract to the Sepolia testnet:

    npx hardhat run scripts/deploy.js --network sepolia
    

Running the Backend Server

  1. Navigate to the backend folder and start the server:

    cd backend
    npm start

Running the Frontend Application

  1. Navigate to the frontend folder and start the React application:

    $env:NODE_OPTIONS = "--openssl-legacy-provider"
    cd frontend
    npm start

Usage

  1. Open your browser and navigate to http://localhost:3000 to access the application.
  2. The application will display the list of pharmaceutical batches and temperature events.

GraphQL Queries

Example Queries

Get Batches

{
  batches {
    id
    manufacturer
    manufactureDate
    expiryDate
    status
  }
}

Get Temperature Events

{
  temperatureEvents {
    id
    batchId
    temperature
    timestamp
  }
}

Get Batches By Manufacturer

{
  batches(where: { manufacturer: $manufacturer }) {
    id
    manufacturer
    manufactureDate
    expiryDate
    status
  }
}

Get Temperature Events By Batch ID

{
  temperatureEvents(where: { batchId: $batchId }) {
    id
    batchId
    temperature
    timestamp
  }
}

Demo

Link to live demo: https://medichain-preview.vercel.app

About

A decentralized supply chain tracking solution for preventing the distribution of fake Paracetamol

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •