
GreenTrace
Tokenize Your Green Impact!
Demo
About
The problem it solves ## Current Challenges in Environmental Action Incentivization - Traditional environmental protection efforts lack effective incentive mechanisms. - Individual green actions (e.g. walking, cycling, recycling) are often unrecognized and unrewarded. - There is no transparent way to quantify or monetize personal carbon footprint reduction. - Existing carbon credit systems are: - Inaccessible to individuals - Lacking transparency and trust - Controlled by large institutions - Public participation is limited due to the absence of tangible personal benefits. --- ## How GreenTrace Solves These Problems ### Individual Carbon Credit Monetization - **Before**: Personal environmental actions have no financial value. - **After**: Each green action can be converted into tradable carbon credits via NFT creation. - **Impact**: Users receive direct financial rewards for sustainable behaviors. ### Transparent and Verifiable Carbon Tracking - **Before**: Carbon reduction claims lack verification and transparency. - **After**: Blockchain-based immutable records integrated with Chainlink oracles provide real-time carbon price data. - **Impact**: Trustworthy and auditable environmental impact tracking. ### Democratized Carbon Credit Market - **Before**: Only large corporations can participate in carbon credit markets. - **After**: Individuals and communities can create, trade, and invest in carbon credits. - **Impact**: Inclusive access to environmental financial tools. ### Gamified Environmental Protection - **Before**: Environmental responsibility feels burdensome or thankless. - **After**: NFT creation, trading, and community engagement introduce gamification and incentives. - **Impact**: Greater public participation and motivation in sustainability efforts. --- ## Real-World Use Cases ### For Individuals - Daily commuters can convert walking or cycling into carbon credits. - Homeowners can earn credits for using solar panels or improving energy efficiency. - Students can mint NFTs based on recycling and campus sustainability projects. - Remote workers can monetize reduced commuting emissions. ### For Communities - Local governments can use the system to incentivize citizen engagement in green programs. - Schools can reward students for participating in environmental projects. - Companies can integrate sustainability engagement into employee incentive programs. ### For Investors - ESG investors can support verified carbon reduction at the individual and community level. - Retail traders can participate in a transparent and accessible carbon market. - Institutions can diversify their portfolios with blockchain-based environmental assets. --- ## How It Makes Tasks Easier and Safer ### Simplified Carbon Credit Creation - **Before**: High barriers to entry with complex verification processes. - **After**: Streamlined NFT creation with automated verification workflows. ### Secure and Transparent Trading - **Before**: Opaque markets with high counterparty risk. - **After**: Smart contract-based trading with Chainlink price feeds for real-time, fair pricing. ### Automated Compliance - **Before**: Manual and error-prone carbon accounting. - **After**: Automated tracking with immutable audit trails for reporting and compliance. ### Liquidity Provision - **Before**: Illiquid and inefficient carbon credit markets. - **After**: Liquidity pools enable continuous trading and improved market efficiency. --- ## Innovation with Chainlink Integration - Real-time carbon pricing through Chainlink Data Feeds ensures accurate, tamper-proof valuation. - Enables trustless, transparent transactions and decentralized compliance mechanisms. - Supports automated workflows for NFT pricing, verification, and marketplace integration.
How it's made
Challenges we ran into 🔧 **Chainlink Functions Dependency Management Issues** **The Problem:** When implementing Chainlink Functions, I encountered significant challenges with dependency management and library versions. The recommended dependency libraries in the official documentation didn't match what I found in the actual Chainlink contracts repository. **Specific Issues:** - **Version Mismatches**: The official docs referenced `@chainlink/contracts` but the actual implementation required specific version paths like `v0.8/functions/v1_3_0/` - **Import Path Confusion**: Different Chainlink services (Functions, Automation, Data Feeds) were scattered across different directories with inconsistent naming conventions - **ABI Location Problems**: The contract ABIs were located in separate directories that weren't clearly documented **How I Solved It:** ```solidity // ❌ What the docs suggested: import "@chainlink/contracts/src/v0.8/functions/FunctionsClient.sol"; // ✅ What actually worked: import "lib/chainlink-brownie-contracts/contracts/src/v0.8/functions/v1_3_0/FunctionsClient.sol"; ``` **Solution Process:** 1. **Deep Repository Exploration**: I had to manually navigate through the entire Chainlink contracts repository to find the correct import paths 2. **Version-Specific Imports**: Discovered that Functions had multiple versions (v1_0_0, v1_1_0, v1_3_0) with different interfaces 3. **ABI Discovery**: Found that contract ABIs were in separate `abi/` directories with version-specific naming ## 🐛 **Carbon Price Oracle Integration Bug** **The Problem:** When integrating the CarbonPriceOracle with Chainlink Functions, I encountered a critical bug where the price deviation mechanism wasn't working correctly due to decimal precision mismatches. **The Bug:** ```solidity // ❌ Original buggy code: uint256 oraclePrice = priceOracle.getLatestCarbonPriceUSD(); // 8 decimals uint256 orderPriceWei = _price * 1e18; // 18 decimals // Direct comparison without proper conversion if (orderPriceWei < oraclePrice) { // This comparison was wrong due to decimal mismatch! } ``` **How I Fixed It:** ```solidity // ✅ Fixed implementation: uint256 oraclePrice = priceOracle.getLatestCarbonPriceUSD(); // 8 decimals if (oraclePrice > 0) { // Convert oracle price from 8 decimals to 18 decimals referencePrice = oraclePrice * 1e10; // 8 -> 18 } else { // Fallback: use AMM pool current price (18 decimals) referencePrice = ammPool.getCarbonPrice(); } // Now both prices are in 18 decimals for proper comparison uint256 orderPriceWei = _price * 1e18; ``` ## 🔄 **Multi-Chain Deployment Complexity** **The Problem:** Deploying the same contracts across different networks (Sepolia, local Foundry) required different configurations and I encountered issues with Chainlink service addresses varying between networks. **Specific Challenges:** - **Different DON IDs**: Each network had different Decentralized Oracle Network identifiers - **Subscription Management**: Chainlink Functions subscriptions were network-specific - **Gas Limit Variations**: Different networks required different gas limits for Functions execution **Solution:** ```solidity // Created network-specific configuration struct NetworkConfig { bytes32 donId; uint64 subscriptionId; uint32 gasLimit; address linkToken; address eurUsdPriceFeed; } // Network-specific deployment script function deployForNetwork(NetworkConfig memory config) internal { CarbonPriceOracle oracle = new CarbonPriceOracle( config.donId, config.subscriptionId, config.gasLimit, config.linkToken, config.eurUsdPriceFeed ); } ``` ## 📊 **Frontend Integration Challenges** **The Problem:** Integrating the smart contract price deviation logic with the frontend UI was complex, especially handling the real-time price updates and threshold calculations. **The Challenge:** - **State Synchronization**: Frontend needed to reflect real-time oracle price changes - **Threshold Visualization**: Users needed to understand when their trades would be blocked - **Error Handling**: Complex error messages needed to be user-friendly **How I Solved It:** ```typescript // Created comprehensive price deviation monitoring const usePriceDeviation = () => { const { data: oraclePrice } = useReadContract({ address: priceOracleAddress, abi: CarbonPriceOracleABI, functionName: 'getLatestCarbonPriceUSD', }); const { data: threshold } = useReadContract({ address: marketAddress, abi: CarbonUSDTMarketABI, functionName: 'priceDeviationThreshold', }); // Real-time deviation calculation const deviation = useMemo(() => { if (!oraclePrice || !currentPrice) return 0; return ((Number(currentPrice) - Number(oraclePrice)) / Number(oraclePrice)) * 100; }, [oraclePrice, currentPrice]); return { deviation, isBlocked: Math.abs(deviation) > (threshold || 10), threshold: threshold || 10 }; }; ```