# IWalletManager

> Create, initialize, and enable Protocol Managed Wallets.

> 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/IWalletManager

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

This facet owns the **wallet lifecycle** for [Protocol Managed Wallets (PMW)](/fcc/overview#protocol-managed-wallets-pmw): create under a project, set admins and optional cosigners, freeze that config, then enable production use after keys exist.

Status is not automatic. Each transition is an explicit call by the project owner (or an admin/cosigner confirming membership):

```
NONE → CREATED → INITIALIZED → PRODUCTION ⇄ PAUSED
```

`PAUSED` is reached only from `PRODUCTION` via the wallet project pause facet (`pauseWallets` / `unpauseWallets`), not from `INITIALIZED`.

Typical setup (FCC wallets scaffold):

1.  [`IWalletProjectManager.createProject`](/fcc/reference/IWalletProjectManager)
2.  `createWallet(projectId)` → status `CREATED`
3.  `setAdmins` / `confirmAdmin` (and optionally `setCosigners` / `confirmCosigner`)
4.  `closeWalletInitialization` → status `INITIALIZED` (admins/cosigners locked)
5.  [`IWalletKeyManager.setMultisigThreshold`](/fcc/reference/IWalletKeyManager) and `addKey` / `confirmKey`
6.  `enableWallet` → status `PRODUCTION` (no more keys can be added)

`WALLET_OP_TYPE` (`F_WALLET`) is the reserved system op type used when key facets send generate/delete instructions to TEEs. Do not reuse `F_`\-prefixed op types in your own extension handlers.

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

info

FCC and Protocol Managed Wallets are in the final stages of development. Prefer **Coston2** for examples and treat interfaces as subject to change.

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

### `WALLET_OP_TYPE`[​](#wallet_op_type "Direct link to wallet_op_type")

System instruction `opType` for wallet key operations (`F_WALLET`). [`IWalletKeyManager.addKey`](/fcc/reference/IWalletKeyManager) / `deleteKey` send instructions with this type and commands such as `KEY_GENERATE` / `KEY_DELETE`.

```
bytes32 constant WALLET_OP_TYPE = bytes32("F_WALLET");
```

### `MAX_WALLET_ADMINS` / `MAX_WALLET_COSIGNERS`[​](#max_wallet_admins--max_wallet_cosigners "Direct link to max_wallet_admins--max_wallet_cosigners")

Upper bounds for `setAdmins` and `setCosigners`.

```
uint256 constant MAX_WALLET_ADMINS = 50;uint256 constant MAX_WALLET_COSIGNERS = 50;
```

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

### `WalletStatus`[​](#walletstatus "Direct link to walletstatus")

```
enum WalletStatus {        NONE,        CREATED,        INITIALIZED,        PRODUCTION,        PAUSED    }
```

### `PublicKey`[​](#publickey "Direct link to publickey")

Shared FCC struct for admin public keys (uncompressed secp256k1 coordinates):

```
struct PublicKey {        bytes32 x;        bytes32 y;    }
```

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

### `createWallet`[​](#createwallet "Direct link to createwallet")

Creates a wallet for the project. Emits `WalletCreated` event. Status becomes `CREATED`. Can only be called by the project owner.

```
function createWallet(        bytes32 _projectId    )        external        returns (bytes32 _walletId)
```

**Parameters**

-   `_projectId`: The project id.

**Returns**

-   `_walletId`: The wallet id.

### `setAdmins`[​](#setadmins "Direct link to setadmins")

Sets the wallet admins (at most `MAX_WALLET_ADMINS`). Emits `WalletAdminsSet` event. Can only be called by the wallet (project) owner while the wallet is still `CREATED`. Each listed admin must later call `confirmAdmin`.

```
function setAdmins(        bytes32 _walletId,        PublicKey[] calldata _adminsPublicKeys,        uint64 _adminsThreshold    )        external
```

**Parameters**

-   `_walletId`: The wallet id.
-   `_adminsPublicKeys`: The wallet admins' public keys.
-   `_adminsThreshold`: The admins threshold.

### `confirmAdmin`[​](#confirmadmin "Direct link to confirmadmin")

Confirms admin membership for `msg.sender` on this wallet. Confirmation is per-wallet membership consent, independent of set composition and threshold. Emits `WalletAdminConfirmed` event.

```
function confirmAdmin(        bytes32 _walletId    )        external
```

**Parameters**

-   `_walletId`: The wallet id.

### `setCosigners`[​](#setcosigners "Direct link to setcosigners")

Sets the wallet cosigners (at most `MAX_WALLET_COSIGNERS`). Emits `WalletCosignersSet` event. Can only be called by the wallet owner while the wallet is still `CREATED`. Optional: skip cosigners if the wallet does not need the extra authorization gate. See [Data providers and cosigners](/fcc/data-providers).

```
function setCosigners(        bytes32 _walletId,        address[] calldata _cosigners,        uint64 _cosignersThreshold    )        external
```

**Parameters**

-   `_walletId`: The wallet id.
-   `_cosigners`: The wallet cosigners.
-   `_cosignersThreshold`: The cosigners threshold.

### `confirmCosigner`[​](#confirmcosigner "Direct link to confirmcosigner")

Confirms cosigner membership for `msg.sender` on this wallet. Emits `WalletCosignerConfirmed` event.

```
function confirmCosigner(        bytes32 _walletId    )        external
```

**Parameters**

-   `_walletId`: The wallet id.

### `closeWalletInitialization`[​](#closewalletinitialization "Direct link to closewalletinitialization")

Closes wallet initialization and enables adding keys. All admins (and any configured cosigners) must be set and confirmed. They cannot be changed after this call. Moves status `CREATED → INITIALIZED` and emits `WalletInitialized`. Can only be called by the wallet owner.

```
function closeWalletInitialization(        bytes32 _walletId    )        external
```

**Parameters**

-   `_walletId`: The wallet id.

### `enableWallet`[​](#enablewallet "Direct link to enablewallet")

Enables a wallet for the first time: `INITIALIZED → PRODUCTION`. Requires the wallet's multisig threshold to be set and at least that many keys to be confirmed ([`IWalletKeyManager`](/fcc/reference/IWalletKeyManager)). Does **not** handle `PAUSED → PRODUCTION`; that path is on the wallet project pause facet (`unpauseWallets`). Emits `WalletEnabled` event. Can only be called by the wallet owner.

```
function enableWallet(        bytes32 _walletId    )        external
```

**Parameters**

-   `_walletId`: The wallet id.

### `getProjectWalletIds`[​](#getprojectwalletids "Direct link to getprojectwalletids")

Returns the list of wallet ids for the project.

```
function getProjectWalletIds(        bytes32 _projectId    )        external view        returns (bytes32[] memory _walletIds)
```

**Parameters**

-   `_projectId`: The project id.

**Returns**

-   `_walletIds`: The list of wallet ids.

### `getWalletProjectId`[​](#getwalletprojectid "Direct link to getwalletprojectid")

Returns the wallet's project id.

```
function getWalletProjectId(        bytes32 _walletId    )        external view        returns (bytes32 _projectId)
```

**Parameters**

-   `_walletId`: The wallet id.

**Returns**

-   `_projectId`: The project id.

### `getWalletAdminsPublicKeysAndThreshold`[​](#getwalletadminspublickeysandthreshold "Direct link to getwalletadminspublickeysandthreshold")

Returns the wallet's admin public keys and threshold.

```
function getWalletAdminsPublicKeysAndThreshold(        bytes32 _walletId    )        external view        returns (            PublicKey[] memory _adminsPublicKeys,            uint64 _adminsThreshold        )
```

**Parameters**

-   `_walletId`: The wallet id.

**Returns**

-   `_adminsPublicKeys`: The wallet admins' public keys.
-   `_adminsThreshold`: The admins threshold.

### `getWalletAdminsAndThreshold`[​](#getwalletadminsandthreshold "Direct link to getwalletadminsandthreshold")

Returns the wallet's admin addresses (derived from public keys) and threshold.

```
function getWalletAdminsAndThreshold(        bytes32 _walletId    )        external view        returns (            address[] memory _admins,            uint64 _adminsThreshold        )
```

**Parameters**

-   `_walletId`: The wallet id.

**Returns**

-   `_admins`: The wallet admin addresses.
-   `_adminsThreshold`: The admins threshold.

### `getWalletCosignersAndThreshold`[​](#getwalletcosignersandthreshold "Direct link to getwalletcosignersandthreshold")

Returns the wallet's cosigners and threshold.

```
function getWalletCosignersAndThreshold(        bytes32 _walletId    )        external view        returns (            address[] memory _cosigners,            uint64 _cosignersThreshold        )
```

**Parameters**

-   `_walletId`: The wallet id.

**Returns**

-   `_cosigners`: The wallet cosigners.
-   `_cosignersThreshold`: The cosigners threshold.

### `getWalletStatus`[​](#getwalletstatus "Direct link to getwalletstatus")

Returns the wallet's status.

```
function getWalletStatus(        bytes32 _walletId    )        external view        returns (WalletStatus _status)
```

**Parameters**

-   `_walletId`: The wallet id.

**Returns**

-   `_status`: The status.

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

### `WalletCreated`[​](#walletcreated "Direct link to walletcreated")

```
event WalletCreated(        bytes32 indexed projectId,        bytes32 indexed walletId    )
```

**Parameters**

-   `projectId` (`bytes32 indexed projectId`)
-   `walletId` (`bytes32 indexed walletId`)

### `WalletAdminsSet`[​](#walletadminsset "Direct link to walletadminsset")

```
event WalletAdminsSet(        bytes32 indexed walletId,        PublicKey[] adminsPublicKeys,        uint64 adminsThreshold    )
```

**Parameters**

-   `walletId` (`bytes32 indexed walletId`)
-   `adminsPublicKeys` (`PublicKey[] adminsPublicKeys`)
-   `adminsThreshold` (`uint64 adminsThreshold`)

### `WalletAdminConfirmed`[​](#walletadminconfirmed "Direct link to walletadminconfirmed")

```
event WalletAdminConfirmed(        bytes32 indexed walletId,        address indexed admin    )
```

**Parameters**

-   `walletId` (`bytes32 indexed walletId`)
-   `admin` (`address indexed admin`)

### `WalletCosignersSet`[​](#walletcosignersset "Direct link to walletcosignersset")

```
event WalletCosignersSet(        bytes32 indexed walletId,        address[] cosigners,        uint64 cosignersThreshold    )
```

**Parameters**

-   `walletId` (`bytes32 indexed walletId`)
-   `cosigners` (`address[] cosigners`)
-   `cosignersThreshold` (`uint64 cosignersThreshold`)

### `WalletCosignerConfirmed`[​](#walletcosignerconfirmed "Direct link to walletcosignerconfirmed")

```
event WalletCosignerConfirmed(        bytes32 indexed walletId,        address indexed cosigner    )
```

**Parameters**

-   `walletId` (`bytes32 indexed walletId`)
-   `cosigner` (`address indexed cosigner`)

### `WalletInitialized`[​](#walletinitialized "Direct link to walletinitialized")

Emitted when `closeWalletInitialization` moves the wallet to `INITIALIZED`.

```
event WalletInitialized(        bytes32 indexed walletId    )
```

**Parameters**

-   `walletId` (`bytes32 indexed walletId`)

### `WalletEnabled`[​](#walletenabled "Direct link to walletenabled")

Emitted when `enableWallet` moves the wallet to `PRODUCTION`.

```
event WalletEnabled(        bytes32 indexed walletId    )
```

**Parameters**

-   `walletId` (`bytes32 indexed walletId`)

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

Facet-specific errors are listed here. The interface also inherits shared [`ITeeCommonErrors`](/fcc/reference/ITeeCommonErrors), including `OnlyOwner`, `InvalidWalletStatus`, `InvalidThreshold`, `InvalidCosigner`, `DuplicatedCosigner`, and `InvalidAddress`.

### `NotEnoughAdmins`[​](#notenoughadmins "Direct link to notenoughadmins")

The admins list is empty or below the required minimum for the threshold rules.

```
error NotEnoughAdmins()
```

### `InvalidAdminsThreshold`[​](#invalidadminsthreshold "Direct link to invalidadminsthreshold")

The admins threshold is zero or larger than the admins set.

```
error InvalidAdminsThreshold()
```

### `DuplicatedPublicKey`[​](#duplicatedpublickey "Direct link to duplicatedpublickey")

The same admin public key appears more than once.

```
error DuplicatedPublicKey(PublicKey publicKey)
```

**Parameters**

-   `publicKey`: The duplicated key.

### `InvalidCosignersThreshold`[​](#invalidcosignersthreshold "Direct link to invalidcosignersthreshold")

The cosigners threshold is zero (when cosigners are set) or larger than the cosigners set.

```
error InvalidCosignersThreshold()
```

### `AdminsNotSet`[​](#adminsnotset "Direct link to adminsnotset")

`closeWalletInitialization` was called before any admins were set.

```
error AdminsNotSet()
```

### `NotAllAdminsConfirmed`[​](#notalladminsconfirmed "Direct link to notalladminsconfirmed")

An admin has not called `confirmAdmin` yet.

```
error NotAllAdminsConfirmed(address admin)
```

**Parameters**

-   `admin`: The admin address still missing confirmation.

### `NotAllCosignersConfirmed`[​](#notallcosignersconfirmed "Direct link to notallcosignersconfirmed")

A cosigner has not called `confirmCosigner` yet.

```
error NotAllCosignersConfirmed(address cosigner)
```

**Parameters**

-   `cosigner`: The cosigner address still missing confirmation.

### `MultisigThresholdNotSet`[​](#multisigthresholdnotset "Direct link to multisigthresholdnotset")

`enableWallet` requires a positive multisig threshold on [`IWalletKeyManager`](/fcc/reference/IWalletKeyManager).

```
error MultisigThresholdNotSet()
```

### `NotEnoughKeys`[​](#notenoughkeys "Direct link to notenoughkeys")

`enableWallet` requires at least `multisigThreshold` confirmed keys.

```
error NotEnoughKeys()
```

### `InvalidAdminPublicKey`[​](#invalidadminpublickey "Direct link to invalidadminpublickey")

An admin public key is not a valid key for this wallet.

```
error InvalidAdminPublicKey(PublicKey publicKey)
```

**Parameters**

-   `publicKey`: The invalid key.

### `InvalidAdmin`[​](#invalidadmin "Direct link to invalidadmin")

`msg.sender` is not a listed admin for `confirmAdmin`.

```
error InvalidAdmin()
```

### `TooManyAdmins`[​](#toomanyadmins "Direct link to toomanyadmins")

More than `MAX_WALLET_ADMINS` admins were supplied.

```
error TooManyAdmins()
```

### `TooManyCosigners`[​](#toomanycosigners "Direct link to toomanycosigners")

More than `MAX_WALLET_COSIGNERS` cosigners were supplied.

```
error TooManyCosigners()
```
