Ring Protocol
Search
K
Comment on page

Timed

A timer utility for keeping track of elapsed time within a window

Contract

Timed.sol

Description

Abstract contract for managing timed events that complete after a period
The contract has a duration d denominated in seconds. It has an effective timestamp t on the range [0,d]. After the period has ended, t stays fixed at d.
When it is initialized, it sets the current block timestamp to t=0. The remaining time is d-t and the completion condition is remaining = 0 (t=d).

Events

DurationUpdate
TimerReset
Change in the duration of the timer
type
param
description
uint256
_duration
new duration
A reset of the timer
type
param
description
uint256
_startTime
new timer start

Read-Only Functions

isTimeEnded

function isTimeEnded() external view returns (bool);
Returns true if elapsed time t is equal to the duration d.

startTime

function startTime() external view returns (uint256);
Returns the starting block timestamp of the window.

duration

function duration() external view returns (uint256);
Returns the duration d of the window.

timeSinceStart

function timeSinceStart() external view returns (uint256);
Returns the elapsed time t since the startTime, with d as the maximum.

remainingTime

function remainingTime() external view returns (uint256);
Returns the time remaining in the window t - d.

ABIs

timed.json
1KB
Code
Timed