Skip to content

Epochs Berachain

Git Source

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_identifieris 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

NameTypeDescription
identifierstringThe identifier of the epoch.

Returns

NameTypeDescription
epochNumberint64The current epoch number.
startTimestampint64The epoch start time in unix.
endTimestampint64The 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

NameTypeDescription
epochNumberint64The epoch number.
startTimeint64The 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

NameTypeDescription
epochNumberint64The epoch number.
endTimeint64The epoch end time in unix.