A Hyperledger Fabric blockchain network for managing industrial machinery maintenance in Industry 4.0 contexts. The system provides transparent maintenance workflows, immutable audit trails, and multi-organizational coordination between machine owners and maintenance service providers.
This project implements a blockchain-based maintenance management system using Hyperledger Fabric 2.5. The network consists of three organizations with distinct roles and access controls:
- OwnerMSP: Machine owners who register equipment, track operating hours, and monitor machine status
- OrdinaryMSP: Service providers handling routine scheduled maintenance
- ExtraordinaryMSP: Emergency maintenance providers responding to unexpected breakdowns
The architecture enforces strict access controls through MSP-based identity verification in the chaincode and flexible endorsement policies that allow autonomous owner operations while requiring bilateral consensus for maintenance activities.
- 1 Orderer: Consensus service using Raft ordering
- 3 Peer Organizations: Owner, Ordinary Service, Extraordinary Service
- 1 Channel:
maintenancechwith shared ledger across all organizations - Go Chaincode: Smart contract with role-based access controls
- Node.js Web Application: Query interface and transaction submission
- Automated Monitoring: Cron-based maintenance alerts with email notifications
The chaincode uses a sophisticated OR/AND endorsement policy:
OR('OwnerMSP.peer',
AND('OwnerMSP.peer', 'OrdinaryMSP.peer'),
AND('OwnerMSP.peer', 'ExtraordinaryMSP.peer'))
This allows:
- Owners to autonomously manage their machines (register, update hours, set status)
- Maintenance operations to require dual endorsement (owner + appropriate service provider)
- Privacy between competing maintenance providers (ordinary and extraordinary services)
This project requires specific versions for compatibility:
- Hyperledger Fabric: 2.5.14
- Go: 1.21.0
- Node.js: 24.13.0
- npm: 11.6.2
- Docker Desktop: 4.34.0
- Docker Compose: 2.29.2
- Postfix: 3.6.4 (for email alerts)
- Bash: 5.1.16
- jq: Latest version (auto-installed by setup script)
git clone https://github.com/Cantellos/fabric-maintenance-network.git
cd fabric-maintenance-networkThe automated setup script handles the entire network deployment:
cd network
./setup-completo.shThis script performs the following steps:
- Cleans any existing network artifacts
- Generates cryptographic materials for all organizations
- Starts Docker containers (orderer + 3 peers)
- Creates and joins channel
maintenancech - Packages and installs chaincode on all peers
- Approves and commits chaincode with endorsement policy
- Initializes ledger with sample machines
Expected completion time: 2-3 minutes.
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"You should see 4 containers running:
orderer.example.compeer0.owner.example.compeer0.ordinary.example.compeer0.extraordinary.example.com
Run the complete access control test suite:
cd network
./test-completo.shThis validates:
- Machine registration permissions (Owner-only)
- Status modification access controls
- Ordinary maintenance endorsement requirements
- Extraordinary maintenance authorization
- Endorsement policy enforcement
Expected output: 10/10 tests passed.
Individual test scenarios are available in test-singoli.sh. Each test can be run independently to verify specific access control rules.
fabric-maintenance-network/
├── chaincode/
│ └── maintenance/
│ └── go/
│ ├── maintenance.go # Smart contract implementation
│ ├── go.mod
│ └── go.sum
├── network/
│ ├── crypto-config.yaml # Certificate generation config
│ ├── configtx.yaml # Channel configuration
│ ├── docker-compose.yaml # Container orchestration
│ ├── setup-completo.sh # Automated network setup
│ ├── test-completo.sh # Automated test suite
│ ├── test-singoli.sh # Individual test scenarios
│ ├── organizations/ # Generated certificates (not in git)
│ └── channel-artifacts/ # Generated channel artifacts (not in git)
├── scripts/
│ └── lib/ # Utility scripts
├── web-app/
│ ├── app.js # Express server
│ ├── package.json
│ └── public/ # Frontend assets
├── logs/
│ └── maintenance-alerts.log # Alert system logs
├── .gitignore
├── LICENSE
└── README.md
-
RegisterMachine: Register a new machine (Owner only)
Args: [id, name, model, operatingHours, status, interventionsJSON] -
UpdateOperatingHours: Increment machine operating hours (Owner only)
Args: [id, hours] -
SetMachineStatus: Update machine status (Owner only)
Args: [id, status] // status: "funzionante" or "guasto" -
ReadMachine: Query machine details (All organizations)
Args: [id] -
GetAllMachines: List all registered machines (All organizations)
Args: []
- AddIntervention: Record maintenance intervention (Service providers + Owner endorsement)
Args: [id, type, description, technician] // type: "ordinaria" (OrdinaryMSP only) or "straordinaria" (ExtraordinaryMSP only)
-
CreateAlert: Generate maintenance alert (Owner or OrdinaryMSP)
Args: [machineId, machineName, alertType, message] -
GetAlertsByMachine: Retrieve alerts for specific machine
Args: [machineId]
The chaincode implements fine-grained access controls using Membership Service Provider (MSP) identities:
- Machine registration, status updates, and operating hours are restricted to OwnerMSP
- Ordinary maintenance interventions require OrdinaryMSP identity
- Extraordinary maintenance interventions require ExtraordinaryMSP identity
- Owner cannot unilaterally validate maintenance (prevented by chaincode logic)
The system employs two security layers:
- Chaincode Identity Verification: Prevents unauthorized function execution
- Endorsement Policy Validation: Requires appropriate peer signatures before commit
This prevents scenarios where an owner could submit and self-endorse maintenance records.
A cron-based system periodically checks machine operating hours and:
- Identifies machines requiring maintenance
- Writes alerts to blockchain
- Sends email notifications via Postfix
- Logs all activities
All transactions (machine registration, status changes, maintenance interventions, alerts) are permanently recorded on the blockchain, providing:
- Immutable maintenance history
- Timestamped intervention records
- Transparent multi-party workflows
- Regulatory compliance support
The Node.js web application provides:
- Machine query interface
- Operating hours updates
- Maintenance intervention registration
- Alert viewing
- REST API endpoints for external integration
Start the web application:
cd web-app
npm install
node app.jsAccess at http://localhost:3000
This project was developed as part of a blockchain laboratory course focusing on Industry 4.0 applications. The implementation demonstrates:
- Multi-organization Hyperledger Fabric network configuration
- Complex endorsement policies with OR/AND logic
- MSP-based identity and access management
- Chaincode development in Go with access controls
- Client application integration using fabric-network SDK
- Automated monitoring and alerting systems
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or issues, please open an issue on the GitHub repository.