A comprehensive blockchain-powered platform that brings transparency, accountability, and gamification to sustainability efforts. Companies log eco-friendly actions, earn tokenized carbon credits (ERC-20), unlock NFT badges (ERC-721), and participate in a vibrant ecosystem with marketplace, staking, and governance features.

โจ Features
Core Features
- ๐ฑ Carbon Credits (ERC-20) - Tokenized proof of eco-friendly actions
- ๐๏ธ EcoBadge NFTs (ERC-721) - Milestone rewards (Bronze, Silver, Gold, Platinum)
- ๐ Interactive Dashboard - Real-time tracking with charts and analytics
- ๐ Public Transparency - Verifiable on-chain records to combat greenwashing
- ๐ Gamification - Leaderboard system driving healthy competition
Advanced Features
- ๐ Marketplace - P2P carbon credit trading
- ๐ฐ Staking - Lock credits for rewards
- ๐ณ๏ธ Governance - DAO-style voting on proposals
- ๐ Analytics - Comprehensive platform and company statistics
- ๐ MetaMask Auth - Signature-based wallet authentication
๐๏ธ Architecture
Tech Stack
Blockchain
- Solidity 0.8.28
- Hardhat development environment
- OpenZeppelin contracts
- Ethers.js v6
Backend API
- Node.js + TypeScript
- Express.js REST API
- PostgreSQL (Neon) database
- Prisma ORM
- JWT + MetaMask signature auth
Frontend
- SvelteKit 5.0
- TypeScript
- TailwindCSS with dark mode
- Lucide icons
- Recharts for data visualization
Smart Contracts
- CarbonCreditToken.sol - ERC-20 carbon credits
- EcoBadgeNFT.sol - ERC-721 milestone NFTs
- EcoLedgerV2.sol - Enhanced action logging with multi-verification
- AccessControl.sol - Role-based permissions
- CarbonCreditMarketplace.sol - P2P trading platform
- CreditStaking.sol - Staking with rewards
- Governance.sol - DAO voting system
- Leaderboard.sol - Company rankings
๐ Quick Start
Prerequisites
- Node.js 18+
- PostgreSQL (or use provided Neon database)
- MetaMask browser extension
1. Clone Repository
git clone <repository-url>
cd EcoCred
2. Setup Blockchain
cd blockchain
npm install
# Start local Hardhat node
npm run node
# In another terminal, deploy contracts
npm run deploy
# Get deployed contract addresses
npm run get-addresses
3. Setup Backend
cd ../backend
npm install
# Database is already configured with Neon PostgreSQL
# Initialize database
npm run db:generate
npm run db:push
# Start backend server
npm run dev
Backend will run on http://localhost:3001
4. Setup Frontend
cd ../frontend
npm install
# Update contract addresses in .env.local
# VITE_CONTRACT_ADDRESS_CARBON=<address>
# VITE_CONTRACT_ADDRESS_BADGE=<address>
# VITE_CONTRACT_ADDRESS_LEDGER=<address>
# Start development server
npm run dev
Frontend will run on http://localhost:5173
๐ How It Works
For Companies
- Connect Wallet โ MetaMask authentication
- Register Profile โ Create company profile
- Log Eco Action โ Submit sustainability initiatives
- Verification โ Multi-verifier approval process
- Earn Credits โ Receive ERC-20 carbon credits
- Unlock Badges โ NFT milestones at credit thresholds
- Trade Credits โ List on marketplace or stake for rewards
- Participate โ Vote on governance proposals
For Verifiers
- Review Actions โ Examine submitted eco actions
- Verify/Reject โ Approve or deny with comments
- Multi-Verification โ Threshold-based consensus
- Transparent Records โ All actions recorded on-chain
- Reputation System โ Companies build trust scores
- Analytics โ Track platform growth and impact
- Governance โ Community-driven decision making
๐ง Configuration
Environment Variables
Backend (backend/.env)
DATABASE_URL=postgresql://...
JWT_SECRET=your-secret-key
BLOCKCHAIN_RPC_URL=http://localhost:8545
# Contract addresses are auto-detected - no need to set them manually!
Frontend - No .env files needed!
- Contract addresses are automatically detected from deployment artifacts
- See
DEPLOYMENT_AUTO.md for details
๐ API Documentation
Authentication
GET /api/auth/nonce/:walletAddress - Get signing nonce
POST /api/auth/verify - Verify signature & get JWT
Companies
GET /api/companies - List companies
POST /api/companies - Register company
PUT /api/companies/:id - Update profile
GET /api/companies/:id/actions - Action history
Actions
GET /api/actions - List all actions
POST /api/actions - Submit action
POST /api/actions/:id/verify - Verify action
Analytics
GET /api/analytics/overview - Platform stats
GET /api/analytics/trends - Historical data
Marketplace
GET /api/marketplace/listings - Browse listings
POST /api/marketplace/listings - Create listing
Staking
GET /api/staking/stakes/my - User's stakes
POST /api/staking/stakes - Create stake
Governance
GET /api/governance/votes - All votes
POST /api/governance/votes - Cast vote
Full API documentation: See backend/README.md
๐งช Testing
Smart Contracts
cd blockchain
npm run test
Backend
cd backend
npm run test
Frontend
cd frontend
npm run check
๐ข Deployment
Testnet Deployment (Sepolia)
- Deploy Contracts
cd blockchain
npm run deploy:sepolia
npm run export:addresses # Auto-export addresses
Contract addresses are automatically detected - no manual configuration needed!
- Deploy Backend
- Use Vercel, Railway, or any Node.js hosting
- Set environment variables
- Run database migrations
- Deploy Frontend
- Use Vercel, Netlify, or similar
- Set environment variables
- Build and deploy
Mainnet Deployment
โ ๏ธ Before mainnet deployment:
- Complete security audit
- Test thoroughly on testnet
- Review all contract parameters
- Implement multi-sig for admin functions
- Set up monitoring and alerts
๐ Security
- โ
Role-based access control
- โ
Input validation on all endpoints
- โ
JWT token authentication
- โ
MetaMask signature verification
- โ
Solidity 0.8.28 (overflow protection)
- โ ๏ธ Recommended: Add reentrancy guards
- โ ๏ธ Recommended: Implement pausable mechanism
- โ ๏ธ Recommended: Professional security audit before mainnet
๐ Database Schema
The PostgreSQL database includes:
- Company - Extended profiles with metadata
- Action - Eco actions with verification status
- Document - Supporting documents for actions
- Verification - Verification records
- Listing - Marketplace listings
- Stake - Staking records
- Vote - Governance votes
- Analytics - Platform snapshots
See backend/src/database/schema.prisma for full schema.
๐จ Frontend Features
- Dark Mode - System preference detection + manual toggle
- Responsive Design - Mobile-first approach
- Toast Notifications - Real-time feedback
- State Management - Svelte stores for wallet, user, theme
- API Integration - Comprehensive service layer
- Modern UI - Glassmorphism, animations, gradients
๐ Roadmap
๐ค Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature)
- Commit changes (
git commit -m 'Add amazing feature')
- Push to branch (
git push origin feature/amazing-feature)
- Open Pull Request
๐ License
This project is licensed under the MIT License.
๐ Support
- Documentation: See individual README files in
blockchain/, backend/, and frontend/
- Smart Contracts: See
blockchain/CONTRACTS_SUMMARY.md
- Deployment: See
blockchain/DEPLOYMENT_GUIDE.md
๐ Acknowledgments
Built with โค๏ธ for a sustainable future.
- OpenZeppelin for secure smart contract libraries
- Hardhat for development tools
- SvelteKit for amazing frontend framework
- Neon for serverless PostgreSQL
Version: 2.0.0
Last Updated: November 2024