
Features implemented: - User authentication with JWT tokens and role-based access (developer/buyer) - Blockchain wallet linking and management with Ethereum integration - Carbon project creation and management for developers - Marketplace for browsing and purchasing carbon offsets - Transaction tracking with blockchain integration - Database models for users, projects, offsets, and transactions - Comprehensive API with authentication, wallet, project, and trading endpoints - Health check endpoint and platform information - SQLite database with Alembic migrations - Full API documentation with OpenAPI/Swagger Technical stack: - FastAPI with Python - SQLAlchemy ORM with SQLite - Web3.py for blockchain integration - JWT authentication with bcrypt - CORS enabled for frontend integration - Comprehensive error handling and validation Environment variables required: - SECRET_KEY (JWT secret) - BLOCKCHAIN_RPC_URL (optional, defaults to localhost)
34 lines
773 B
Python
34 lines
773 B
Python
from pydantic import BaseModel
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
|
|
class TransactionCreate(BaseModel):
|
|
offset_id: int
|
|
quantity: int
|
|
|
|
class TransactionResponse(BaseModel):
|
|
id: int
|
|
transaction_hash: str
|
|
quantity: int
|
|
price_per_credit: float
|
|
total_amount: float
|
|
status: str
|
|
block_number: Optional[int] = None
|
|
gas_used: Optional[int] = None
|
|
created_at: datetime
|
|
confirmed_at: Optional[datetime] = None
|
|
buyer_id: int
|
|
offset_id: int
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
class TransactionListResponse(BaseModel):
|
|
transactions: List[TransactionResponse]
|
|
total: int
|
|
page: int
|
|
page_size: int
|
|
|
|
class PurchaseRequest(BaseModel):
|
|
project_id: int
|
|
quantity: int |