Smart contract - I4ET-Group3/I4ET-Group-4 GitHub Wiki

Overview

Monitoring.sol is a smart contract designed to support a Hybrid Propulsion Management and Health Monitoring System by logging sensor events such as fire alerts, smoke levels, and system warnings onto the blockchain. It provides a tamper-proof and transparent record of onboard events for audit, validation, and system diagnostics.


Features

  • ๐Ÿ”ฅ Fire detection logging
  • ๐Ÿ’จ Smoke level recording
  • ๐Ÿ•’ Timestamped event history
  • ๐Ÿ‘ค Access control via ownership
  • ๐Ÿ“œ Event emission for off-chain system tracking

Functions

logEvent(string memory _message)

Records a new system event.

  • Input: _message โ€“ Description of the event (e.g., "Fire detected!", "RPM spike").
  • Action: Stores the event message with the current block timestamp.
  • Access: Public

getEvent(uint _index)

Retrieves a specific event by its index.

  • Input: _index โ€“ Index of the stored event
  • Returns: (string message, uint timestamp)

getEventCount()

Returns the total number of events logged.

  • Returns: uint โ€“ Number of events stored

Access Control

  • The contract uses OpenZeppelinโ€™s Ownable or a custom owner modifier (depending on the actual implementation in the .sol file) to restrict admin-level changes.

Example Usage

Monitoring monitor = new Monitoring();
monitor.logEvent("FIRE detected at engine room!");
(uint count) = monitor.getEventCount();
(string memory msg, uint time) = monitor.getEvent(count - 1);

Off-Chain Integration

This smart contract can be connected to external systems via:

  • Oracles
  • IoT event bridges
  • Dashboard webhooks (e.g., using Web3.js or Ethers.js to call logEvent())

Security Notes

  • Validate any external system inputs before logging.
  • Rate-limit logging externally to prevent blockchain bloat.

Future Improvements

  • Add role-based access (engineers, inspectors)
  • Introduce event types/enums instead of freeform strings
  • Support for external log validation via signatures