A blockchain-based DApp for traceability of hospital sanitization activities
Project for the Blockchain and Cryptocurrencies course β University of Bologna
Proposal 7 β DLTs for Traceability in Supply Chain (AnaNSi Research Group)
- Description
- Tech Stack
- Architecture & Project Structure
- Smart Contract β Features
- Frontend DApp β Features
- Installation & Usage
- Deployed Contract
- Author
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.
| 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 |
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
The SanitizationTracker.sol contract implements the following:
| Struct | Main Fields |
|---|---|
Area |
id, name, active, exists |
Operator |
wallet, name, active, exists |
SanitizationEvent |
areaId, operatorAddress, timestamp, outcome, notes |
| 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 |
onlyAdminβ deployer address onlyonlyActiveOperatorβ registered and active operators only
AreaRegistered(id, name)OperatorRegistered(wallet, name)AreaSanitized(areaId, operator, timestamp, outcome)
The frontend/ folder contains a full web DApp that connects to the contract via MetaMask.
| 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
adminaddress and theoperatorsmapping directly from the contract.
| # | 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 |
- Node.js v22+
- MetaMask installed in the browser
- Sepolia account with test ETH (Sepolia Faucet)
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# 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 sepolianpx serve frontend
# or use the "Live Server" extension in VS CodeOpen the browser at http://localhost:3000 and select the Sepolia network in MetaMask.
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
| Field | Value |
|---|---|
| Network | Ethereum Sepolia Testnet |
| Address | 0x679C6625f9479cf3b711F7a246C8F7a6655E4517 |
| Deploy Date | February 21, 2026 |
| Etherscan | View on Sepolia Etherscan |
Francesco Castaldi
University of Bologna β Blockchain and Cryptocurrencies Course
Project developed for academic purposes