# IModule\_v1.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/649b450f02fc8b735c128ff0821467e71966c666/src/modules/base/IModule_v1.sol)

### Functions

#### init

The module's initializer function.

*CAN be overridden by downstream contract.*

*MUST call `__Module_init()`.*

```solidity
function init(
    IOrchestrator_v1 orchestrator,
    Metadata memory metadata,
    bytes memory configData
) external;
```

**Parameters**

| Name           | Type               | Description                                               |
| -------------- | ------------------ | --------------------------------------------------------- |
| `orchestrator` | `IOrchestrator_v1` | The module's {Orchestrator\_v1} instance.                 |
| `metadata`     | `Metadata`         | The module's metadata.                                    |
| `configData`   | `bytes`            | Variable config data for specific module implementations. |

#### identifier

Returns the module's identifier.

*The identifier is defined as the keccak256 hash of the module's abi packed encoded major version, url and title.*

```solidity
function identifier() external view returns (bytes32);
```

**Returns**

| Name     | Type      | Description              |
| -------- | --------- | ------------------------ |
| `<none>` | `bytes32` | The module's identifier. |

#### version

Returns the module's version.

```solidity
function version() external view returns (uint, uint, uint);
```

**Returns**

| Name     | Type      | Description                 |
| -------- | --------- | --------------------------- |
| `<none>` | `uint256` | The module's major version. |
| `<none>` | `uint256` | The module's minor version. |
| `<none>` | `uint256` | The module's patch version. |

#### url

Returns the module's URL.

```solidity
function url() external view returns (string memory);
```

**Returns**

| Name     | Type     | Description       |
| -------- | -------- | ----------------- |
| `<none>` | `string` | The module's URL. |

#### title

Returns the module's title.

```solidity
function title() external view returns (string memory);
```

**Returns**

| Name     | Type     | Description         |
| -------- | -------- | ------------------- |
| `<none>` | `string` | The module's title. |

#### orchestrator

Returns the module's {Orchestrator\_v1} interface, {IOrchestrator\_v1}.

```solidity
function orchestrator() external view returns (IOrchestrator_v1);
```

**Returns**

| Name     | Type               | Description                     |
| -------- | ------------------ | ------------------------------- |
| `<none>` | `IOrchestrator_v1` | The module's {Orchestrator\_1}. |

#### grantModuleRole

Grants a module role to a target address.

```solidity
function grantModuleRole(bytes32 role, address target) external;
```

**Parameters**

| Name     | Type      | Description                              |
| -------- | --------- | ---------------------------------------- |
| `role`   | `bytes32` | The role to grant.                       |
| `target` | `address` | The target address to grant the role to. |

#### grantModuleRoleBatched

Grants a module role to multiple target addresses.

```solidity
function grantModuleRoleBatched(bytes32 role, address[] calldata targets)
    external;
```

**Parameters**

| Name      | Type        | Description                                |
| --------- | ----------- | ------------------------------------------ |
| `role`    | `bytes32`   | The role to grant.                         |
| `targets` | `address[]` | The target addresses to grant the role to. |

#### revokeModuleRole

Revokes a module role from a target address.

```solidity
function revokeModuleRole(bytes32 role, address target) external;
```

**Parameters**

| Name     | Type      | Description                                 |
| -------- | --------- | ------------------------------------------- |
| `role`   | `bytes32` | The role to revoke.                         |
| `target` | `address` | The target address to revoke the role from. |

#### revokeModuleRoleBatched

Revokes a module role from multiple target addresses.

```solidity
function revokeModuleRoleBatched(bytes32 role, address[] calldata targets)
    external;
```

**Parameters**

| Name      | Type        | Description                                   |
| --------- | ----------- | --------------------------------------------- |
| `role`    | `bytes32`   | The role to revoke.                           |
| `targets` | `address[]` | The target addresses to revoke the role from. |

### Events

#### ModuleInitialized

Module has been initialized.

```solidity
event ModuleInitialized(address indexed parentOrchestrator, Metadata metadata);
```

**Parameters**

| Name                 | Type       | Description                                                    |
| -------------------- | ---------- | -------------------------------------------------------------- |
| `parentOrchestrator` | `address`  | The address of the {Orchestrator\_v1} the module is linked to. |
| `metadata`           | `Metadata` | The metadata of the module.                                    |

#### ProtocolFeeTransferred

Event emitted when protocol fee has been transferred to the treasury.

```solidity
event ProtocolFeeTransferred(
    address indexed token, address indexed treasury, uint feeAmount
);
```

**Parameters**

| Name        | Type      | Description                                                   |
| ----------- | --------- | ------------------------------------------------------------- |
| `token`     | `address` | The token received as protocol fee.                           |
| `treasury`  | `address` | The protocol treasury address receiving the token fee amount. |
| `feeAmount` | `uint256` | The fee amount transferred to the treasury.                   |

### Errors

#### Module\_\_CallerNotAuthorized

Function is only callable by authorized caller.

```solidity
error Module__CallerNotAuthorized(bytes32 role, address caller);
```

**Parameters**

| Name     | Type      | Description                                    |
| -------- | --------- | ---------------------------------------------- |
| `role`   | `bytes32` | The role that is required.                     |
| `caller` | `address` | The address that is required to have the role. |

#### Module\_\_OnlyCallableByOrchestrator

Function is only callable by the {Orchestrator\_v1}.

```solidity
error Module__OnlyCallableByOrchestrator();
```

#### Module\_\_OnlyCallableByPaymentClient

Function is only callable by a {IERC20PaymentClientBase\_v1}.

```solidity
error Module__OnlyCallableByPaymentClient();
```

#### Module\_\_InvalidOrchestratorAddress

Given {Orchestrator\_v1} address invalid.

```solidity
error Module__InvalidOrchestratorAddress();
```

#### Module\_\_InvalidMetadata

Given metadata invalid.

```solidity
error Module__InvalidMetadata();
```

#### Module\_OrchestratorCallbackFailed

{Orchestrator\_v1} callback triggered failed.

```solidity
error Module_OrchestratorCallbackFailed(string funcSig);
```

**Parameters**

| Name      | Type     | Description                           |
| --------- | -------- | ------------------------------------- |
| `funcSig` | `string` | The signature of the function called. |

#### Module\_\_InvalidAddress

*Invalid Address.*

```solidity
error Module__InvalidAddress();
```

### Structs

#### Metadata

The module's metadata.

```solidity
struct Metadata {
    uint majorVersion;
    uint minorVersion;
    uint patchVersion;
    string url;
    string title;
}
```

**Properties**

| Name           | Type      | Description                 |
| -------------- | --------- | --------------------------- |
| `majorVersion` | `uint256` | The module's major version. |
| `minorVersion` | `uint256` | The module's minor version. |
| `patchVersion` | `uint256` | The module's patch version. |
| `url`          | `string`  | The module's URL.           |
| `title`        | `string`  | The module's title.         |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.inverter.network/contracts/technical-reference/modules/base/imodule_v1.sol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
