Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

Distributed Climate Monitoring Network Smart Contract

A decentralized smart contract built on the Stacks blockchain for managing a distributed network of climate monitoring stations. This contract enables users to register monitoring devices, submit weather measurements, and maintain a transparent, immutable record of climate data.

Overview

This smart contract provides a trustless infrastructure for climate data collection by allowing anyone to register monitoring stations and submit validated weather measurements. All data is stored on-chain with proper validation and access controls.

Features

  • Decentralized Station Registry: Register climate monitoring stations with geographic coordinates
  • Validated Measurements: Submit weather data with comprehensive bounds checking
  • Data Integrity: Immutable timestamp-based records of all climate measurements
  • Access Control: Station owners control their devices; admin manages system parameters
  • Multi-Monitor Support: Users can register and manage multiple monitoring stations
  • Active/Inactive Status: Deactivate stations without deleting historical data

Data Validation

All submitted measurements are validated against the following bounds:

  • Temperature: -50°C to 60°C (configurable by admin)
  • Humidity: 0% to 100%
  • Pressure: Must be greater than 0
  • Wind Speed: 0 to 500 units
  • Precipitation: 0 to 1000 units
  • Coordinates: Latitude (-90 to 90), Longitude (-180 to 180)

Public Functions

register-monitor

Register a new climate monitoring station.

Parameters:

  • name: Station identifier (1-64 ASCII characters)
  • latitude: Geographic latitude (-90 to 90)
  • longitude: Geographic longitude (-180 to 180)

Returns: Unique monitor ID

Example:

(register-monitor "Downtown Weather Station" 40 -74)

submit-measurement

Submit a climate measurement from a registered monitor.

Parameters:

  • monitor-id: The station's unique identifier
  • temperature: Temperature reading (°C)
  • humidity: Humidity percentage (0-100)
  • pressure: Atmospheric pressure
  • wind-speed: Wind speed (0-500)
  • precipitation: Precipitation amount (0-1000)

Authorization: Only the station owner or contract admin can submit readings.

Example:

(submit-measurement u0 25 65 1013 15 0)

deactivate-monitor

Deactivate a monitoring station (preserves historical data).

Parameters:

  • monitor-id: The station to deactivate

Authorization: Only the station owner can deactivate.

update-temp-thresholds

Update acceptable temperature range for validation.

Parameters:

  • min-temp: Minimum acceptable temperature
  • max-temp: Maximum acceptable temperature

Authorization: Admin only

Read-Only Functions

get-monitor

Retrieve station details by ID.

Returns: Station information including owner, name, coordinates, and status.

get-latest-measurement

Get the most recent measurement for a station.

Returns: Complete weather reading with all parameters.

get-owner-monitors

Count how many stations a principal owns.

Returns: Number of monitors registered by the owner.

is-monitor-active

Check if a monitoring station is currently active.

Returns: Boolean active status.

get-total-monitors

Get the total number of registered monitoring stations.

Returns: Total monitor count.

Error Codes

  • u100: Not authorized to perform this action
  • u101: Invalid or non-existent monitor ID
  • u102: Invalid measurement data (out of bounds)
  • u103: Duplicate monitor (already exists)
  • u104: Resource not found

System Limits

  • Maximum Monitors: 10,000 stations network-wide
  • Name Length: 64 ASCII characters maximum
  • Data Storage: All measurements stored with block-height timestamps

Security Features

  1. Bounds Validation: All inputs validated before storage
  2. Ownership Verification: Only owners can manage their stations
  3. Admin Controls: Separate admin privileges for system parameters
  4. Duplicate Prevention: Prevents duplicate station registration
  5. Existence Checks: Validates monitor IDs before operations

Use Cases

  • Community Weather Networks: Grassroots climate monitoring initiatives
  • Research Projects: Academic climate data collection
  • Agricultural Monitoring: Farm-level weather tracking
  • Urban Climate Studies: City-wide temperature and precipitation mapping
  • Environmental Compliance: Transparent environmental data reporting

Deployment

The contract is deployed on the Stacks blockchain. The deploying address becomes the admin with special privileges for managing system-wide parameters.

About

The Climate Monitoring Network is a blockchain-based contract that enables the creation and management of a decentralized network of weather monitoring stations. Built on the Stacks blockchain using Clarity, this contract provides a transparent, immutable infrastructure for collecting and storing climate data from distributed sensors worldwide.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors