0Pricing
Web3 & DApp Development Fundamentals · Leçon

Verrous temporels et exécution

Mises à niveau sûres

Verrous temporels et exécution est une leçon Web3 & DApp Development Fundamentals gratuite sur CoddyKit. Ceci est la leçon 4 sur 4. Tu peux lire la leçon complète ci-dessous gratuitement — puis la pratiquer en direct dans le navigateur avec un éditeur de code intégré et un tuteur IA 24/7. Elle fait partie du parcours d'apprentissage Web3 & DApp Development Fundamentals, et ta progression se synchronise sur le web et l'application CoddyKit. Le cours Web3 & DApp Development Fundamentals comprend 4 leçons au total.

Certaines parties de cette leçon n'ont pas encore été traduites et s'affichent en anglais.

Why Timelocks Exist

A timelock is a mandatory delay between when a proposal passes and when it executes.

It protects users by giving them time to react to changes they disagree with — for example, withdrawing funds before a risky upgrade.

The TimelockController

OpenZeppelin's TimelockController is a contract that schedules, delays, and then executes operations.

The Governor proposes and queues actions into the timelock, which actually owns the protocol's admin rights.

contract Timelock is TimelockController {
    constructor(uint minDelay, address[] proposers, address[] executors)
        TimelockController(minDelay, proposers, executors, msg.sender) {}
}

Schedule, Wait, Execute

Operations flow through three steps:

  • schedule — queue the action with a delay
  • wait — the minDelay must elapse
  • execute — run the action after the delay
timelock.schedule(target, value, data, predecessor, salt, delay);
// ... wait minDelay ...
timelock.execute(target, value, data, predecessor, salt);

The minDelay Parameter

The minDelay sets how long every scheduled operation must wait. Common values range from 1 to 7 days.

Longer delays mean more safety but slower governance — a deliberate trade-off each DAO must tune.

Roles in the Timelock

The timelock uses access roles:

  • PROPOSER — can schedule operations (the Governor)
  • EXECUTOR — can run them after the delay
  • ADMIN — manages roles (often renounced)

Timelock Owns the Protocol

For governance to be meaningful, the timelock contract should hold the protocol's admin and ownership rights — not any individual.

This ensures every privileged change must pass through the full govern-then-delay pipeline.

protocol.transferOwnership(
    address(timelock)
);

Defense Against Malicious Proposals

If an attacker sneaks a harmful proposal through voting, the timelock delay is the last line of defense.

The community can spot the queued action and exit or coordinate a response before it executes.

Predecessor and Salt

Each scheduled operation can specify a predecessor (an operation that must run first) and a salt to make its identifier unique.

These let DAOs order dependent operations and avoid hash collisions between similar actions.

Cancelling Operations

A scheduled operation can be cancelled before execution by an address with the canceller role.

This provides an emergency brake if a queued action is found to be dangerous during the delay window.

timelock.cancel(operationId);

Upgrades Done Safely

Combining Governor + Timelock + a proxy pattern lets DAOs upgrade contracts safely: vote, queue, delay, then execute the upgrade.

Every step is transparent and reversible up until execution, balancing flexibility with security.

Putting It Together

The timelock enforces a delay between approval and execution, owns the protocol's privileges, and uses roles plus cancellation to keep upgrades safe.

It is the crucial buffer that makes on-chain governance trustworthy.

Quick Check

Test your timelock understanding.

Recap: Timelocks and Execution

You learned that:

  • A timelock delays execution after a proposal passes
  • TimelockController schedules, waits, then executes
  • minDelay tunes the safety vs speed trade-off
  • The timelock should own the protocol; roles control access
  • Operations can be cancelled during the delay

Course complete! Next course: Layer 2 and Scaling.

Questions Fréquemment Posées

La leçon « Verrous temporels et exécution » est-elle gratuite ?

Oui — le texte complet de « Verrous temporels et exécution » est gratuit à lire ici sur le web. Pour la pratiquer de manière interactive (un éditeur de code intégré et un tuteur IA 24/7) et déverrouiller le reste du cours Web3 & DApp Development Fundamentals, passe à CoddyKit PRO. Le cours Web3 & DApp Development Fundamentals comprend 4 leçons au total.

Qu'est-ce que j'apprendrai dans « Verrous temporels et exécution » ?

Mises à niveau sûres Tu pratiques Web3 & DApp Development Fundamentals avec du code pratique que tu exécutes directement dans le navigateur, et un tuteur IA 24/7 répond à tes questions au fur et à mesure que tu avances dans la leçon.

Dois-je avoir de l'expérience pour commencer Web3 & DApp Development Fundamentals ?

Aucune expérience préalable n'est requise. Web3 & DApp Development Fundamentals sur CoddyKit est structuré pour les débutants jusqu'aux apprenants avancés, donc tu peux commencer ici ou depuis le début et avancer à ton rythme. Ceci est la leçon 4 sur 4.

Combien de temps prend la leçon « Verrous temporels et exécution » ?

La plupart des leçons CoddyKit prennent environ 5–10 minutes. Chacune est courte et interactive, tu progresses régulièrement et tu repiques exactement où tu t'es arrêté sur le web et l'app.

Peux-tu écrire et exécuter du code dans cette leçon Web3 & DApp Development Fundamentals ?

Oui. Chaque leçon Web3 & DApp Development Fundamentals inclut un éditeur de code intégré, tu écris et exécutes du vrai code directement dans ton navigateur et tu reçois des retours IA instantanés — aucune configuration locale requise.

Toutes les leçons de ce cours

  1. Qu’est-ce qu’une DAO
  2. Jetons de gouvernance
  3. Propositions et vote
  4. Verrous temporels et exécution
← Retour à Web3 & DApp Development Fundamentals