Multiple inheritance for a governance token

Hello,
I would like to deploy a token that in the future will be upgraded to have governance functionality.

Is this correct?

import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20PausableUpgradeable.sol";

contract MyToken is Initializable, AccessControlUpgradeable, ERC20PausableUpgradeable {
    using SafeMathUpgradeable for uint256;

    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
    bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

    function initialize(string memory name, string memory symbol) public initializer {
        __ERC20_init(name, symbol);

        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(MINTER_ROLE, _msgSender());
        _setupRole(PAUSER_ROLE, _msgSender());
    }

}
1 Like

Hi @jev9,

When doing multiple inheritance you would need to call the unchained initializers.
https://docs.openzeppelin.com/contracts/4.x/upgradeable#multiple-inheritance

See the example of the preset contract:

This is great, will be using the preset to avoid such mistakes exactly

Thanks a lot.

1 Like