# IMachineManager

> TEE machine registration and lifecycle.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.

Source: https://dev.flare.network/fcc/reference/IMachineManager

Public interface for `MachineManagerFacet` on the [`FlareTeeManager`](/fcc/reference/IFlareTeeManager) diamond.

A TEE machine is identified by `teeId` (the identity address whose private key stays in the enclave). Read more about the TEE public and private keys in the [TEE public and private keys](/fcc/tee-keys) guide. An allowlisted machine owner calls `register` with attested machine data; the call also triggers an availability check. The owner (or a valid availability proof) later moves the machine `INITIALIZED → PRODUCTION` with `toProduction`.

Status is not automatic: `pause`, `ban`, and `unban` are explicit calls. The `getRandomTeeIds` function is the usual way an instructions sender picks machines for `IInstructions.sendInstructions`.

Inherits shared [`ITeeCommonErrors`](/fcc/reference/ITeeCommonErrors).

## Constants[​](#constants "Direct link to Constants")

### `REG_OP_TYPE`[​](#reg_op_type "Direct link to reg_op_type")

System instruction `opType` for TEE registration and attestation (`F_REG`). The [`IVerification.requestTeeAttestation`](/fcc/reference/IVerification) function sends an instruction with this type and command `TEE_ATTESTATION`. The `opType` strings beginning with `F_` are reserved for Flare system operations.

```
bytes32 constant REG_OP_TYPE = bytes32("F_REG");
```

### `TEE_MACHINE_REGISTER`[​](#tee_machine_register "Direct link to tee_machine_register")

Domain prefix for the payload the TEE identity key signs at `register`. The signed message is `prefix + chainId + keccak256(abi.encode(TeeMachineData))`. The recovered signer is the machine's `teeId`. The prefix separates this signature from other FCC signed payloads; `chainId` blocks cross-chain replay.

```
bytes32 constant TEE_MACHINE_REGISTER = bytes32("TEE_MACHINE_REGISTER");
```

## Types[​](#types "Direct link to Types")

### `TeeStatus`[​](#teestatus "Direct link to teestatus")

```
enum TeeStatus {        NONE,        INITIALIZED,        PRODUCTION,        SUSPENDED,        PAUSED,        BANNED    }
```

### `TeeMachineData`[​](#teemachinedata "Direct link to teemachinedata")

```
struct TeeMachineData {        uint256 extensionId;        address initialOwner;        bytes32 codeHash;        bytes32 platform;        PublicKey publicKey;        bytes32 governanceHash;    }
```

### `TeeMachine`[​](#teemachine "Direct link to teemachine")

```
struct TeeMachine {        address teeId;        address teeProxyId;        string url;    }
```

### `TeeMachineWithAttestationData`[​](#teemachinewithattestationdata "Direct link to teemachinewithattestationdata")

```
struct TeeMachineWithAttestationData {        address teeId;        address initialTeeId;        string url;        bytes32 codeHash;        bytes32 platform;    }
```

## Functions[​](#functions "Direct link to Functions")

### `register`[​](#register "Direct link to register")

Register a new TEE machine. It also triggers availability check. Emits TeeMachineRegistered event.

```
function register(        TeeMachineData calldata _teeMachineData,        Signature calldata _teeMachineDataSignature,        address _teeProxyId,        string calldata _url,        address _claimBackAddress    )        external payable
```

**Parameters**

-   `_teeMachineData`: The TEE machine data.
-   `_teeMachineDataSignature`: The TEE machine signature over the TEE machine data.
-   `_teeProxyId`: The TEE proxy id.
-   `_url`: The TEE machine URL (proxy URL).
-   `_claimBackAddress`: An address that can claim back the fee if the instructions are not executed (optional). Can only be called by an allowlisted TEE machine owner.

### `toProduction`[​](#toproduction "Direct link to toproduction")

Put a TEE machine into production. Emits TeeMachineStatusChanged event.

```
function toProduction(        ITeeAvailabilityCheck.Proof calldata _proof    )        external
```

**Parameters**

-   `_proof`: The availability check proof.

### `pause`[​](#pause "Direct link to pause")

Pause a TEE machine. Emits TeeMachineStatusChanged event.

```
function pause(        address _teeId    )        external
```

**Parameters**

-   `_teeId`: The TEE machine id.

### `pauseWithProof`[​](#pausewithproof "Direct link to pausewithproof")

Pause a TEE machine with proof. Emits TeeMachineStatusChanged event.

```
function pauseWithProof(        ITeeAvailabilityCheck.Proof calldata _proof    )        external
```

**Parameters**

-   `_proof`: The availability check proof.

### `ban`[​](#ban "Direct link to ban")

Ban a TEE machine - puts it into BANNED status. Emits TeeMachineStatusChanged event.

```
function ban(        address _teeId    )        external
```

**Parameters**

-   `_teeId`: The TEE machine id. Can only be called by the extension owner.

### `unban`[​](#unban "Direct link to unban")

Unban a TEE machine - puts it into PAUSED status. Emits TeeMachineStatusChanged event.

```
function unban(        address _teeId    )        external
```

**Parameters**

-   `_teeId`: The TEE machine id. Can only be called by the extension owner.

### `proposeNewOwner`[​](#proposenewowner "Direct link to proposenewowner")

Propose a new owner for a TEE machine. Emits NewOwnerProposed event.

```
function proposeNewOwner(        address _teeId,        address _newOwner    )        external
```

**Parameters**

-   `_teeId`: The TEE machine id.
-   `_newOwner`: The new owner address. Can only be called by the current TEE machine owner.

### `confirmOwnership`[​](#confirmownership "Direct link to confirmownership")

Confirm the ownership of a TEE machine. Emits NewOwnerConfirmed event.

```
function confirmOwnership(        address _teeId    )        external
```

**Parameters**

-   `_teeId`: The TEE machine id. Can only be called by the proposed new owner.

### `updateTeeMachineSettings`[​](#updateteemachinesettings "Direct link to updateteemachinesettings")

Update TEE machine settings. Put the TEE machine into PAUSED status if it was in PRODUCTION or SUSPENDED and emits TeeMachineStatusChanged event. Emits TeeMachineSettingsUpdated event.

```
function updateTeeMachineSettings(        address _teeId,        address _teeProxyId,        string calldata _url    )        external
```

**Parameters**

-   `_teeId`: The TEE machine id.
-   `_teeProxyId`: The TEE proxy id.
-   `_url`: The TEE machine URL. Can only be called by the TEE machine owner.

### `getTeeMachineStatus`[​](#getteemachinestatus "Direct link to getteemachinestatus")

Get the status of a TEE machine.

```
function getTeeMachineStatus(        address _teeId    )        external view        returns (TeeStatus)
```

**Parameters**

-   `_teeId`: The TEE machine id.

**Returns**

-   `TeeStatus`: The status of the TEE machine.

### `getTeeMachineOwner`[​](#getteemachineowner "Direct link to getteemachineowner")

Get the owner of a TEE machine.

```
function getTeeMachineOwner(        address _teeId    )        external view        returns (address)
```

**Parameters**

-   `_teeId`: The TEE machine id.

**Returns**

-   `address`: The owner address.

### `getInitialSigningPolicyId`[​](#getinitialsigningpolicyid "Direct link to getinitialsigningpolicyid")

Get initial signing policy id of a TEE machine.

```
function getInitialSigningPolicyId(        address _teeId    )        external view        returns (uint32)
```

**Parameters**

-   `_teeId`: The TEE machine id.

**Returns**

-   `uint32`: The initial signing policy id.

### `getTeeMachine`[​](#getteemachine "Direct link to getteemachine")

Get TEE machine basic data.

```
function getTeeMachine(        address _teeId    )        external view        returns (TeeMachine memory)
```

**Parameters**

-   `_teeId`: The TEE machine id.

**Returns**

-   `TeeMachine`: The TEE machine data.

### `getTeeMachineWithAttestationData`[​](#getteemachinewithattestationdata "Direct link to getteemachinewithattestationdata")

Get TEE machine attestation data.

```
function getTeeMachineWithAttestationData(        address _teeId    )        external view        returns (TeeMachineWithAttestationData memory)
```

**Parameters**

-   `_teeId`: The TEE machine id.

**Returns**

-   `TeeMachineWithAttestationData`: The TEE machine data.

### `getRandomTeeIds`[​](#getrandomteeids "Direct link to getrandomteeids")

Returns random active TEE machine ids.

```
function getRandomTeeIds(        uint256 _extensionId,        uint256 _count    )        external view        returns (address[] memory)
```

**Parameters**

-   `_extensionId`: The id of the extension.
-   `_count`: The number of TEE machine ids to return.

**Returns**

-   `address[]`: The list of TEE machine ids.

### `getAllActiveTeeMachines`[​](#getallactiveteemachines "Direct link to getallactiveteemachines")

Get all active TEE machines.

```
function getAllActiveTeeMachines(        uint256 _start,        uint256 _end    )        external view        returns (            address[] memory _teeIds,            string[] memory _urls,            uint256 _totalLength        )
```

**Parameters**

-   `_start`: The start index (inclusive) for pagination.
-   `_end`: The end index (exclusive) for pagination.

**Returns**

-   `_teeIds`: The list of TEE machine ids.
-   `_urls`: The list of TEE machine URLs.
-   `_totalLength`: The total number of active TEE machines.

### `getActiveTeeMachines`[​](#getactiveteemachines "Direct link to getactiveteemachines")

Get active TEE machines.

```
function getActiveTeeMachines(        uint256 _extensionId    )        external view        returns (            address[] memory _teeIds,            string[] memory _urls        )
```

**Parameters**

-   `_extensionId`: The id of the extension.

**Returns**

-   `_teeIds`: The list of TEE machine ids.
-   `_urls`: The list of TEE machine URLs.

### `getExtensionId`[​](#getextensionid "Direct link to getextensionid")

Get the extension id for a TEE machine.

```
function getExtensionId(        address _teeId    )        external view        returns (uint256)
```

**Parameters**

-   `_teeId`: The TEE machine id.

**Returns**

-   `uint256`: The extension id.

### `getPublicKey`[​](#getpublickey "Direct link to getpublickey")

Get the public key for a TEE machine.

```
function getPublicKey(        address _teeId    )        external view        returns (PublicKey memory)
```

**Parameters**

-   `_teeId`: The TEE machine id.

**Returns**

-   `PublicKey`: The public key.

### `getLastStatusChangeTs`[​](#getlaststatuschangets "Direct link to getlaststatuschangets")

Get the last status change timestamp for a TEE machine.

```
function getLastStatusChangeTs(        address _teeId    )        external view        returns (uint256)
```

**Parameters**

-   `_teeId`: The TEE machine id.

**Returns**

-   `uint256`: The last status change timestamp.

## Events[​](#events "Direct link to Events")

### `NewOwnerProposed`[​](#newownerproposed "Direct link to newownerproposed")

```
event NewOwnerProposed(        address indexed teeId,        address indexed oldOwner,        address indexed newOwner    )
```

**Parameters**

-   `teeId` (`address indexed teeId`)
-   `oldOwner` (`address indexed oldOwner`)
-   `newOwner` (`address indexed newOwner`)

### `NewOwnerConfirmed`[​](#newownerconfirmed "Direct link to newownerconfirmed")

```
event NewOwnerConfirmed(        address indexed teeId,        address indexed newOwner    )
```

**Parameters**

-   `teeId` (`address indexed teeId`)
-   `newOwner` (`address indexed newOwner`)

### `TeeMachineRegistered`[​](#teemachineregistered "Direct link to teemachineregistered")

```
event TeeMachineRegistered(        address indexed teeId,        address indexed teeProxyId,        address indexed owner,        uint256 extensionId,        string url,        bytes32 codeHash,        bytes32 platform,        bytes32 governanceHash    )
```

**Parameters**

-   `teeId` (`address indexed teeId`)
-   `teeProxyId` (`address indexed teeProxyId`)
-   `owner` (`address indexed owner`)
-   `extensionId` (`uint256 extensionId`)
-   `url` (`string url`)
-   `codeHash` (`bytes32 codeHash`)
-   `platform` (`bytes32 platform`)
-   `governanceHash` (`bytes32 governanceHash`)

### `TeeMachineStatusChanged`[​](#teemachinestatuschanged "Direct link to teemachinestatuschanged")

```
event TeeMachineStatusChanged(        address indexed teeId,        TeeStatus indexed newStatus    )
```

**Parameters**

-   `teeId` (`address indexed teeId`)
-   `newStatus` (`TeeStatus indexed newStatus`)

### `TeeMachineSettingsUpdated`[​](#teemachinesettingsupdated "Direct link to teemachinesettingsupdated")

```
event TeeMachineSettingsUpdated(        address indexed teeId,        address indexed teeProxyId,        string url    )
```

**Parameters**

-   `teeId` (`address indexed teeId`)
-   `teeProxyId` (`address indexed teeProxyId`)
-   `url` (`string url`)

## Errors[​](#errors "Direct link to Errors")

Facet-specific errors are listed here. The interface also inherits shared [`ITeeCommonErrors`](/fcc/reference/ITeeCommonErrors). This facet uses those for allowlist and proof checks, including `OnlyOwner`, `OwnerNotAllowed`, `InvalidGovernanceHash`, `InvalidResponseData`, and `VersionNotSupported`.

### `InvalidTeePublicKey`[​](#invalidteepublickey "Direct link to invalidteepublickey")

The identity public key in `TeeMachineData` is not a valid uncompressed secp256k1 key.

```
error InvalidTeePublicKey()
```

### `InvalidTeeProxyId`[​](#invalidteeproxyid "Direct link to invalidteeproxyid")

`_teeProxyId` is `address(0)`. Thrown by `register` and `updateTeeMachineSettings`.

```
error InvalidTeeProxyId()
```

### `InvalidTeePublicKeyOrSignature`[​](#invalidteepublickeyorsignature "Direct link to invalidteepublickeyorsignature")

The recovered signer of the `TEE_MACHINE_REGISTER` payload is not the address derived from `TeeMachineData.publicKey`. The TEE identity key must sign the registration data.

```
error InvalidTeePublicKeyOrSignature()
```

### `InvalidUrl`[​](#invalidurl "Direct link to invalidurl")

`_url` is empty. Thrown by `register` and `updateTeeMachineSettings`.

```
error InvalidUrl()
```

### `AlreadyRegistered`[​](#alreadyregistered "Direct link to alreadyregistered")

A machine with this `teeId` is already registered. The same identity key cannot register twice.

```
error AlreadyRegistered()
```

### `InvalidTeeStatus`[​](#invalidteestatus "Direct link to invalidteestatus")

The machine is not in a status the function allows. Examples: `toProduction` from a status other than `INITIALIZED`, `PAUSED`, or `SUSPENDED`; owner `pause` when not `PRODUCTION` or `SUSPENDED`; `ban` when already `INITIALIZED` or `BANNED`.

```
error InvalidTeeStatus()
```

### `InvalidResponseDataOrAvailabilityCheckStatus`[​](#invalidresponsedataoravailabilitycheckstatus "Direct link to invalidresponsedataoravailabilitycheckstatus")

`pauseWithProof` requires a *failing* availability-check proof. Thrown when the proof verifies and `status` is `OK` — that proof would promote the machine, not suspend it.

```
error InvalidResponseDataOrAvailabilityCheckStatus()
```

### `OnlyOwnerOrExpiredAvailabilityCheck`[​](#onlyownerorexpiredavailabilitycheck "Direct link to onlyownerorexpiredavailabilitycheck")

A non-owner called `pause` while the machine's availability check is still valid (`endTs >= now`). Anyone may suspend a `PRODUCTION` machine only after `endTs` has passed.

```
error OnlyOwnerOrExpiredAvailabilityCheck()
```

### `OwnerMismatch`[​](#ownermismatch "Direct link to ownermismatch")

Declared on this interface. The current `MachineManagerFacet` does not throw it (ownership transfer uses `OnlyProposedOwner` instead).

```
error OwnerMismatch()
```

### `TooMany`[​](#toomany "Direct link to toomany")

`getRandomTeeIds` asked for more ids than the extension has active (`PRODUCTION`) machines.

```
error TooMany()
```

### `TeeNotFound`[​](#teenotfound "Direct link to teenotfound")

No machine is registered at this `teeId`.

```
error TeeNotFound()
```

### `InvalidNewStatus`[​](#invalidnewstatus "Direct link to invalidnewstatus")

Declared on this interface. The current `MachineManagerFacet` does not throw it (`InvalidTeeStatus` covers illegal transitions).

```
error InvalidNewStatus()
```
