-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
Constructors are not used because they are generally not compatible with upgradeable contracts. However, some contracts require initialization, so users must write their own constructors.
We could include overridable _constructor functions in each contract. Possibly unimplemented, to force the user to override and make some decisions specific to the contract (and encourage setting immutable variables to replace certain storage accessors).
// _Ownable.sol
constructor () {
_Ownable();
}
function _Ownable () internal virtual;Or we could offer a library of composable initializers for users to import and call depending on which contracts they're using.
// Solidstate library
library Constructor {
function Ownable () {
_setOwner(msg.sender);
}
}
// user's contract
constructor () {
Constructor.Ownable();
}The former approach will cause problems with hardhat-exposed. The latter is error-prone, both on the user's end and in cases of API changes.
Metadata
Metadata
Assignees
Labels
No labels