Skip to content

bright-beep/BTC-CarbonX

Repository files navigation

BTC-CarbonX: Bitcoin-Powered Carbon Credit Exchange

Overview

BTC-CarbonX is a revolutionary carbon credit exchange platform built on Stacks Layer 2, leveraging Bitcoin's security and scalability. The platform enables secure, transparent, and cost-effective trading of carbon offset credits with real-time validation and automated compliance.

Features

  • Decentralized Credit Management

    • Create and list carbon offset credits
    • Transparent validation process
    • Automated compliance checks
    • Real-time credit status tracking
  • Secure Trading System

    • Peer-to-peer credit transfers
    • Built-in platform fees (default 2.5%)
    • Automated STX settlement
    • Credit retirement functionality
  • Validator Framework

    • Reputation-based validator system
    • Transparent validation process
    • Automated validator management
    • Reputation scoring (0-100)

Smart Contract Functions

Credit Management

create-credit

Creates a new carbon offset credit listing.

(create-credit amount price metadata)
  • amount: Total credits available
  • price: Price per credit in STX
  • metadata: Credit details and certification info

validate-credit

Validates a credit listing by an authorized validator.

(validate-credit credit-id validator-id new-status)
  • credit-id: Unique identifier of the credit
  • validator-id: Validator's unique identifier
  • new-status: Updated validation status

buy-credit

Purchases carbon offset credits.

(buy-credit credit-id amount)
  • credit-id: Credit listing identifier
  • amount: Number of credits to purchase

Credit Operations

transfer-credits

Transfers credits between users.

(transfer-credits recipient amount)
  • recipient: Recipient's principal
  • amount: Number of credits to transfer

retire-credits

Permanently retires carbon credits.

(retire-credits amount)
  • amount: Number of credits to retire

Validator Management

add-validator

Registers a new validator.

(add-validator name)
  • name: Validator's name

update-validator-reputation

Updates a validator's reputation score.

(update-validator-reputation validator-id new-reputation)
  • validator-id: Validator's identifier
  • new-reputation: New reputation score (0-100)

Platform Management

update-platform-fee

Updates the platform fee percentage.

(update-platform-fee new-fee)
  • new-fee: New fee percentage (0-100)

Read-Only Functions

  • get-credit: Retrieves credit details
  • get-balance: Checks user's credit balance
  • get-validator: Retrieves validator information

Error Handling

The contract includes comprehensive error handling:

  • err-owner-only: Unauthorized owner access
  • err-not-found: Resource not found
  • err-unauthorized: Unauthorized operation
  • err-invalid-amount: Invalid amount specified
  • err-insufficient-balance: Insufficient funds/credits
  • err-credit-not-available: Credits unavailable
  • err-invalid-status: Invalid credit status
  • err-transfer-failed: Transfer operation failed

Security Features

  1. Access Control

    • Owner-only functions for platform management
    • Validator authentication for credit validation
    • Secure transfer mechanisms
  2. Transaction Safety

    • Balance checks before transfers
    • Atomic transactions
    • Status validation
    • Amount validation
  3. Platform Integrity

    • Reputation-based validator system
    • Transparent fee structure
    • Immutable transaction history

Technical Details

  • Built on Stacks Layer 2
  • Leverages Bitcoin's security
  • Uses STX for settlements
  • Implements Clarity smart contract language
  • Supports high-throughput transactions

Platform Fees

  • Default fee: 2.5% (25 basis points)
  • Fees are calculated and processed automatically
  • Fees are paid by sellers
  • Owner can adjust fees (0-10% range)

Credit States

Credits can exist in the following states:

  • pending: Newly created, awaiting validation
  • validated: Verified and available for trading
  • Other states as defined by validators

Best Practices

  1. For Credit Creators

    • Provide detailed metadata
    • Set reasonable prices
    • Ensure sufficient documentation
  2. For Buyers

    • Verify credit validation status
    • Check validator reputation
    • Review credit metadata
  3. For Validators

    • Maintain high reputation scores
    • Follow validation guidelines
    • Provide clear status updates

Integration Guide

Reading Credit Data

;; Get credit details
(get-credit credit-id)

;; Check user balance
(get-balance user-principal)

Creating and Trading Credits

;; Create new credits
(create-credit u100 u1000 "Carbon credits from forest conservation project")

;; Buy credits
(buy-credit u1 u10)

Validator Operations

;; Add new validator
(add-validator "Eco Certification Corp")

;; Update reputation
(update-validator-reputation u1 u95)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors