Ring Protocol
Search…
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

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

startTime

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

duration

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

timeSinceStart

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

remainingTime

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

ABIs

timed.json
1KB
Binary
Timed
Last modified 4mo ago