Skip to content

Shivamd0608/GreenXAi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

99 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌿 GreenAiDEX

GreenAiDEX is an on-chain platform for registering, tokenizing, and trading real-world environmental credits in a transparent, secure, and accessible way.

The platform supports four types of environmental credits:

  • 🌱 Green Credits
  • πŸ’§ Water Conservation Credits
  • 🌍 Carbon Credits
  • ⚑ Renewable Energy Credits

GreenAiDEX enables verified environmental projects to convert these credits into ERC-1155 crypto assets, trade them directly using stablecoin settlement, and optionally make them DeFi-compatible by wrapping them into ERC-20 tokens tradable via a Uniswap V2–style AMM.

GreenAiDEX is designed to make green credit markets more efficient, accessible, and trustable for both small sustainability projects and large organizations.


🌍 Problem Statement

Traditional green credit markets face major structural limitations:

  • Centralized registries with low transparency
  • Manual verification and settlement
  • High entry barriers for small companies
  • Poor liquidity and inefficient price discovery
  • Limited global accessibility

As a result, green credits remain illiquid, opaque, and difficult to trade, reducing their real-world environmental impact.


βœ… GreenAiDEX Solution

GreenAiDEX moves the entire green credit lifecycle on-chain, removing intermediaries and enabling open participation.

Core Benefits

  • Transparency – Credit issuance, supply, and retirement are publicly verifiable
  • Accessibility – Anyone can buy or sell credits on-chain
  • Liquidity – Credits can be traded instantly or via DeFi pools
  • Trust – Smart contracts enforce rules instead of centralized entities
  • Low Cost – Built on Mantle L2 for fast, low-fee transactions

πŸ”„ End-to-End Credit Lifecycle

Real-World Environmental Credit
↓
On-chain Registration
↓
ERC-1155 Credit Token
↓
Buy / Sell via Orderbook
↓
(Optional) ERC-20 Wrapping
↓
AMM Trading (Uniswap-style)
↓
Retirement (On-chain Burn)

Each credit has full on-chain traceability from issuance to retirement.


πŸ— System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Frontend                                  β”‚
β”‚  Next.js + Ethers.js + TailwindCSS         β”‚
β”‚  - Credit Registry UI                      β”‚
β”‚  - Buy / Sell Credits                      β”‚
β”‚  - Wrap / Unwrap Tokens                    β”‚
β”‚  - Liquidity & Swap Interface              β”‚
β”‚  - AI Chat Assistant                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  AI Backend                                β”‚
β”‚  - User guidance logic                     β”‚
β”‚  - Confidence score calculation            β”‚
β”‚  - Read-only blockchain access             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Mantle Sepolia (L2)                       β”‚
β”‚                                            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ ERC-1155 Credits ────────┐  β”‚
β”‚  β”‚  GreenCreditToken                    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                    β–Ό                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ ERC-20 Wrappers ─────────┐  β”‚
β”‚  β”‚  Wrapper Factory + Wrappers          β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                    β–Ό                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ AMM (Uniswap V2) ────────┐  β”‚
β”‚  β”‚  Factory β€’ Pair β€’ Router             β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                    β–Ό                       β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ Orderbook ───────────────┐  β”‚
β”‚  β”‚  Stablecoin-settled credit trades    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧩 Full System Workflow

GreenAiDEX Workflow

πŸ” AMM vs Orderbook in GreenXchange

GreenAiDEX uses both an Orderbook and an AMM to support different trading needs.

πŸ“Š Comparison Table

Feature Orderbook (ERC-1155) AMM (ERC-20 Wrapped)
Token type Direct ERC-1155 credits ERC-20 wrapped credits
Trading model Fixed-price, peer-to-peer Automated (x Β· y = k)
Liquidity requirement No pooled liquidity Requires liquidity providers
Price impact No slippage Slippage based on pool size
Execution Match-based Instant swap
Transaction size Best for large trades Best for small trades

🧠 Why both are used

  • Orderbook

    • Preserves native ERC-1155 credit structure
    • Ideal for bulk and institutional trades
    • Predictable pricing (no slippage)
  • AMM

    • Enables DeFi composability via ERC-20
    • Instant execution for retail users
    • Always-on liquidity pools

Together, they balance precision trading and liquidity-driven trading.


🧠 AI Assistant Layer

GreenAiDEX integrates an AI-powered assistant to improve usability and reduce user errors.

AI Capabilities

  • In-app chat guidance
  • Step-by-step help for:
    • Credit registration & minting
    • Buying / selling credits
    • Token approvals
    • ERC-1155 ↔ ERC-20 wrapping
    • Liquidity provision & swaps
  • Clear explanations of failed transactions
  • Risk-aware insights using on-chain data

⚠️ The AI operates in read-only mode and never executes transactions.


πŸ“Š Swap Confidence Score

Before executing a swap, users are shown a Confidence Score (0–100) calculated from:

  • Liquidity depth
  • Trade size vs pool reserves
  • Expected price impact
  • User slippage tolerance

Example:

Confidence Score: 76 / 100 Liquidity: Strong Price Impact: Moderate Slippage Risk: Low

This helps users understand trade quality before execution.


🧱 Core Protocol Components

1️⃣ Green Credit Registry (ERC-1155)

Purpose: Tokenize verified environmental credits.

  • ERC-1155 multi-token standard
  • Credit registration & verification
  • Supply and retirement tracking
  • Freeze & revoke mechanisms
  • Acts as the source of truth

2️⃣ ERC-1155 β†’ ERC-20 Wrapper Layer

Purpose: Enable DeFi compatibility.

  • One wrapper per credit type
  • Fully collateralized 1:1 backing
  • Reentrancy-safe mint & burn
  • Credit status validation

3️⃣ AMM Layer (Uniswap V2 Style)

Purpose: Permissionless liquidity & swaps.

  • Factory β€’ Pair β€’ Router architecture
  • Constant product formula (x * y = k)
  • 0.3% LP fee
  • Slippage & deadline protection

4️⃣ Orderbook (Stablecoin Settlement)

Purpose: Fixed-price trading of credits.

  • On-chain escrow
  • Access-controlled actions
  • Pausable & reentrancy-safe
  • Supports direct ERC-1155 trades

πŸ’΅ Stablecoin & Faucet System

  • Uses Mock USDC (mUSDC)
  • Faucet available on frontend
  • Enables realistic testing
  • Smooth onboarding for new users

βš™οΈ Technology Stack

Smart Contracts

  • Solidity ^0.8.20
  • OpenZeppelin libraries
  • ERC-1155 & ERC-20 standards
  • Uniswap V2–style AMM

Frontend

  • Next.js 14
  • TailwindCSS
  • Ethers.js

AI Layer

  • LLM-based assistant
  • On-chain data interpretation
  • Confidence scoring
  • Read-only execution

Network

  • Mantle Sepolia (L2)
  • Chain ID: 5003

πŸš€ Getting Started

git clone https://github.com/Shivamd0608/GreenAiDEX.git
cd GreenAiDEX/frontend
npm install
npm run dev

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors