Inspiration
Climate change is one of the defining challenges of our time, yet most people have no idea what their personal carbon footprint actually looks like. Existing tools either give vague estimates or require manual research. We wanted something that combines scientific accuracy with radical transparency — where every number is AI-verified and every record is publicly immutable on the blockchain.
What it does
EcoLedger lets you log everyday activities — driving, flying, eating, shopping — and instantly receive a precise CO₂ analysis powered by Alibaba Qwen AI using IPCC emission factors. Each activity is then hashed and recorded permanently on the Polygon Amoy blockchain, creating a tamper-proof environmental ledger that anyone can verify.
Key features:
- 🤖 AI Carbon Analysis — Qwen AI calculates grams of CO₂ equivalent for 40+ activity types across 5 categories, with a detailed breakdown, reduction tips, and real-world comparisons
- ⛓️ Blockchain Verification — every activity is hashed (keccak256) and stored on-chain via a custom Solidity smart contract — immutable and publicly queryable
- 🏆 EcoCredits — earn on-chain gamification credits for low-carbon choices (50 credits for zero-carbon, down to 0 for high-impact activities)
- 📊 Dashboard — 30-day carbon trend chart, category breakdown pie chart, weekly/monthly totals
- 🔒 Secure Auth — custom JWT authentication with httpOnly cookies and bcrypt password hashing
How we built it
| Layer | Technology |
|---|---|
| Frontend | Next.js 14 (App Router) + TypeScript + Tailwind CSS |
| AI | Alibaba DashScope API — qwen-max model (IPCC emission factors in system prompt) |
| Blockchain | Polygon Amoy testnet + ethers.js v6 + Solidity 0.8.24 |
| Database | MySQL 8.0+ with connection pooling (mysql2) |
| Auth | Custom JWT with jose library (Edge Runtime compatible) + bcrypt |
| Charts | Recharts — AreaChart + PieChart with SSR-safe dynamic imports |
| Testing | Jest (64 tests) + Hardhat + Chai (smart contract tests) |
The architecture follows a clean separation: the Next.js server handles all sensitive operations (AI calls, DB queries, JWT verification), while the client only receives sanitized results. The smart contract prevents duplicate entries via keccak256 hash tracking.
Challenges we faced
Edge Runtime compatibility — Next.js middleware runs in the Edge Runtime, which doesn't support Node.js APIs. The jsonwebtoken library silently failed there, causing all authenticated routes to reject valid sessions. The fix was migrating to jose, which is built on the Web Crypto API and works everywhere.
MySQL prepared statements — mysql2's execute() method uses binary prepared statements that reject JavaScript numbers for LIMIT/OFFSET/INTERVAL parameters. Switching to pool.query() (text protocol) resolved this without sacrificing security.
DashScope regions — The Alibaba API has separate endpoints for China (dashscope.aliyuncs.com) and international (dashscope-intl.aliyuncs.com). Using the wrong endpoint causes silent 401 errors even with a valid API key.
What we learned
- Blockchain immutability is genuinely powerful for environmental accountability — not just as a buzzword, but as a way to make personal climate data verifiable and trustworthy
- IPCC emission factors vary enormously (beef = 27,000g CO₂/kg vs vegetables = 200g CO₂/kg) — AI is the right tool to make this complexity accessible to normal users
- Building a full-stack project end-to-end in 4 days forces ruthless prioritization — every feature had to earn its place in the demo
What's next
- Mobile app with GPS-based automatic transport detection
- Social features — compare carbon footprints with friends
- Integration with smart home devices for automatic energy tracking
- Carbon offset marketplace — trade EcoCredits for verified offsets
Built With
- alibaba
- cloud
- css
- mysql
- next.js
- polygon
- solidity
- tailwind
- typescript
Log in or sign up for Devpost to join the conversation.