-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Overview
Extend Impact Product NFT smart contracts to store enhanced cleanup metadata and implement automated Hypercert generation trigger every 10 verified cleanups.
Technical Requirements
1. Enhanced Metadata Storage
Update Impact Product NFT contract to store additional metadata fields:
Basic Impact Metrics:
struct EnhancedImpactData {
uint256 areaCleaned; // in square meters
string locationType; // beach, park, street, forest, waterway
string[] wasteTypes; // plastic_bottles, cigarette_butts, food_waste, etc.
uint256 estimatedWeight; // in grams
uint8 bagsFilled;
uint256 durationMinutes;
uint256 timestamp;
}Hypercert-Specific Fields:
struct HypercertData {
address[] contributors; // wallet addresses
string scopeOfWork; // auto-generated from location + waste types
uint256 timeOfWork; // timestamp
string scopeOfImpact; // auto-generated from environmental tags
uint256 timeOfImpact; // default to work time, extendable
string rightsAssignment; // default: "Attribution, Non-commercial use"
}Additional Context:
struct AdditionalContext {
string environmentalChallenges;
string preventionSuggestions;
string[] equipmentUsed;
string[] safetyMeasures;
}2. Metadata Update Functions
function updateImpactProduct(
uint256 tokenId,
EnhancedImpactData calldata enhancedData,
HypercertData calldata hypercertData,
AdditionalContext calldata context
) external onlyTokenOwner(tokenId) {
// Update metadata
// Emit MetadataUpdate event
// Update aggregation for Hypercert tracking
}3. Hypercert Milestone Tracking
mapping(address => uint256) public userCleanupCount;
mapping(address => EnhancedImpactData[]) public userCleanupHistory;
function incrementCleanupCount(address user) internal {
userCleanupCount[user]++;
if (userCleanupCount[user] % 10 == 0) {
emit HypercertMilestoneReached(user, userCleanupCount[user]);
}
}4. Data Aggregation for Hypercerts
function getAggregatedData(address user, uint256 fromCleanup, uint256 toCleanup)
external
view
returns (
uint256 totalArea,
uint256 totalWeight,
uint256 totalDuration,
string[] memory allWasteTypes,
string[] memory allLocations
) {
// Aggregate data from last 10 cleanups
// Return combined metrics for Hypercert generation
}5. Bonus Rewards Integration
uint256 public constant ENHANCED_FORM_BONUS = 5 * 10**18; // 5 DCU
function claimWithEnhancedData(
uint256 submissionId,
EnhancedImpactData calldata enhancedData
) external {
// Standard claim logic
// Award base 10 DCU
// Check if enhanced data provided
if (enhancedData.areaCleaned > 0) {
// Award bonus 5 DCU
dcuToken.mint(msg.sender, ENHANCED_FORM_BONUS);
emit EnhancedSubmissionBonus(msg.sender, submissionId);
}
}6. Privacy Controls
struct PrivacySettings {
bool shareLocationData;
bool sharePersonalContext;
bool includeInAnalytics;
}
mapping(uint256 => PrivacySettings) public tokenPrivacySettings;
function updatePrivacySettings(uint256 tokenId, PrivacySettings calldata settings)
external
onlyTokenOwner(tokenId) {
tokenPrivacySettings[tokenId] = settings;
}7. Data Validation
modifier validImpactData(EnhancedImpactData calldata data) {
require(data.areaCleaned <= 1000000, "Area too large"); // max 1km²
require(data.estimatedWeight <= 10000000, "Weight too large"); // max 10 tons
require(data.durationMinutes <= 1440, "Duration exceeds 24 hours");
require(data.bagsFilled <= 255, "Too many bags");
_;
}Implementation Tasks
Phase 1: Core Contract Updates
- Update Impact Product NFT contract with new metadata structures
- Implement enhanced data storage functions
- Add cleanup count tracking and milestone detection
- Create data aggregation view functions for Hypercerts
Phase 2: Bonus & Incentives
- Integrate enhanced form bonus (5 DCU) in claiming logic
- Emit proper events for milestone tracking
- Update DCU minting logic for bonus rewards
Phase 3: Privacy & Validation
- Implement privacy control mechanisms
- Add data validation modifiers
- Create functions to retrieve privacy-filtered data
Phase 4: Hypercert Preparation
- Build aggregation queries for 10-cleanup windows
- Format data according to Hypercerts metadata standard
- Create read functions for DeCleanup Network to retrieve aggregated data
Phase 5: Testing & Deployment
- Unit tests for all new functions
- Integration tests with existing submission flow
- Gas optimization analysis
- Security audit
- Deploy to Celo testnet
- Deploy to Celo mainnet
Technical Specifications
Blockchain: Celo (initial deployment)
Contract Standards:
- ERC-1155 (Impact Products)
- ERC-20 (DCU token)
Gas Optimization:
- Use
calldatafor struct parameters - Pack storage variables efficiently
- Batch operations where possible
Events to Emit:
event EnhancedDataAdded(uint256 indexed tokenId, address indexed user);
event HypercertMilestoneReached(address indexed user, uint256 cleanupCount);
event EnhancedSubmissionBonus(address indexed user, uint256 submissionId);
event MetadataUpdated(uint256 indexed tokenId, string newMetadataURI);Integration Points
Frontend Requirements:
- Form should call
claimWithEnhancedData()when user completes enhanced form - Display Hypercert milestone progress (X/10 cleanups)
- Show bonus DCU earned for enhanced submissions
- Allow users to update privacy settings post-submission
Backend/Indexer Requirements:
- Listen for
HypercertMilestoneReachedevents - Trigger Hypercert generation workflow
- Aggregate data from blockchain for analytics dashboard
- Filter data based on privacy settings
Acceptance Criteria
- Enhanced metadata stores correctly onchain
- Bonus DCU (5) mints when enhanced form completed
- Cleanup count increments properly
- Milestone events emit at 10, 20, 30, etc. cleanups
- Aggregation functions return correct combined data
- Privacy controls filter data appropriately
- All validation checks prevent invalid data
- Gas costs remain reasonable (<$0.10 per enhanced submission on Celo)
- Contract upgradeable for future Hypercert integration improvements
Security Considerations
- Validate all user inputs with bounds checking
- Prevent re-entrancy in bonus minting
- Ensure only token owners can update their metadata
- Protect against manipulation of cleanup counts
- Rate limiting on bonus claims if needed
Documentation Requirements
- Update contract documentation with new functions
- Document metadata structure for frontend integration
- Create Hypercert data format specification
- Provide examples of aggregated data queries
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
💡 Ideas