Skip to main content
The 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

Effect:
  • Reverts if current time is less than or equal to input time
  • Used when time must have passed
Example:

Current Time Is Less

Effect:
  • Reverts if current time is greater than or equal to input time
  • Used when operation must happen before time
Example:

Current Time Is Within Range

Effect:
  • Reverts if current time is less than initialTime or greater than finalTime
  • Used for operations within specific time windows
Example:

Internal Functions

Revert If Current Time Is Not Less

Effect:
  • Reverts with CurrentTimeIsGreater error if current time is greater than or equal to input time
  • Used internally by currentTimeIsLess modifier

Revert If Current Time Is Not Greater

Effect:
  • Reverts with CurrentTimeIsLess error if current time is less than or equal to input time
  • Used internally by currentTimeIsGreater modifier

Revert If Current Time Is Not Within Range

Effect:
  • Reverts with CurrentTimeIsNotWithinRange error if not in range
  • Used internally by currentTimeIsWithinRange modifier

Errors

CurrentTimeIsGreater

Thrown when: Current time is greater than expected (too late) Includes: Expected time and actual current time

CurrentTimeIsLess

Thrown when: Current time is less than expected (too early) Includes: Expected time and actual current time

CurrentTimeIsNotWithinRange

Thrown when: Current time is outside the allowed range Includes: Start and end times of the range

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.timestamp which 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