The PWN Epoch Clock provides the current epoch number in the PWN DAO context. One epoch is 4 weeks long and the epoch numbering starts with 1. INITIAL_EPOCH_TIMESTAMP is set at the deployment time and can be used to sync the clock between different chains.
2. Important links
3. Contract details
PWNEpochClock.sol is written in Solidity version 0.8.25
Features
Get current epoch
Set epoch start at deployment
Inherited contracts, implemented Interfaces and ERCs
Function to get the current epoch number. If this function is called before the clock start, 0 is returned.
This function doesn't take any arguments.
Implementation
functioncurrentEpoch() externalviewreturns (uint16) {// timestamps prior to `INITIAL_EPOCH_TIMESTAMP` are considered to be in epoch 0if (block.timestamp < INITIAL_EPOCH_TIMESTAMP) {return0; }// first epoch is 1uint256 epoch = (block.timestamp - INITIAL_EPOCH_TIMESTAMP) / SECONDS_IN_EPOCH +1;returnuint16(epoch); // safe cast for the next 5041 years after deployment}