TimestampChecker is an abstract utility contract that provides timestamp-based validation for time-sensitive operations. It’s used throughout the protocol to ensure functions are called at the correct times.
Overview
Purpose
- Time Validation: Ensure operations occur at correct times
- Campaign Launches: Verify campaign hasn’t launched yet
- Deadlines: Verify campaign hasn’t ended
- Time Windows: Validate operations within time ranges
- Gas Efficient: Simple timestamp comparisons
Modifiers
Current Time Is Greater
- Reverts if current time is less than or equal to input time
- Used when time must have passed
Current Time Is Less
- Reverts if current time is greater than or equal to input time
- Used when operation must happen before time
Current Time Is Within Range
- Reverts if current time is less than initialTime or greater than finalTime
- Used for operations within specific time windows
Internal Functions
Revert If Current Time Is Not Less
- Reverts with
CurrentTimeIsGreatererror if current time is greater than or equal to input time - Used internally by
currentTimeIsLessmodifier
Revert If Current Time Is Not Greater
- Reverts with
CurrentTimeIsLesserror if current time is less than or equal to input time - Used internally by
currentTimeIsGreatermodifier
Revert If Current Time Is Not Within Range
- Reverts with
CurrentTimeIsNotWithinRangeerror if not in range - Used internally by
currentTimeIsWithinRangemodifier
Errors
CurrentTimeIsGreater
CurrentTimeIsLess
CurrentTimeIsNotWithinRange
Usage Examples
Campaign Launch Time Validation
Deadline Enforcement
Pre-Launch Updates
Pledge Window Check
Integration
With CampaignInfo
With Treasury
Security Considerations
Timestamp Manipulation
- Uses
block.timestampwhich miners can manipulate slightly - 15-second tolerance is typical
- Use relative times when possible
Front-Running
- Timestamps prevent certain operations
- Can’t be bypassed by transaction ordering
- Provides natural protection for state changes
Timezone Independence
- All timestamps in Unix epoch seconds
- No timezone considerations needed
- Clear, universal time reference
Best Practices
Define Clear Time Windows
Test Time-Based Logic
Handle Edge Cases
Next Steps
- CampaignInfo - Uses timestamp validation
- AllOrNothing - Enforces pledge windows
- PausableCancellable - Additional state controls