Skip to content

FrancescoCastaldi/HospitalSanitizationTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

52 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ HospitalSanitizationTracker

A blockchain-based DApp for traceability of hospital sanitization activities

CI Solidity Hardhat Node Network Tests License: MIT Etherscan

Project for the Blockchain and Cryptocurrencies course – University of Bologna
Proposal 7 – DLTs for Traceability in Supply Chain (AnaNSi Research Group)


Table of Contents

  1. Description
  2. Tech Stack
  3. Architecture & Project Structure
  4. Smart Contract – Features
  5. Frontend DApp – Features
  6. Installation & Usage
  7. Deployed Contract
  8. Author

Description

An Ethereum smart contract-based system that allows authorized operators to register and certify sanitization operations of hospital areas.

Every event is recorded immutably on the blockchain and can be queried at any time, guaranteeing transparency and non-repudiation of data.


Tech Stack

Technology Version Role
Solidity 0.8.20 Smart contract language
Hardhat 2.28.0 Development / test / deploy framework
Ethers.js v6 Contract interaction from frontend
Node.js v22 JavaScript runtime
Infura – RPC Provider (Sepolia)
MetaMask – Wallet for transaction signing
Ethereum Sepolia Testnet Deployment network

Architecture & Project Structure

HospitalSanitizationTracker/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml                       # GitHub Actions CI pipeline
β”œβ”€β”€ contracts/
β”‚   └── SanitizationTracker.sol          # Main smart contract
β”œβ”€β”€ scripts/
β”‚   └── deploy.js                        # Local deploy script
β”œβ”€β”€ ignition/
β”‚   └── modules/
β”‚       └── SanitizationTracker.js       # Hardhat Ignition module (testnet deploy)
β”œβ”€β”€ test/
β”‚   └── SanitizationTracker.test.js      # Test suite (14/14)
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html                       # DApp web interface
β”‚   β”œβ”€β”€ app.js                           # DApp logic + contract interaction
β”‚   └── style.css                        # Styles
β”œβ”€β”€ Photos/
β”‚   └── logo.png
β”œβ”€β”€ artifacts/                           # Compilation output (gitignored)
β”œβ”€β”€ cache/                               # Hardhat cache (gitignored)
β”œβ”€β”€ hardhat.config.js
β”œβ”€β”€ package.json
β”œβ”€β”€ .env.example                         # Environment variables template
└── .gitignore

Smart Contract – Features

The SanitizationTracker.sol contract implements the following:

Data Structures

Struct Main Fields
Area id, name, active, exists
Operator wallet, name, active, exists
SanitizationEvent areaId, operatorAddress, timestamp, outcome, notes

Main Functions

Function Access Description
registerArea(id, name) onlyAdmin Register a new area
setAreaActive(id, active) onlyAdmin Enable/disable an area
registerOperator(wallet, name) onlyAdmin Register a new operator
setOperatorActive(wallet, active) onlyAdmin Enable/disable an operator
sanitize(areaId, outcome, notes) onlyActiveOperator Record a sanitization event
getAreaEvents(areaId) public Returns full event history
getLastSanitization(areaId) public Returns last event
getEventCount(areaId) public Returns event count

Access Modifiers

  • onlyAdmin β†’ deployer address only
  • onlyActiveOperator β†’ registered and active operators only

On-Chain Events

  • AreaRegistered(id, name)
  • OperatorRegistered(wallet, name)
  • AreaSanitized(areaId, operator, timestamp, outcome)

Frontend DApp – Features

The frontend/ folder contains a full web DApp that connects to the contract via MetaMask.

Roles

Role Description
Admin Deployer account; can register areas and operators
Operator Account registered by admin; can record sanitizations
Guest Unrecognized account; read-only access

The DApp automatically detects the role by reading the admin address and the operators mapping directly from the contract.

Interface Sections

# Section Required Role Function
1 Header – MetaMask connection, connected address, detected role
2 Register Area Admin Register a new area (ID + Name)
3 Register Operator Admin Register an operator (Wallet Address + Name)
4 Record Sanitization Operator Record event (Area ID, Outcome, Notes)
5 Area Status All Display area data + last sanitization
6 Area Events All Full event history for an area

Installation & Usage

Prerequisites

  • Node.js v22+
  • MetaMask installed in the browser
  • Sepolia account with test ETH (Sepolia Faucet)

Setup

git clone https://github.com/FrancescoCastaldi/HospitalSanitizationTracker.git
cd HospitalSanitizationTracker
npm install
cp .env.example .env
# Edit .env with your INFURA_API_KEY and PRIVATE_KEY

Commands

# Compile the contract
npx hardhat compile

# Run tests
npx hardhat test

# Deploy to Sepolia (Hardhat Ignition)
npx hardhat ignition deploy ignition/modules/SanitizationTracker.js --network sepolia

Start Frontend

npx serve frontend
# or use the "Live Server" extension in VS Code

Open the browser at http://localhost:3000 and select the Sepolia network in MetaMask.

Typical Usage Flow

1. Connect with Admin account (deployer)
   β””β†’ Register an area  (e.g. ID=101, Name="Operating Room")
   β””β†’ Register an operator (wallet of 2nd MetaMask account)

2. Switch account in MetaMask β†’ Operator
   β””β†’ Record a sanitization (Area 101, Outcome: OK, Notes: ...)

3. With any account
   β””β†’ Check Area Status and Area Events to verify the history

Deployed Contract

Field Value
Network Ethereum Sepolia Testnet
Address 0x679C6625f9479cf3b711F7a246C8F7a6655E4517
Deploy Date February 21, 2026
Etherscan View on Sepolia Etherscan

Author

Francesco Castaldi
University of Bologna – Blockchain and Cryptocurrencies Course

GitHub


Project developed for academic purposes

About

DApp for tracing sanitization activities in hospitals using blockchain technology - Project for Blockchain and Cryptocurrencies course

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors