# KintoWalletFactory

**Deployment Address**

Mainnet: [<mark style="color:purple;">0x8a4720488CA32f1223ccFE5A087e250fE3BC5D75</mark>](https://explorer.kinto.xyz/address/0x8a4720488CA32f1223ccFE5A087e250fE3BC5D75)

Interface: [<mark style="color:purple;">IKintoWalletFactory.sol</mark>](https://github.com/KintoXYZ/kinto-core/blob/main/src/interfaces/IKintoWalletFactory.sol)

***

## **Basics**

* Creates [`KintoWallet`](/kinto-the-modular-exchange/building-on-kinto/smart-contract-reference/kinto-wallet.md) instances using a beacon proxy pattern.
* Method to fund a `KintoWallet` account with ETH.
* Ensures KYC compliance of wallet owners through integration with [`KintoID`](/kinto-the-modular-exchange/building-on-kinto/smart-contract-reference/kintoid.md).
* Supports deployment of custom contracts using [`CREATE2`](/kinto-the-modular-exchange/building-on-kinto/rollup-features/create2.md).
* Manages wallet recovery process.
* Handles ETH transfers to various entities within the Kinto ecosystem.
* Implements an upgradeable beacon for wallet implementations.

***

### Constructor

**Constructor Parameters:**

| Parameter       | Type                | Explanation                               |
| --------------- | ------------------- | ----------------------------------------- |
| `_implAddressP` | `IKintoWallet`      | Address of the KintoWallet implementation |
| `_appRegistry`  | `IKintoAppRegistry` | Address of the KintoAppRegistry contract  |
| `_kintoID`      | `IKintoID`          | Address of the KintoID contract           |

### Initialize

**Initialize Function:**

```solidity
function initialize() external initializer;
```

Initializes the contract, setting up the beacon and initial wallet version.

### State Functions

```solidity
function upgradeAllWalletImplementations(IKintoWallet newImplementationWallet) external override onlyOwner;

function createAccount(address owner, address recoverer, bytes32 salt) external override returns (IKintoWallet ret);

function startWalletRecovery(address payable wallet) external override;

function completeWalletRecovery(address payable wallet, address[] calldata newSigners) external override;

function approveWalletRecovery(address wallet) external override onlyOwner;

function changeWalletRecoverer(address payable wallet, address _newRecoverer) external override;

function fundWallet(address payable wallet) external payable override;

function claimFromFaucet(address _faucet, IFaucet.SignatureData calldata _signatureData) external override;

function sendMoneyToAccount(address target) external payable override;

function sendMoneyToRecoverer(address wallet, address recoverer) external payable override;

function sendETHToDeployer(address deployer) external payable override;

function sendETHToEOA(address eoa, address app) external payable override;
```

#### 1. `upgradeAllWalletImplementations` (Admin only)

Upgrades all wallet implementations to the specified new implementation.

```solidity
function upgradeAllWalletImplementations(IKintoWallet newImplementationWallet) external override onlyOwner;
```

| Parameter                 | Type           | Explanation                        |
| ------------------------- | -------------- | ---------------------------------- |
| `newImplementationWallet` | `IKintoWallet` | New wallet implementation address. |

#### 2. `createAccount`

Creates an account and returns its address, using `bytes32` for `salt`.

```solidity
function createAccount(address owner, address recoverer, bytes32 salt) external override returns (IKintoWallet ret);
```

| Parameter   | Type      | Explanation                          |
| ----------- | --------- | ------------------------------------ |
| `owner`     | `address` | The owner address.                   |
| `recoverer` | `address` | The recoverer address.               |
| `salt`      | `bytes32` | The salt to use for the calculation. |

#### 3. `startWalletRecovery` (Only callable by recoverer)

Initiates the wallet recovery process.

```solidity
function startWalletRecovery(address payable wallet) external override;
```

| Parameter | Type      | Explanation        |
| --------- | --------- | ------------------ |
| `wallet`  | `address` | The wallet address |

#### 4. `completeWalletRecovery` (Only callable by recoverer)

Completes the wallet recovery process.

```solidity
function completeWalletRecovery(address payable wallet, address[] calldata newSigners) external override;
```

| Parameter    | Type        | Explanation        |
| ------------ | ----------- | ------------------ |
| `wallet`     | `address`   | The wallet address |
| `newSigners` | `address[]` | New signers array  |

#### 5. `approveWalletRecovery` (Admin only)

Approves a wallet for recovery.

```solidity
function approveWalletRecovery(address wallet) external override onlyOwner;
```

| Parameter | Type      | Explanation                             |
| --------- | --------- | --------------------------------------- |
| `wallet`  | `address` | The wallet address to approve recovery. |

#### 6. `changeWalletRecoverer` (Only callable by recoverer)

Changes the wallet's recoverer.

```solidity
function changeWalletRecoverer(address payable wallet, address _newRecoverer) external override;
```

| Parameter       | Type      | Explanation           |
| --------------- | --------- | --------------------- |
| `wallet`        | `address` | The wallet address    |
| `_newRecoverer` | `address` | New recoverer address |

#### 7. `fundWallet`

Funds a `KintoWallet` through the factory.

```solidity
function fundWallet(address payable wallet) external payable override;
```

| Parameter | Type      | Explanation                 |
| --------- | --------- | --------------------------- |
| `wallet`  | `address` | The wallet address to fund. |

#### 8. `claimFromFaucet`

Claims from a faucet on behalf of a user.

```solidity
function claimFromFaucet(address _faucet, IFaucet.SignatureData calldata _signatureData) external override;
```

| Parameter        | Type                    | Explanation                       |
| ---------------- | ----------------------- | --------------------------------- |
| `_faucet`        | `address`               | The faucet address to claim from. |
| `_signatureData` | `IFaucet.SignatureData` | The signature data for the claim. |

#### 9. `sendMoneyToAccount`

Allows sending money to an account from privileged accounts or KYC accounts.

```solidity
function sendMoneyToAccount(address target) external payable override;
```

| Parameter | Type      | Explanation                                  |
| --------- | --------- | -------------------------------------------- |
| `target`  | `address` | The target account address to send money to. |

#### 10. `sendMoneyToRecoverer`

Sends money to a recoverer from a wallet to facilitate the recovery process.

```solidity
function sendMoneyToRecoverer(address wallet, address recoverer) external payable override;
```

| Parameter   | Type      | Explanation                    |
| ----------- | --------- | ------------------------------ |
| `wallet`    | `address` | The wallet address.            |
| `recoverer` | `address` | The recoverer address to fund. |

#### 11. `sendETHToDeployer`

Sends ETH to the deployer of a wallet.

```solidity
function sendETHToDeployer(address deployer) external payable override;
```

| Parameter  | Type      | Explanation                   |
| ---------- | --------- | ----------------------------- |
| `deployer` | `address` | The deployer address to fund. |

#### 12. `sendETHToEOA`

Sends ETH to the EOA of an app.

```solidity
function sendETHToEOA(address eoa, address app) external payable override;
```

| Parameter | Type      | Explanation                       |
| --------- | --------- | --------------------------------- |
| `eoa`     | `address` | The EOA address to receive funds. |
| `app`     | `address` | The associated app address.       |

### View Functions

```solidity
function getWalletTimestamp(address wallet) external view override returns (uint256);

function getAddress(address owner, address recoverer, bytes32 salt) public view override returns (address);
```

#### 1. `getWalletTimestamp`

Returns the creation timestamp of a wallet.

```solidity
function getWalletTimestamp(address wallet) external view override returns (uint256);
```

| Parameter | Type      | Explanation                  |
| --------- | --------- | ---------------------------- |
| `wallet`  | `address` | The wallet address to query. |

#### 2. `getAddress`

Calculates the counterfactual address of an account.

```solidity
function getAddress(address owner, address recoverer, bytes32 salt) public view override returns (address);
```

| Parameter   | Type      | Explanation                                |
| ----------- | --------- | ------------------------------------------ |
| `owner`     | `address` | The owner address of the account.          |
| `recoverer` | `address` | The address that can recover the account.  |
| `salt`      | `bytes32` | The salt used for the address calculation. |

### Events

* `KintoWalletFactoryCreation`: Emitted when a new wallet is created.
* `KintoWalletFactoryUpgraded`: Emitted when the wallet implementation is upgraded.


---

# 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.kinto.xyz/kinto-the-modular-exchange/building-on-kinto/smart-contract-reference/kintowalletfactory.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.
