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);
Parameter | Type | Description |
---|---|---|
minDelay | uint256 | Initial minimum delay required for scheduled operations. |
proposers | address[] | Array of addresses granted the PROPOSER_ROLE . |
executors | address[] | Array of addresses granted the EXECUTOR_ROLE . |
admin | address | Address 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);
Parameter | Type | Description |
---|---|---|
target | address | Address of the target contract for the call. |
value | uint256 | Amount of ETH to send with the call. |
data | bytes | Encoded function call data for the target. |
predecessor | bytes32 | ID of the predecessor operation, if any. |
salt | bytes32 | Salt value used for operation uniqueness. |
delay | uint256 | Delay 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);
Parameter | Type | Description |
---|---|---|
targets | address[] | Array of target contract addresses for each call. |
values | uint256[] | Array of ETH amounts to send with each call. |
payloads | bytes[] | Array of encoded function call data for each target. |
predecessor | bytes32 | ID of the predecessor operation, if any. |
salt | bytes32 | Salt value used for operation uniqueness. |
delay | uint256 | Delay 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);
Parameter | Type | Description |
---|---|---|
target | address | Address of the target contract for the call. |
value | uint256 | Amount of ETH to send with the call. |
data | bytes | Encoded function call data for the target. |
predecessor | bytes32 | ID of the predecessor operation, if any. |
salt | bytes32 | Salt 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);
Parameter | Type | Description |
---|---|---|
targets | address[] | Array of target contract addresses for each call. |
values | uint256[] | Array of ETH amounts to send with each call. |
payloads | bytes[] | Array of encoded function call data for each target. |
predecessor | bytes32 | ID of the predecessor operation, if any. |
salt | bytes32 | Salt value used for operation uniqueness. |
Cancellation and Delay Management
cancel
Cancels a pending operation.
function cancel(bytes32 id);
Parameter | Type | Description |
---|---|---|
id | bytes32 | ID of the operation to cancel. |
updateDelay
Updates the minimum delay for future operations.
function updateDelay(uint256 newDelay);
Parameter | Type | Description |
---|---|---|
newDelay | uint256 | New minimum delay required for future operations. |