# Account Factory

The `Modular4337Factory` is a fully on-chain, deterministic factory contract used to deploy modular smart accounts (`Modular4337Account`) via the CREATE2 opcode. It supports flexible account instantiation, vault registries, and optional integration with ERC-4337's EntryPoint staking model.

#### **Key Features**

* **Deterministic Wallet Addresses**\
  Every smart account is deployed using `CREATE2` with a per-user salt and nonce combination, allowing you to predict the address **before** deployment.
* **Proxy Pattern**\
  All accounts are proxies pointing to a shared `Modular4337Account` implementation, minimizing deployment gas costs.
* **Vault Whitelist Registry**\
  Includes built-in support for managing whitelisted vault contracts that can interact with accounts — useful for protocol-specific integrations.
* **On-Chain Metadata**\
  Maintains a complete registry of:
  * Wallets deployed by each user (`getUserWallets`)
  * Wallet ownership (`userWalletOwner`)
  * Wallet deployment nonces (`userNonce`)
* **EntryPoint Stake Utilities**\
  Supports `addStake`, `unlockStake`, and `withdrawStake` for ERC-4337 compliance and bundler staking.

#### Typical usage flow

1. **Compute Wallet Address:**\
   Use `computeAccountAddress(owner, salt)` to pre-calculate the address of the wallet.
2. **Deploy Wallet:**\
   Call `deployAccount(owner, salt)` to deploy the proxy and initialize the wallet with the provided `owner` and `EntryPoint`.
3. **Manage Vaults:**\
   Admins can register protocol-approved vault contracts with `addVault()` or `bulkAddVaults()`.


---

# 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.alloc8.xyz/architechure/readme/account-factory.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.
