Skip to main content

Timelock Contract Reference Documentation

Overview

The TimelockControllerEnumerable contract combines Open Zeppelin's TimelockController with AccessControlEnumerable to provide role-based access control, supporting both single and batch operations with a minimum delay requirement. It is designed for time-sensitive governance operations, often positioned as the owner of a contract governed by a DAO or multisig.

Inherits: TimelockController, AccessControlEnumerable

Key Roles

  • TIMELOCK_ADMIN_ROLE: Manages and configures timelock settings.
  • PROPOSER_ROLE: Schedules proposals.
  • EXECUTOR_ROLE: Executes approved proposals.
  • CANCELLER_ROLE: Cancels pending proposals.

Events

  • CallScheduled: Emitted when a call is scheduled.
  • CallExecuted: Emitted upon execution of a scheduled call.
  • Cancelled: Emitted when an operation is cancelled.
  • MinDelayChange: Emitted when the minimum delay changes.

Functions

Constructor

Initializes the contract with the minimum delay and role assignments.

constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin);
ParameterTypeDescription
minDelayuint256Initial minimum delay required for scheduled operations.
proposersaddress[]Array of addresses granted the PROPOSER_ROLE.
executorsaddress[]Array of addresses granted the EXECUTOR_ROLE.
adminaddressAddress given the TIMELOCK_ADMIN_ROLE.

Scheduling and Execution

schedule

Schedules a single transaction for execution.

function schedule(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt, uint256 delay);
ParameterTypeDescription
targetaddressAddress of the target contract for the call.
valueuint256Amount of ETH to send with the call.
databytesEncoded function call data for the target.
predecessorbytes32ID of the predecessor operation, if any.
saltbytes32Salt value used for operation uniqueness.
delayuint256Delay in seconds before the operation can be executed.

scheduleBatch

Schedules a batch of transactions for execution.

function scheduleBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata payloads, bytes32 predecessor, bytes32 salt, uint256 delay);
ParameterTypeDescription
targetsaddress[]Array of target contract addresses for each call.
valuesuint256[]Array of ETH amounts to send with each call.
payloadsbytes[]Array of encoded function call data for each target.
predecessorbytes32ID of the predecessor operation, if any.
saltbytes32Salt value used for operation uniqueness.
delayuint256Delay in seconds before the batch operation can be executed.

execute

Executes a scheduled transaction.

function execute(address target, uint256 value, bytes calldata data, bytes32 predecessor, bytes32 salt);
ParameterTypeDescription
targetaddressAddress of the target contract for the call.
valueuint256Amount of ETH to send with the call.
databytesEncoded function call data for the target.
predecessorbytes32ID of the predecessor operation, if any.
saltbytes32Salt value used for operation uniqueness.

executeBatch

Executes a scheduled batch of transactions.

function executeBatch(address[] calldata targets, uint256[] calldata values, bytes[] calldata payloads, bytes32 predecessor, bytes32 salt);
ParameterTypeDescription
targetsaddress[]Array of target contract addresses for each call.
valuesuint256[]Array of ETH amounts to send with each call.
payloadsbytes[]Array of encoded function call data for each target.
predecessorbytes32ID of the predecessor operation, if any.
saltbytes32Salt value used for operation uniqueness.

Cancellation and Delay Management

cancel

Cancels a pending operation.

function cancel(bytes32 id);
ParameterTypeDescription
idbytes32ID of the operation to cancel.

updateDelay

Updates the minimum delay for future operations.

function updateDelay(uint256 newDelay);
ParameterTypeDescription
newDelayuint256New minimum delay required for future operations.