16 token id strategy
Overview
The token ID strategy is critical for the semi-fungible credit system. It determines how projects map to credit token IDs and affects traceability, scalability, and operational complexity.
Strategy Options
Option 1: tokenId = ProjectRecordId (Recommended for v1)
Mapping:
ProjectRecord tokenId = 101
Credit Units tokenId = 101Implementation:
// When ProjectRecord is minted
uint256 projectTokenId = projectRegistry.mintProjectRecord(...);
// Credits use the same tokenId
carbonCredit1155.setProjectConfig(projectTokenId, capUnits, ...);
carbonCredit1155.mintCredits(projectTokenId, to, amountUnits);Advantages:
✅ Easiest to trace and reason about
✅ Direct 1:1 mapping
✅ Simple implementation
✅ Clear project-to-credits relationship
Disadvantages:
❌ One project = one issuance batch
❌ Cannot issue multiple batches per project easily
Use Case: One project record represents one issuance batch (most common for v1).
Option 2: tokenId = hash(projectId + vintage + verifier + methodology)
Mapping:
Implementation:
Advantages:
✅ Supports multiple batches per project
✅ Batch-specific tracking
✅ Flexible issuance model
Disadvantages:
❌ More complex tokenId generation
❌ Requires batch management
❌ Harder to trace without mapping table
Use Case: Multiple issuance batches per project (common in carbon markets).
Option 3: Sequential Token IDs with Mapping
Mapping:
Implementation:
Advantages:
✅ Clear batch separation
✅ Multiple batches per project
✅ Sequential IDs (easier to iterate)
Disadvantages:
❌ Requires mapping tables
❌ More complex queries
❌ Additional gas costs
Use Case: Complex multi-batch scenarios.
Recommendation
For v1: Use Option 1
Rationale:
Simplest implementation
Easiest to understand and audit
Sufficient for most use cases
Can upgrade to Option 2 later if needed
For Future: Consider Option 2
When to Upgrade:
Need multiple issuance batches per project
Different vintages need separate tracking
Different verifiers/methodologies per project
Implementation Example (Option 1)
ProjectRegistry
CarbonCredit1155
Usage
Token ID Lookup Patterns
Query Credits by Project
Query Project by Credit TokenId
Migration Considerations
From Option 1 to Option 2
Best Practices
Last updated