VeChain Hackathon MVP - A decentralized application for tracking and verifying product sustainability data on the blockchain.
- Overview
- Features
- Architecture
- Tech Stack
- Project Structure
- Getting Started
- Smart Contract
- Frontend
- API Endpoints
- Blockchain Integration
- Development
- Deployment
- Contributing
- License
EcoLedger is a blockchain-based sustainability platform that allows users to register, track, and verify the environmental impact of products. Built for the VeChain Hackathon, this MVP demonstrates how blockchain technology can create transparent, immutable records of product sustainability data.
This project was developed as an MVP (Minimum Viable Product) for the VeChain Hackathon. It showcases the core functionality of a sustainability tracking platform using VeChain's blockchain technology. A complete, production-ready dApp will be developed after the hackathon with additional features, enhanced security, and scalability improvements.
- Transparency: All product data is stored on the blockchain, ensuring immutability and transparency
- Verification: Products can be verified by scanning QR codes linked to blockchain transactions
- Accessibility: Anyone with a wallet can register products without complex company registration
- Real-time: Live blockchain integration with VeChain testnet
- User-friendly: Intuitive interface for both technical and non-technical users
- VeChain Testnet: Live blockchain integration with real transactions
- Wallet Connection: VeChain DAppKit for seamless wallet integration
- Transaction Verification: QR codes link to VeChain Explorer for transaction verification
- Real-time Data: Products fetched directly from blockchain
- Product Registry: 16 pre-loaded sustainable products with real emission factors
- EcoScore Calculation: Dynamic sustainability scoring (0-100 scale)
- Carbon Footprint Tracking: CO2 emissions calculated and stored on blockchain
- Category Classification: Products organized by material type and sustainability impact
- Responsive Design: Mobile-first design with desktop optimization
- Tab-based Navigation: Organized interface for different functionalities
- Real-time Stats: Dynamic statistics based on selected products
- Interactive Cards: Product cards with blockchain integration
- Frontend-only Architecture: No backend server required
- Local API: All product data and calculations handled in frontend
- TypeScript: Full type safety and better development experience
- Modern React: Hooks, context, and modern React patterns
┌─────────────────────────────────────────────────────────────┐
│ Frontend (React + TypeScript) │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Dashboard │ │ Components │ │ Services │ │
│ │ │ │ │ │ │ │
│ │ • Product │ │ • Product │ │ • Local API │ │
│ │ Registry │ │ Cards │ │ • Blockchain│ │
│ │ • Blockchain│ │ • QR Codes │ │ • VeChain │ │
│ │ Products │ │ • Forms │ │ DAppKit │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ VeChain Testnet │
├─────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ EcoLedger │ │ VeChain │ │ VeChain │ │
│ │ Smart │ │ DAppKit │ │ Explorer │ │
│ │ Contract │ │ Wallet │ │ (QR Links) │ │
│ │ │ │ Integration │ │ │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘
- React 18 - Modern React with hooks and context
- TypeScript - Type safety and better development experience
- Vite - Fast build tool and development server
- Tailwind CSS - Utility-first CSS framework
- Shadcn/ui - Modern UI component library
- Lucide React - Beautiful icons
- VeChain - Blockchain platform for sustainability tracking
- VeChain DAppKit - Wallet integration and blockchain interaction
- Solidity 0.8.20 - Smart contract development
- Hardhat - Development environment for smart contracts
- OpenZeppelin - Secure smart contract libraries
- ESLint - Code linting and quality
- Prettier - Code formatting
- React Query - Data fetching and caching
- React Router - Client-side routing
EcoLedger/
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ │ ├── ui/ # Shadcn/ui components
│ │ │ ├── ProductCard.tsx
│ │ │ ├── BlockchainProductCard.tsx
│ │ │ ├── RegisterProductForm.tsx
│ │ │ └── ...
│ │ ├── hooks/ # Custom React hooks
│ │ │ ├── useBlockchain.ts
│ │ │ ├── useProducts.ts
│ │ │ └── ...
│ │ ├── pages/ # Page components
│ │ │ ├── Dashboard.tsx
│ │ │ └── NotFound.tsx
│ │ ├── services/ # API and blockchain services
│ │ │ ├── api.ts
│ │ │ ├── local-api.ts
│ │ │ ├── vechain-dappkit.ts
│ │ │ └── ...
│ │ └── util/ # Utility functions
│ ├── public/ # Static assets
│ ├── package.json
│ └── vite.config.ts
├── contracts/ # Smart contracts
│ ├── contracts/
│ │ └── EcoLedger.sol # Main smart contract
│ ├── scripts/
│ │ └── deploy-ecoledger.ts
│ ├── test/
│ │ └── EcoLedger.test.ts
│ ├── hardhat.config.ts
│ └── package.json
├── backend/ # NestJS backend (optional)
│ └── api/ # API endpoints and services
└── README.md
- Node.js (v18 or higher)
- npm or yarn
- Git
- VeChain Wallet (Sync2)
-
Clone the repository
git clone https://github.com/your-username/EcoLedger.git cd ecoledger -
Install frontend dependencies
cd frontend npm install -
Install contract dependencies (optional)
cd ../contracts npm install
cd frontend
npm run devcd contracts
npm run compile # Compile contracts
npm run test # Run tests
npm run deploy:testnet # Deploy to VeChain testnetThe EcoLedger.sol contract is deployed on VeChain testnet and provides:
registerProduct()- Register a new product with sustainability datagetWalletProducts()- Get all products registered by a walletgetProduct()- Get specific product informationgetGlobalStats()- Get global sustainability statisticsupdateProductCo2()- Update product CO2 footprintupdateProductTxHash()- Update product transaction hash
VeChain Testnet: 0x92e647e3bc952154e8336673c4acd1acdcbe63eb
- No Company Registration: Anyone can register products directly
- Wallet-based Ownership: Products are associated with wallet addresses
- Transaction Hash Storage: Each product stores its registration transaction hash
- Global Statistics: Track total products, wallets, and CO2 footprint
- Immutable Records: All data is stored permanently on the blockchain
- Product Registry: View and manage selected products
- Blockchain Products: View products stored on blockchain
- Add from Database: Select from 16 pre-loaded sustainable products
- Wallet Connection: Connect VeChain wallet
- Register New: Register custom products
- EcoScore Display: Visual sustainability score (0-100)
- Carbon Footprint: CO2 emissions in kg
- Blockchain Integration: Add products to blockchain
- QR Code Generation: Automatic QR codes for blockchain products
- Mobile-first: Optimized for mobile devices
- Desktop Support: Enhanced experience on larger screens
- Touch-friendly: Easy interaction on all devices
All API endpoints are now handled locally in the frontend:
GET /products- Get all productsGET /products/:id- Get specific productGET /products/emission-factors- Get emission factors
POST /co2/calculate- Calculate CO2 footprintPOST /co2/calculate-simple- Simple CO2 calculationGET /co2/ecoscore-interpretation- Get EcoScore interpretation
The application includes 16 pre-loaded sustainable products:
- Bamboo Cutlery Set (0.5 kg CO2/kg)
- Recycled Paper Notebook (0.8 kg CO2/kg)
- Recycled Glass Bottle (1.0 kg CO2/kg)
- Cardboard Packaging Box (1.2 kg CO2/kg)
- Recycled Steel Water Bottle (0.5 kg CO2/kg)
- Recycled Aluminum Can (2.5 kg CO2/kg)
- Concrete Building Block (0.13 kg CO2/kg)
- Polyester Jacket (5.5 kg CO2/kg)
- Virgin Plastic Bottle (6.0 kg CO2/kg)
- Aluminum Foil (8.2 kg CO2/kg)
- Cotton T-Shirt (27.0 kg CO2/kg)
- Leather Wallet (15.0 kg CO2/kg)
- Smartphone (25.0 kg CO2/kg)
- Cement Block (0.9 kg CO2/kg)
- Laptop Computer (30.0 kg CO2/kg)
- Beef Jerky (60.0 kg CO2/kg)
The application uses VeChain DAppKit for:
- Wallet Connection: Seamless wallet integration
- Transaction Signing: Secure transaction signing
- Network Interaction: Direct interaction with VeChain testnet
- Event Listening: Real-time blockchain event monitoring
- User Selects Product: Choose from database or register new
- Wallet Connection: Connect VeChain wallet
- Transaction Creation: Create blockchain transaction
- User Approval: User signs transaction in wallet
- Blockchain Confirmation: Transaction confirmed on VeChain
- QR Code Generation: Automatic QR code with transaction hash
- Explorer Integration: QR code links to VeChain Explorer
- Automatic Generation: QR codes generated for all blockchain products
- VeChain Explorer: Direct links to transaction details
- Verification: Users can verify products by scanning QR codes
- Mobile-friendly: Easy scanning with mobile devices
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLint
npm run type-check # Run TypeScript type checkingnpm run compile # Compile contracts
npm run test # Run tests
npm run deploy # Deploy to testnet
npm run verify # Verify contract on explorerVITE_VECHAIN_NETWORK=testnet
VITE_CONTRACT_ADDRESS=0x92e647e3bc952154e8336673c4acd1acdcbe63ebVECHAIN_PRIVATE_KEY=your_private_key
VECHAIN_NETWORK=testnet- TypeScript: Full type safety
- ESLint: Code linting and quality
- Prettier: Code formatting
- Husky: Git hooks for quality checks
npm run build
# Deploy to Vercelnpm run build
# Deploy to Netlifynpm run build
# Upload dist/ folder to any static hostingcd contracts
npm run deploy:testnetcd contracts
npm run deploy:mainnet- Company Registration: Optional company profiles
- Product Verification: Third-party verification system
- Supply Chain Tracking: Multi-step supply chain tracking
- Carbon Credits: Integration with carbon credit markets
- AI Integration: Machine learning for sustainability scoring
- IoT Integration: Real-time sensor data integration
- Multi-chain Support: Support for other blockchain networks
- Mobile App: Native mobile applications
- Enterprise Dashboard: Advanced analytics and reporting
- API Access: Public API for third-party integrations
- White-label Solution: Customizable platform for enterprises
- Compliance Tools: Regulatory compliance features
- Audit: Professional smart contract audit
- Multi-sig: Multi-signature wallet integration
- Access Control: Role-based access control
- Encryption: End-to-end encryption for sensitive data
- Layer 2: Integration with VeChain Layer 2 solutions
- Database: Hybrid blockchain-database architecture
- Caching: Advanced caching strategies
- CDN: Content delivery network integration
- Progressive Web App: PWA capabilities
- Offline Support: Offline functionality
- Accessibility: WCAG compliance
- Internationalization: Multi-language support
This project was developed for the VeChain Hackathon. Contributions are welcome:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
- Code Style: Follow TypeScript and React best practices
- Testing: Write tests for new features
- Documentation: Update documentation for changes
- Commit Messages: Use conventional commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
- VeChain Foundation - For providing the blockchain platform
- VeChain DAppKit Team - For excellent developer tools
- OpenZeppelin - For secure smart contract libraries
- React Community - For the amazing React ecosystem
- Hackathon Participants - For inspiration and feedback
- Project: EcoLedger
- Hackathon: VeChain Hackathon 2024
- Status: MVP - Production version coming soon
- Website: [Coming Soon]
Built with ❤️ for the VeChain Hackathon
This is an MVP developed for demonstration purposes. A complete, production-ready version will be developed after the hackathon with enhanced features, security, and scalability.