Skip to content

The contract enables vehicle owners to register their vehicles using VIN numbers and maintain a complete, verifiable service history. Each vehicle is assigned a unique ID and linked to its owner's blockchain address. Owners can add detailed maintenance records including service type, mileage, costs, descriptions, and service provider information.

Notifications You must be signed in to change notification settings

seun-ola/Vehicle-Maintenance-Tracking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Vehicle Maintenance Tracking Smart Contract

A decentralized vehicle maintenance tracking system built on the Stacks blockchain using Clarity. This contract provides an immutable, transparent ledger for vehicle ownership and service history.

Overview

This smart contract enables vehicle owners to register their vehicles and maintain a complete, verifiable service history on the blockchain. It creates a tamper-proof record of all maintenance activities, ownership transfers, and service schedules that can be independently verified while maintaining proper access controls.

Key Features

Vehicle Management

  • Register Vehicles: Add vehicles with VIN, make, model, year, and current mileage
  • Transfer Ownership: Securely transfer vehicles between blockchain addresses
  • Activate/Deactivate: Control vehicle status for operational management
  • Multi-Vehicle Support: Track unlimited vehicles per owner

Maintenance Tracking

  • Service Records: Log detailed maintenance with service type, cost, and descriptions
  • Mileage Tracking: Automatic mileage updates with fraud prevention (mileage can only increase)
  • Service Scheduling: Track when next service is due based on mileage
  • Provider Records: Link maintenance to specific service provider addresses
  • Complete History: Immutable audit trail of all service activities

Access Control

  • Owner Permissions: Only vehicle owners can modify their vehicle data
  • Authorized Mechanics: Contract owner can authorize trusted service providers
  • Two-Tier Security: Separate permissions for owners and mechanics
  • Transfer Protection: Prevents invalid ownership transfers

Data Integrity

  • VIN Validation: Enforces 17-character VIN format
  • Year Validation: Accepts years between 1900-2100
  • Mileage Verification: Prevents odometer rollback fraud
  • Input Sanitization: Comprehensive bounds checking on all inputs
  • String Length Limits: Prevents storage abuse

Technical Specifications

  • Language: Clarity
  • Blockchain: Stacks
  • Lines of Code: 285
  • Gas Optimized: Uses maps for O(1) lookups
  • Zero Warnings: Passes Clarity static analysis

Quick Start

1. Deploy the Contract

```bash clarinet contract deploy vehicle-maintenance ```

2. Register a Vehicle

(contract-call? .vehicle-maintenance register-vehicle
  "1HGBH41JXMN109186"  ;; VIN (17 characters)
  "Honda"               ;; Make
  "Accord"              ;; Model
  u2020                 ;; Year
  u50000                ;; Current mileage
)
;; Returns: (ok u1) - Vehicle ID

About

The contract enables vehicle owners to register their vehicles using VIN numbers and maintain a complete, verifiable service history. Each vehicle is assigned a unique ID and linked to its owner's blockchain address. Owners can add detailed maintenance records including service type, mileage, costs, descriptions, and service provider information.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published