# StartupGovernor

[Git Source](https://github.com/EntreDevelopers-Lab-Inc/Mezz-Companies/blob/f7a3e84e3dd5bb33c4bd7f77283983f9e8ba20b2/src/core/governance/startup/StartupGovernor.sol)

**Inherits:** MezzGovernor, MezzEIP712, NoncesUpgradeable, IStartupGovernor

**Author:** Daniel Yamagata

A governance contract that enables the execution of arbitrary transactions by a super-majority of a treasury's signers. A super majority is counted as two-thirds of the signers rounded upwards. Below is a table with a few examples.

| Signers | Super Majority |
| ------- | -------------- |
| 2       | 2              |
| 3       | 2              |
| 4       | 3              |
| 5       | 4              |
| 6       | 4              |

*The execution of transactions requires an arbitrary deadline. If this deadline passes, the transaction will revert even if provided the correct number of signatures.*

## State Variables

### EXECUTE\_TYPEHASH

```solidity
bytes32 public constant EXECUTE_TYPEHASH =
    keccak256("Execute(address target,uint256 value,bytes data,uint256 deadline,uint256 nonce)");
```

## Functions

### constructor

```solidity
constructor(address _mezzHub, address _mezzMigrator) MezzGovernor(_mezzHub, _mezzMigrator);
```

### init

Intializes the Governor's state

```solidity
function init(address initTreasury, bytes memory) external virtual override initializer;
```

**Parameters**

| Name           | Type      | Description                                                   |
| -------------- | --------- | ------------------------------------------------------------- |
| `initTreasury` | `address` | The address of the Treasury that the Governor is in charge of |
| `<none>`       | `bytes`   |                                                               |

### \_\_Startup\_Governor\_init

*The 'params' argument is maintained in case future versions require additional initialization parameters*

```solidity
function __Startup_Governor_init(address initTreasury, bytes memory) internal virtual onlyInitializing;
```

### executeTx

Executes an arbitrary transaction. Requires a super majority of board members to sign off

*Signatures must be packed in ascending order of the public addresses of the signers and must be packed into a single variable.*

```solidity
function executeTx(address target, uint256 value, bytes memory data, bytes memory signatures, uint256 deadline)
    public
    virtual
    freezable
    returns (bytes memory);
```

**Parameters**

| Name         | Type      | Description                                                |
| ------------ | --------- | ---------------------------------------------------------- |
| `target`     | `address` | The target address to execute the transaction on           |
| `value`      | `uint256` | The amount of native currency to send with the transaction |
| `data`       | `bytes`   | The calldata of the transaction                            |
| `signatures` | `bytes`   | The signatures of the board members                        |
| `deadline`   | `uint256` |                                                            |

**Returns**

| Name     | Type    | Description                        |
| -------- | ------- | ---------------------------------- |
| `<none>` | `bytes` | The return data of the transaction |

### \_checkNSignatures

*Validates the 'signatures' and the number of required signatures for 'safeCache', '\_hash', and '\_hashData'*

```solidity
function _checkNSignatures(address safeCache, bytes32 dataHash, bytes memory signatures, uint256 requiredSigs)
    internal
    view
    virtual;
```

### \_execute

*Executes a call on a given 'target' with 'data' and 'value'. Reverts if the call fails or the target's code length is zero*

```solidity
function _execute(address target, uint256 value, bytes memory data) internal virtual returns (bytes memory);
```

### getExecuteTransactionHash

Returns the transaction hash of the encoded execute data.

*This hash is the one to be signed by a private key. Signatures should then be packed in ascending order by the public keys of the owners when calling executeTx()*

```solidity
function getExecuteTransactionHash(DataTypes.StartupGovernorExecute memory execute)
    public
    view
    virtual
    returns (bytes32);
```

**Parameters**

| Name      | Type                               | Description                               |
| --------- | ---------------------------------- | ----------------------------------------- |
| `execute` | `DataTypes.StartupGovernorExecute` | The StartupGovernorExecute struct to hash |

### encodeExecuteData

Encodes a StartupGovernorExecute struct hash following the EIP-191 signed typed data standard

*Reference: <https://eips.ethereum.org/EIPS/eip-191>*

```solidity
function encodeExecuteData(DataTypes.StartupGovernorExecute memory execute)
    public
    view
    virtual
    returns (bytes memory);
```

**Parameters**

| Name      | Type                               | Description                                                       |
| --------- | ---------------------------------- | ----------------------------------------------------------------- |
| `execute` | `DataTypes.StartupGovernorExecute` | The StartupGovernorExecute struct to hash and subsequently encode |

### getExecuteStructHash

Returns the hash of a StartupGovernorExecute struct following the EIP-712 encoding standards

*Reference: <https://eips.ethereum.org/EIPS/eip-712>*

```solidity
function getExecuteStructHash(DataTypes.StartupGovernorExecute memory execute) public view virtual returns (bytes32);
```

**Parameters**

| Name      | Type                               | Description                               |
| --------- | ---------------------------------- | ----------------------------------------- |
| `execute` | `DataTypes.StartupGovernorExecute` | The StartupGovernorExecute struct to hash |

### coreId

Returns the coreId of the implementation as a bytes32

*The core ID is the keccak256 hash of the contract name followed by a version under the following syntax: "mezzanine.coreId.ContractName.vX" For example, the core ID of the 2nd version of the Treasury would be the following: keccak256(abi.encodePacked("mezzanine.coreId.Treasury.v2"))*

```solidity
function coreId() public pure virtual override(Credentialed, ICredentialed) returns (bytes32);
```

### version

Returns the version of the implementation as a uint256

```solidity
function version() public pure virtual override(Credentialed, ICredentialed) returns (uint256);
```

### onERC721Received

*Reference: <https://eips.ethereum.org/EIPS/eip-721>*

```solidity
function onERC721Received(address, address, uint256, bytes memory) public view virtual returns (bytes4);
```

### onERC1155Received

*Reference: <https://eips.ethereum.org/EIPS/eip-1155>*

```solidity
function onERC1155Received(address, address, uint256, uint256, bytes memory) public view virtual returns (bytes4);
```

### onERC1155BatchReceived

*Reference: <https://eips.ethereum.org/EIPS/eip-1155>*

```solidity
function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory)
    public
    view
    virtual
    returns (bytes4);
```

### supportsInterface

*ERC165 support*

```solidity
function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(MezzEIP712, MezzUUPSUpgradeable, IERC165)
    returns (bool);
```


---

# 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.mezzanine.xyz/smart-contracts/source-code/core/mezzgovernor/startupgovernor.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.
