How to deploy a Governor contract?

Hi, i am following OpenZeppelin’s Governor tutorial to deploy a governor contract and use it with Time Lock Controller and ERC20 contract. But I'm having trouble while deploying the governor contract.

I have already deployed my ERC20 and TimelockController contract to rinkeby testnet. But i could not deploy the governance contract. I think I'm getting error because i assign the wrong values to the constructor while deploying. Here is the constructor of governance contract and hardhat deployment file.I would appreciate if anybody could help me how to deploy the governance contract.

:1234: Governance Contract

 // SPDX-License-Identifier: MIT
pragma solidity ^0.8.3;

contract MyGovernor is Governor, GovernorCompatibilityBravo, GovernorVotes, GovernorVotesQuorumFraction, GovernorTimelockControl {
    constructor(IVotes _token, TimelockController _timelock)
        
        Governor("MyGovernor")
        GovernorVotes(_token)
        GovernorVotesQuorumFraction(4)
        GovernorTimelockControl(_timelock)
    {}

}

:1234: Deployment File

async function main() {

    const MyTokenAddress = '0xfF24a23BA6648246C605ad6d7db640313FbA7C91';
    const MyToken = await ethers.getContractFactory('contracts/MyToken.sol:MyToken');
    const myToken = await MyToken.attach(MyTokenAddress);


    const TimelockAddress = '0x36A373B51CB42eA098A2e63Bae5D6Fd8c8A7E211';
    const TimelockController = await ethers.getContractFactory('contracts/TimelockController.sol:TimelockController');
    const timelockController = await TimelockController.attach(TimelockAddress);

    // We get the contract to deploy
    const MyGovernor = await ethers.getContractFactory(myToken,timelockController);
    console.log("Deploying MyGovernor");
    const myGovernor = await MyGovernor.deploy();
    console.log("MyGovernor deployed to:", myGovernor.address);
  
  }

:computer: Environment
Rinkeby, Hardhat and ethers.js

Think this should be MyGovernor.deploy(myToken,timelockController) and remove the params from contract factory call.

Yeah, just like kiko said above, and also add await myGovernor.deployed()

I changed it as above but still get errors.

code=INVALID_ARGUMENT, version=contracts/5.5.0)
    at Logger.makeError (/Users/rojhat/node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
    at Logger.throwError (/Users/rojhat/node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
    at Logger.throwArgumentError (/Users/rojhat/node_modules/@ethersproject/logger/src.ts/index.ts:241:21)
    at /Users/rojhat/node_modules/@ethersproject/contracts/src.ts/index.ts:120:16
    at step (/Users/rojhat/node_modules/@ethersproject/contracts/lib/index.js:48:23)
    at Object.next (/Users/rojhat/node_modules/@ethersproject/contracts/lib/index.js:29:53)
    at fulfilled (/Users/rojhat/node_modules/@ethersproject/contracts/lib/index.js:20:58) {
  reason: 'invalid address or ENS name',
  code: 'INVALID_ARGUMENT',
  argument: 'name',

Deployment File


async function main() {

    const MyTokenAddress = '0xfF24a23BA6648246C605ad6d7db640313FbA7C91';
    const MyToken = await ethers.getContractFactory('contracts/MyToken.sol:MyToken');
    const myToken = await MyToken.attach(MyTokenAddress);


    const TimelockAddress = '0x36A373B51CB42eA098A2e63Bae5D6Fd8c8A7E211';
    const TimelockController = await ethers.getContractFactory('contracts/TimelockController.sol:TimelockController');
    const timelockController = await TimelockController.attach(TimelockAddress);

    // We get the contract to deploy
    const MyGovernor = await ethers.getContractFactory("MyGovernor");
    console.log("Deploying MyGovernor");
    const myGovernor = await MyGovernor.deploy(myToken,timelockController)
    const deployedGovernor  = await myGovernor.deployed()
    console.log("MyGovernor deployed to:", myGovernor.address);
  
  }
  
  main()
    .then(() => process.exit(0))
    .catch((error) => {
      console.error(error);
      process.exit(1);
    });

I am also doing the same action

Hi, i solved the issue with changing the code as below. Thanks again for the replies.

async function main() {
    const MyGovernor = await ethers.getContractFactory("MyGovernor");
    console.log("Deploying MyGovernor");
    const myGovernor = await MyGovernor.deploy("0xfF24...","0x36A...");
    const deployedGovernor  = await myGovernor.deployed()
    console.log("MyGovernor deployed to:", myGovernor.address);
  }