# AUT\_EXT\_VotingRoles\_v1.sol

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

**Inherits:** IAUT\_EXT\_VotingRoles\_v1, Module\_v1

**Author:** Inverter Network

Facilitates voting and motion management within the Inverter Network, allowing designated voters to participate in governance through proposals, voting, and execution of decisions.

*Supports setting thresholds for decision-making, managing voter lists, creating motions, casting votes, and executing actions based on collective decisions. This structure enhances governance transparency and efficacy.*

### State Variables

#### MAX\_VOTING\_DURATION

The maximum voting duration.

```solidity
uint public constant MAX_VOTING_DURATION = 2 weeks;
```

#### MIN\_VOTING\_DURATION

The minimum voting duration.

```solidity
uint public constant MIN_VOTING_DURATION = 1 days;
```

#### isVoter

Checks whether an address is a voter.

```solidity
mapping(address => bool) public isVoter;
```

#### motions

Gets the motion data.

```solidity
mapping(bytes32 => Motion) public motions;
```

#### motionCount

Gets the number of motions.

```solidity
uint public motionCount;
```

#### voterCount

Gets the number of voters.

```solidity
uint public voterCount;
```

#### threshold

Gets the threshold.

```solidity
uint public threshold;
```

#### voteDuration

Gets the voting duration.

```solidity
uint public voteDuration;
```

#### \_\_gap

*Storage gap for future upgrades.*

```solidity
uint[50] private __gap;
```

### Functions

#### supportsInterface

*See {IERC165-supportsInterface}.*

```solidity
function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(Module_v1)
    returns (bool);
```

#### onlySelf

*Reverts if caller is not the module itself.*

```solidity
modifier onlySelf();
```

#### onlyVoter

*Reverts if caller is not a voter.*

```solidity
modifier onlyVoter();
```

#### isValidVoterAddress

*Reverts if voter address is invalid.*

```solidity
modifier isValidVoterAddress(address voter);
```

**Parameters**

| Name    | Type      | Description           |
| ------- | --------- | --------------------- |
| `voter` | `address` | The address to check. |

#### init

```solidity
function init(
    IOrchestrator_v1 orchestrator_,
    Metadata memory metadata,
    bytes memory configData
) external override initializer;
```

#### getReceipt

Gets the receipt of a voter for a motion.

```solidity
function getReceipt(bytes32 _ID, address voter)
    public
    view
    returns (Receipt memory);
```

**Parameters**

| Name    | Type      | Description               |
| ------- | --------- | ------------------------- |
| `_ID`   | `bytes32` | The ID of the motion.     |
| `voter` | `address` | The address of the voter. |

**Returns**

| Name     | Type      | Description               |
| -------- | --------- | ------------------------- |
| `<none>` | `Receipt` | The receipt of the voter. |

#### setThreshold

Sets the threshold.

```solidity
function setThreshold(uint newThreshold) public onlySelf;
```

**Parameters**

| Name           | Type      | Description        |
| -------------- | --------- | ------------------ |
| `newThreshold` | `uint256` | The new threshold. |

#### setVotingDuration

Sets the voting duration.

```solidity
function setVotingDuration(uint newVoteDuration) external onlySelf;
```

**Parameters**

| Name              | Type      | Description              |
| ----------------- | --------- | ------------------------ |
| `newVoteDuration` | `uint256` | The new voting duration. |

#### addVoter

Adds a voter.

```solidity
function addVoter(address who) public onlySelf isValidVoterAddress(who);
```

**Parameters**

| Name  | Type      | Description         |
| ----- | --------- | ------------------- |
| `who` | `address` | The address to add. |

#### addVoterAndUpdateThreshold

Adds a voter and updates the threshold.

```solidity
function addVoterAndUpdateThreshold(address who, uint newThreshold) external;
```

**Parameters**

| Name           | Type      | Description         |
| -------------- | --------- | ------------------- |
| `who`          | `address` | The address to add. |
| `newThreshold` | `uint256` | The new threshold.  |

#### removeVoter

Removes a voter.

```solidity
function removeVoter(address who) public onlySelf;
```

**Parameters**

| Name  | Type      | Description            |
| ----- | --------- | ---------------------- |
| `who` | `address` | The address to remove. |

#### removeVoterAndUpdateThreshold

Removes a voter and updates the threshold.

```solidity
function removeVoterAndUpdateThreshold(address who, uint newThreshold)
    external
    onlySelf;
```

**Parameters**

| Name           | Type      | Description            |
| -------------- | --------- | ---------------------- |
| `who`          | `address` | The address to remove. |
| `newThreshold` | `uint256` | The new threshold.     |

#### \_removeVoter

*Removes a voter from the list of voters.*

```solidity
function _removeVoter(address who) internal;
```

**Parameters**

| Name  | Type      | Description                         |
| ----- | --------- | ----------------------------------- |
| `who` | `address` | The address of the voter to remove. |

#### createMotion

Creates a motion.

```solidity
function createMotion(address target, bytes calldata action)
    external
    onlyVoter
    returns (bytes32);
```

**Parameters**

| Name     | Type      | Description                                           |
| -------- | --------- | ----------------------------------------------------- |
| `target` | `address` | The address of the contract to execute the action on. |
| `action` | `bytes`   | The action data to execute on the target contract.    |

**Returns**

| Name     | Type      | Description                   |
| -------- | --------- | ----------------------------- |
| `<none>` | `bytes32` | The ID of the created motion. |

#### castVote

Casts a vote for a motion.

```solidity
function castVote(bytes32 motionId, uint8 support) external onlyVoter;
```

**Parameters**

| Name       | Type      | Description                                                    |
| ---------- | --------- | -------------------------------------------------------------- |
| `motionId` | `bytes32` | The ID of the motion.                                          |
| `support`  | `uint8`   | The value that indicates wether the voter supports the motion. |

#### executeMotion

Executes a motion.

```solidity
function executeMotion(bytes32 motionId) external;
```

**Parameters**

| Name       | Type      | Description           |
| ---------- | --------- | --------------------- |
| `motionId` | `bytes32` | The ID of the motion. |

#### \_validateThreshold

*Internal function to validate the threshold.*

```solidity
function _validateThreshold(uint _voters, uint _threshold) internal pure;
```

**Parameters**

| Name         | Type      | Description           |
| ------------ | --------- | --------------------- |
| `_voters`    | `uint256` | The number of voters. |
| `_threshold` | `uint256` | The threshold.        |


---

# 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/authorizer/role/aut_ext_votingroles_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.
