Skip to main content

SetupGovernance

This is a guide to setting up the TimeLock contract for use with the Governor contract. The TimeLock contract is used to delay the execution of transactions proposed by the Governor contract. This is done to give users a chance to review the transactions before they are executed. The TimeLock contract is also used to ensure that the Governor contract cannot execute transactions that have not been proposed by the Governor contract.

const { ethers } = require("hardhat");

const ADDRESS_ZERO = "0x0000000000000000000000000000000000000000";
module.exports = async function (hre) {
// @ts-ignore
const { getNamedAccounts, deployments } = hre;
const { log } = deployments;
const { deployer } = await getNamedAccounts();

const timeLock = await ethers.getContract("TimeLock", deployer);
const governor = await ethers.getContract("GovernorContract", deployer);

log("----------------------------------------------------");
log("Setting up contracts for roles...");
// would be great to use multicall here...
const proposerRole = await timeLock.PROPOSER_ROLE();
const executorRole = await timeLock.EXECUTOR_ROLE();
const adminRole = await timeLock.TIMELOCK_ADMIN_ROLE();

// Grant proposer role to governor so that it can propose and execute transactions
const proposerTx = await timeLock.grantRole(proposerRole, governor.address);
await proposerTx.wait(1);

//Grant executor role to nobody so that anyone can execute transactions
const executorTx = await timeLock.grantRole(executorRole, ADDRESS_ZERO);
await executorTx.wait(1);

// Grant revoke role to admin
const revokeTx = await timeLock.revokeRole(adminRole, deployer);
await revokeTx.wait(1);
};

module.exports.tags = ["all", "setup", "main"];