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.
- 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.
- Node.js
- npm or yarn
- Hardhat
- A Web3 wallet (e.g., MetaMask)
- Infura project for Ethereum access
-
Clone the repository:
git clone https://github.com/yourusername/pharma-supply-chain-tracker.git cd pharma-supply-chain-tracker
-
Install dependencies for backend and frontend:
cd backend
npm install
cd ../frontend
npm install
cd ../subgraph
npm install
-
Create a
.env
file in thebackend
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
-
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
-
Compile the smart contract:
npx hardhat compile
-
Deploy the smart contract to the Sepolia testnet:
npx hardhat run scripts/deploy.js --network sepolia
-
Navigate to the
backend
folder and start the server:cd backend npm start
-
Navigate to the
frontend
folder and start the React application:$env:NODE_OPTIONS = "--openssl-legacy-provider" cd frontend npm start
- Open your browser and navigate to
http://localhost:3000
to access the application. - The application will display the list of pharmaceutical batches and temperature events.
{
batches {
id
manufacturer
manufactureDate
expiryDate
status
}
}
{
temperatureEvents {
id
batchId
temperature
timestamp
}
}
{
batches(where: { manufacturer: $manufacturer }) {
id
manufacturer
manufactureDate
expiryDate
status
}
}
{
temperatureEvents(where: { batchId: $batchId }) {
id
batchId
temperature
timestamp
}
}
Link to live demo: https://medichain-preview.vercel.app