To incorporate multiple inheritance using OpenZeppelin upgradeable contracts, you can follow the below steps:
Here's an example:
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
contract MyNewContract is Initializable, OwnableUpgradeable, AccessControlUpgradeable {
bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
function initialize() initializer public {
__Ownable_init();
__AccessControl_init();
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(ADMIN_ROLE, msg.sender);
}
}
In the example above, "MyNewContract" is inheriting from "OwnableUpgradeable", "AccessControlUpgradeable", and "Initializable". The constant "ADMIN_ROLE" is also declared using the keccak256 hashing algorithm. Finally, the constructor "initialize()" is created using the "initializer" modifier from OpenZeppelin.
Asked: 2021-07-21 11:00:00 +0000
Seen: 9 times
Last updated: Jan 16 '22