> For the complete documentation index, see [llms.txt](https://docs.alloc8.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.alloc8.xyz/architechure/readme/account-factory.md).

# 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()`.
