---
# System prepended metadata

title: V3 Initializers

---

# V3 Initializers

## Module Implementators TLDR

Initializable modules should:
* Inherit `InitializableMixin` (see below)
* Override the internal function `_isInitialized()`
* Implement an external/public view called is***ModuleName***Initialized() that returns a bool
* Implement an external/public called initialize***ModuleName***(...)

i.e. 
```solidity=
contract SampleModule is InitializableMixin {
    ...
    
    function initializeSampleModule(address param1, address param2, uint param3) external onlyIfNotInitialized {
        // Will reverti if called after initialization
        // ...
         
        // Set initialized. This can be logically derived from other params and not in a specific boolean. Showed as boolean to simplify the example
        _someStorage().initialized = true;
    }
    
    function isSampleModuleInitialized() external returns(bool) {
        return _isInitialized();
    }

    function _isInitialized() internal override returns(bool) {
        // isInitialized logic. This can be logically derived from other params and not in a specific boolean. Showed as boolean to simplify the example
        return(_someStorage().initialized);
    }

    ...
        
    function someFuntion() external onlyIfInitialized {
        // will revert unless the module was initialized
    }
    ...
    
} 
```


## InitializableMixin

InitializebleMixin adds two modifiers (`onlyIfInitialized` and `onlyIfNotInitialized`) and requires the implementation of the virtual function (`_isInitialized()`)

```solidity=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../errors/InitError.sol";

abstract contract InitializableMixin {
    modifier onlyIfInitialized() {
        if (!_isInitialized()) {
            revert InitError.NotInitialized();
        }

        _;
    }

    modifier onlyIfNotInitialized() {
        if (_isInitialized()) {
            revert InitError.AlreadyInitialized();
        }

        _;
    }

    function _isInitialized() internal virtual view returns(bool);
}
```

## Tooling 

### Deployer

The tooling will check if a module inherits the `InitializableMixin`. If a module inherits the mixin it should:
- Check if there's an external function named is***ModuleName***Initialized() that returns a bool
- Check if there's an external function named initialize***ModuleName***() (with or without parameters)

### CLI

The CLI will raise a warning when trying to interact with a initializable module that wasn't initialized.
