Constructor "IVotes" Not Found or Not Unique

Hello!

I'm trying to compile my smart contract that was created in OpenZeppelin using their Contracts wizard. The contract is a Governor contract for a DAO as a test on the Ropsten testnet. I am using Truffle and Ganache.

Here is my code that was given back to me from the OZ Wizard:

// SPDX-License-Identifier: MIT
pragma solidity >=0.4.0 <0.9.0;

import "@openzeppelin/contracts/governance/Governor.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorSettings.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorCountingSimple.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotes.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorVotesQuorumFraction.sol";
import "@openzeppelin/contracts/governance/extensions/GovernorTimelockControl.sol";

/// @custom:security-contact Pavon Dunbar
contract PavonDAO is Governor, GovernorSettings, GovernorCountingSimple, GovernorVotes, GovernorVotesQuorumFraction, GovernorTimelockControl {
    constructor(IVotes _token, TimelockController _timelock)
        Governor("PavonDAO")
        GovernorSettings(1 /* 1 block */, 45818 /* 1 week */, 10e18)
        GovernorVotes(_token)
        GovernorVotesQuorumFraction(8)
        GovernorTimelockControl(_timelock)
    {}

    ...

When I try to compile the contract using

truffle test --network ropsten

I am met with this error and the compilation fails.

DeclarationError: Identifier not found or not unique.
  --> project:/contracts/PavonDAO.sol:13:17:
   |
13 |     constructor(IVotes _token, TimelockController _timelock)
   |                 ^^^^^^

Compilation failed. See above.
Truffle v5.4.31 (core: 5.4.31)
Node v16.9.1

THE ONLY THING I CHANGED was the solidity versions in the contract. But even when I reverted back to the original version, I was met with the same error.

Thanks in advance to anyone who responds.

Pavon

Had a similar issue. Upgrade your openzeppelin using the following npm command: npm install @openzeppelin/contracts update. Then add this import statement into your Governor contract: import "@openzeppelin/contracts/governance/utils/IVotes.sol";

Hope this helps!

2 Likes

Just have a test on the Remix, it can be compiled.

so how about installing the latest version of the openzeppelin/contracts to have a try?

1 Like

I will try updating OpenZeppelin as you both recommended. Thank you for your responses. I appreciate it a lot.

Have a great day, @Trapper_Tribiani and @Skyge , and much success to the both of you!

Pavon

1 Like