Timelocks

Explanation: What is a Timelock Contract, How Does It Work, What does it do?

Timelock Smart Contract Mechanism:

A timelock smart contract serves as an effective mechanism to introduce a delay system for executing function calls on other smart contracts. This unique contract structure establishes a predefined minimum time delay requirement before a scheduled operation can proceed.

Functionality of a Timelock Contract:

While the Timelock contract does not fall strictly under the category of MultiSig/Voting Contracts, it closely adheres to the fundamental principles outlined in CW3-spec compliant contracts. Rather than facilitating immediate execution, this contract allows addresses to propose or schedule operations, which subsequently undergo a specified delay period before final execution can take place.

Timelock Contract Instantiation:

Initial Configuration

Upon the deployment of the Timelock contract, the following parameters can be configured:

Minimum Time Delay: Set a predefined time delay before operations can be executed.

Administrators and Proposers: Assign addresses to fulfill these roles. Operations can only be scheduled by proposers if their execution time exceeds the set delay.

Administrators

Administrators are responsible for the initial setup and ensuring compatibility with potential target contracts. In the absence of specified addresses, the contract initiator automatically assumes the role of administrator. Once the configuration is complete, administrators have the authority to freeze the Timelock, rendering it immutable. This action is irreversible and can render the contract non-modifiable.

Proposers

Proposers are tasked with scheduling operations to be executed after the specified delay. It's crucial to ensure that the Timelock contract possesses the necessary permissions on the target contracts. Additionally, propellers should specify executor addresses responsible for the final execution of operations on the target contract. In cases where no executor is specified, any address can carry out the operation once the scheduled time arrives.

It's important to note that scheduling operations with the Timelock does not guarantee their execution. Proposers retain the option to cancel scheduled operations before they are executed. Therefore, the selection of responsible proposers holds significant importance in this context.

InstantiateMsg

ExecuteMsg

Example

To generate a CosmWasm timelocks contract, you can prepare the following files: lib.rs, contract.rs, msg.rs, error.rs, and state.rs.

lib.rs

contract.rs

msg.rs

state.rs

Attribution: 'CosmWasm by Example' provides access to the code on GitHub.

Last updated

Was this helpful?