Epochs Berachain
Epochs represent an interval of time. There are many different epochs, however the epoch most PoL dApps use can be identified by berachain_epoch_identifier
.
Berachain tracks the following epochs:
day
hour
week
berachain_epoch_identifier
Example:
Number of seconds in a day = (24 * 60 * 60) seconds = 86400
Given a block time of 5 seconds, an epoch of a day would last approximately: 86400/5 = 17280
A new epoch would begin every 17280
blocks based on this math.
Note: Link to existing contract ABI's can be found on Github here.
Functions
getCurrentEpoch
Gets the current epoch based on an identifier. Note: berachain_epoch_identifier
is the default epoch identifier for berachain poof of liquidity dApps.
solidity
function getCurrentEpoch(string calldata identifier)
external
view
returns (int64 epochNumber, int64 startTimestamp, int64 endTimestamp);
function getCurrentEpoch(string calldata identifier)
external
view
returns (int64 epochNumber, int64 startTimestamp, int64 endTimestamp);
Parameters
Name | Type | Description |
---|---|---|
identifier | string | The identifier of the epoch. |
Returns
Name | Type | Description |
---|---|---|
epochNumber | int64 | The current epoch number. |
startTimestamp | int64 | The epoch start time in unix. |
endTimestamp | int64 | The current epoch end time in unix. |
Events
EpochStart
Emitted when an epoch started.
solidity
event EpochStart(int64 indexed epochNumber, int64 startTime);
event EpochStart(int64 indexed epochNumber, int64 startTime);
Parameters
Name | Type | Description |
---|---|---|
epochNumber | int64 | The epoch number. |
startTime | int64 | The epoch start time in unix. |
EpochEnd
Emitted when an epoch ended.
solidity
event EpochEnd(int64 indexed epochNumber, int64 endTime);
event EpochEnd(int64 indexed epochNumber, int64 endTime);
Parameters
Name | Type | Description |
---|---|---|
epochNumber | int64 | The epoch number. |
endTime | int64 | The epoch end time in unix. |