Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Glossary

Account Factory

An Account Factory is a smart contract pattern that enables the deterministic deployment of smart contract accounts, often using CREATE2, for features like social recovery and gas sponsorship.
Chainscore © 2026
definition
SMART ACCOUNT INFRASTRUCTURE

What is Account Factory?

An Account Factory is a smart contract that programmatically deploys smart contract accounts, enabling scalable and customizable user onboarding.

An Account Factory is a foundational smart contract in account abstraction architectures that serves as a standardized, on-chain deployment mechanism for smart contract accounts (SCAs). Instead of users manually deploying individual account contracts, which is costly and complex, the factory contract acts as a blueprint, creating new account instances using a deterministic CREATE2 operation. This allows for counterfactual deployment, where an account's address can be pre-computed and used (e.g., to receive funds) before the contract code is ever deployed to the chain, optimizing gas costs and user experience.

The core function of an Account Factory is to separate the logic of account creation from the account's runtime execution. It typically accepts initialization parameters—such as the owner's public key, entry point address, and any custom module configurations—and uses them to instantiate a new account contract. This pattern is central to ERC-4337 (Account Abstraction) and ERC-6900 (Modular Smart Accounts), enabling features like social recovery, batch transactions, and sponsored gas fees to be built directly into the account creation process. Popular implementations include Safe{Wallet}'s ProxyFactory and the SimpleAccountFactory from the ERC-4337 entry point contracts.

From a developer's perspective, using an Account Factory provides critical advantages: standardization ensures interoperability across dApps, gas efficiency is achieved through optimized deployment paths and potential batch creation, and enhanced security by relying on audited, canonical factory contracts. For users, it abstracts away the complexity of key management and contract deployment, allowing for seamless onboarding through familiar web2 patterns like email or social logins, which are powered by signature schemes and verification logic handled by the factory and its associated infrastructure.

how-it-works
SMART CONTRACT PATTERN

How Does an Account Factory Work?

An Account Factory is a foundational smart contract pattern in blockchain development that standardizes and automates the creation of new smart contract accounts.

An Account Factory is a smart contract whose primary function is to serve as a deterministic, permissionless deployment mechanism for other smart contracts, most commonly smart accounts or account abstraction wallets. It works by exposing a public function, often called createAccount, that accepts parameters (like an owner's public key or salt) and uses them to deploy a new contract instance via the CREATE2 or CREATE opcode. This pattern decouples the logic of account creation from the application's core business logic, enabling predictable contract addresses and gas-efficient deployments.

The factory's deterministic nature is crucial. By using CREATE2 with a predefined salt value (often derived from the user's address), the resulting smart account's address can be computed before it is ever deployed on-chain. This enables advanced functionalities like counterfactual deployment, where a user can receive funds or interact with a protocol using their future account address, with the actual contract deployment only occurring upon their first transaction. This dramatically improves the user experience by removing upfront gas costs and setup steps.

Key architectural components include the factory contract itself, a singleton implementation contract containing the wallet logic, and a proxy contract for each user. The factory typically deploys a minimal proxy (like an ERC-1167 clone) that delegates all calls to the immutable singleton implementation. This proxy pattern ensures gas efficiency and upgradability, as the core logic can be updated in the singleton without needing to migrate user funds or state. The factory manages the mapping between user identifiers and their deployed proxy addresses.

Practical applications are vast. In ERC-4337 Account Abstraction, bundlers use account factories to deploy smart contract wallets for users who submit UserOperations. Gas sponsorship protocols rely on factories so paymasters can predictably deploy accounts for users they sponsor. Developers use this pattern for creating NFT collections (where each NFT is a unique contract), liquidity pool pairs, or multi-signature wallets. It is a cornerstone for scaling and improving blockchain usability by abstracting away deployment complexity.

key-features
ACCOUNT ABSTRACTION

Key Features

An Account Factory is a smart contract that enables the programmatic creation of smart contract wallets, a core primitive for user onboarding and account abstraction.

01

Deterministic Address Generation

A factory uses a deterministic algorithm (like CREATE2) to pre-calculate a wallet's address before it's deployed. This allows for:

  • Counterfactual addressing: Users can receive funds to an address that doesn't exist on-chain yet.
  • Gas sponsorship: A third party can pay for deployment, as the address is known in advance.
  • Secure onboarding: Bundling initial setup operations into a single transaction.
02

Social Recovery & Guardians

Factories enable wallets with built-in social recovery mechanisms. Instead of a single private key, control can be managed by:

  • A set of guardians (trusted devices or contacts).
  • A security module that enforces recovery logic. This shifts security from key management to social or procedural safeguards, drastically reducing the risk of permanent loss.
03

Batch Operations & Sponsorship

Factories allow sponsors (dApps, paymasters) to bundle multiple actions into one user transaction, abstracting away gas complexities. This enables:

  • Gasless transactions: The sponsor pays fees on the user's behalf.
  • Atomic multi-op bundles: Creating an account, approving a token, and executing a swap in one click.
  • Improved UX: Removing the need for users to hold the native token for gas.
04

Modular Smart Account Design

Factories deploy modular smart contract accounts where functionality is not fixed. Key features can be added or upgraded via:

  • Plugin architecture: Adding modules for specific DeFi protocols or security features.
  • Upgradeable logic: The account's behavior can be updated without changing its address.
  • Session keys: Granting limited permissions to specific applications for a set time.
06

Use Cases & Examples

Account Factories power critical onboarding and automation flows:

  • Mass airdrops: Pre-generating addresses for thousands of users.
  • Enterprise payroll: Automatically creating wallets for employees.
  • Game item wallets: Generating a unique wallet for each in-game asset.
  • Cross-chain accounts: Using a factory to deploy the same wallet address on multiple EVM chains.
code-example
ACCOUNT FACTORY

Code Example

A practical implementation of an Account Factory smart contract, demonstrating how to programmatically create smart contract wallets.

The following Solidity code illustrates a basic Account Factory using the Create2 opcode, which allows for deterministic contract address generation. This pattern is fundamental for counterfactual deployment, where a user can receive assets at a wallet address before the contract is deployed on-chain. The factory's createAccount function takes a salt and initializer data, deploys a new instance of a predefined Account contract, and emits an event with the new address.

Key components of this implementation include the singleton contract pattern, where the factory stores a single, immutable accountImplementation address. The createAccount function uses Create2 to compute the new contract's address via computeAddress before performing the actual deployment with Create2.deploy. This ensures the address is predictable and can be derived off-chain. The salt, often a hash of the user's EOA address or other unique data, guarantees each user gets a unique, deterministic smart account address.

In practice, this factory enables gas sponsorship models (like paymasters) and batch transactions, as the deploying entity (a relayer) can pay the gas for creating the account. The deployed Account contract itself would typically implement ERC-4337 standards for User Operations, allowing for signature verification and custom logic. This code forms the backbone for smart account ecosystems, providing the infrastructure for scalable, user-friendly wallet creation without requiring users to hold native gas tokens initially.

examples
ACCOUNT FACTORY

Examples & Use Cases

Account factories are smart contracts that programmatically deploy smart contract wallets. They are foundational for onboarding, gas sponsorship, and enabling complex user experiences.

01

Batch Onboarding & User Acquisition

A primary use case is mass onboarding for dApps and games. Instead of requiring users to deploy their own wallets, the factory can create them on-demand, often paying the gas fee via gas sponsorship. This removes a major friction point for new users.

  • Example: A Web3 game can create a smart account for every new player upon sign-up.
  • Benefit: Enables non-custodial experiences without requiring users to hold ETH for gas.
02

Social Logins & Embedded Wallets

Factories enable social login experiences (e.g., Sign in with Google) by deploying a smart account whose ownership is tied to a user's social identity via ERC-4337 or similar standards. The factory handles the deployment logic and key management.

  • Example: Privy or Dynamic use account factories to create wallets upon social authentication.
  • Benefit: Abstracts away seed phrases and provides a familiar Web2 login flow.
03

Paymaster Integration & Gas Abstraction

Account factories are often integrated with paymasters to offer gasless transactions or pay fees in ERC-20 tokens. The factory can deploy an account pre-configured to interact with a specific paymaster.

  • Example: A dApp can sponsor the first 10 transactions for new users by bundling account creation and initial actions in a single UserOperation.
  • Benefit: Dramatically improves user experience by removing the need for native tokens upfront.
04

Modular Smart Account Deployment

Factories allow for the deployment of modular smart accounts with custom plugins and guards. The factory logic can install specific modules (e.g., multi-signature, recovery, session keys) at the time of creation.

  • Example: Safe{Wallet} uses a Proxy Factory to deploy new Safe multi-sig instances with a defined set of owners and threshold.
  • Benefit: Enables highly customizable and secure account structures from day one.
05

Cross-Chain Account Creation

Advanced factories can deploy counterfactual addresses and create the actual contract on different chains as needed. This enables a unified identity across multiple blockchains.

  • Example: Using ERC-6551, a factory can deploy a Token Bound Account (TBA) for an NFT on any EVM chain, with the same deterministic address.
  • Benefit: Users can interact with a single account address across an entire multi-chain ecosystem.
06

Referral & Reward Programs

Factories can be used to implement on-chain referral systems. A new account can be deployed with built-in logic to credit a referrer, or the factory can mint a Soulbound Token (SBT) to the creator as proof of onboarding.

  • Example: A DeFi protocol's factory could embed a small reward in the newly created account for the user who shared the referral link.
  • Benefit: Creates verifiable, on-chain growth loops and attribution.
ecosystem-usage
ACCOUNT FACTORY

Ecosystem Usage

Account Factories are smart contracts that programmatically create and manage smart accounts, enabling key use cases like onboarding, gas sponsorship, and multi-chain deployment.

01

Onboarding & User Experience

Account Factories are the primary tool for onboarding users to smart accounts. They enable:

  • Social logins via Web2 credentials (e.g., Google, GitHub).
  • Gasless onboarding, where the factory or a dApp pays the initial creation gas fees.
  • Batch creation for projects needing to deploy accounts for many users at once.
  • Deterministic addressing, ensuring a user's account address is predictable and can be funded before creation.
02

Gas Abstraction & Sponsorship

A core utility is abstracting gas fees from the end-user. Factories integrate with Paymasters to enable:

  • Sponsored transactions, where a dApp or relayer covers gas costs.
  • Gas payment in ERC-20 tokens, allowing users to pay fees in stablecoins or app tokens.
  • Session keys, where a factory-deployed account can grant temporary gas sponsorship to a specific dApp.
03

Multi-Chain & Cross-Chain Deployment

Factories manage smart account deployment across multiple blockchains. This involves:

  • Canonical address derivation, using the same salt and owner key to generate the same address on EVM chains (Ethereum, Polygon, Arbitrum).
  • Lazy instantiation, where the account contract is only deployed on a chain when the user first interacts there.
  • Bridging assets directly to a pre-computed address before the account is formally created on the destination chain.
04

Account Recovery & Management

Factories provide frameworks for managing smart account lifecycles beyond creation.

  • Social recovery setups, where a factory can deploy an account with pre-configured guardians.
  • Key rotation, facilitating the deployment of new accounts linked to updated signing schemes or owners.
  • Modular upgrades, allowing newly created accounts to be attached to the latest, most secure implementations of account logic.
05

Integration with EntryPoint & Bundlers

Factories are a critical component of the ERC-4337 (Account Abstraction) stack. They work with:

  • EntryPoint: The singleton contract that validates and executes UserOperations. The factory's createAccount function is often called within a UserOperation.
  • Bundlers: Nodes that bundle UserOperations and submit them to the EntryPoint. Bundlers interact with factories to get the initCode needed for first-time account creation.
security-considerations
ACCOUNT FACTORY

Security Considerations

Account factories introduce unique security vectors that differ from standard externally owned accounts (EOAs) or single smart contract wallets. These considerations center on the factory's authority, user key management, and the security of the generated account contracts.

01

Factory Owner Privileges

The factory contract owner holds significant power, including the ability to upgrade the factory logic or change the implementation contract for newly created accounts. This can introduce centralization risks and upgrade vectors if not properly governed. Key questions include:

  • Is the owner a multi-signature wallet or DAO?
  • Are there timelocks on administrative functions?
  • Can the owner change the bytecode for accounts created in the future?
02

Initialization & Replay Attacks

The initialization call (e.g., via initialize function) that sets up a new smart account is a critical attack surface. If not properly secured, a malicious actor could:

  • Front-run the user's creation transaction.
  • Replay the initialization with different parameters.
  • Take control of the newly deployed account. Secure factories use mechanisms like counterfactual deployment with user-specific salts or require the user's signature for initialization to bind the setup to a specific owner.
03

Verification & Audit Surface

Security depends on the integrity of two components: the factory contract and the account implementation contract. Both must be rigorously audited. A vulnerability in the implementation contract affects all accounts created by the factory. Users must verify:

  • Audit reports for both factory and implementation.
  • Immutable vs. Upgradable design for the implementation.
  • Use of established standards like ERC-4337 for account abstraction, which have undergone extensive community review.
04

Social Engineering & Phishing

Account creation often involves signature requests for meta-transactions or paymaster sponsorship. This creates new phishing opportunities. Attackers might:

  • Trick users into signing a malicious user operation that deploys an account controlled by the attacker.
  • Spoof legitimate factory interfaces in fake dApps. User education on verifying transaction details and using hardware wallets for signing is crucial, as the security model shifts from simple ETH transfers to complex contract interactions.
05

Dependency on EntryPoint & Paymasters

In ERC-4337 account abstraction, the factory's security is intertwined with the EntryPoint contract and any paymaster used. Compromise of these system components can compromise user accounts. Considerations include:

  • EntryPoint centralization: Is it a singleton, and is it audited/verified?
  • Paymaster trust: A malicious paymaster can refuse to sponsor operations or censor users.
  • Staking requirements: EntryPoint may require paymasters to stake ETH, which acts as a security deposit against abuse.
06

Key Management for Smart Accounts

While the factory creates the contract wallet, the user's signer private key remains the ultimate root of security. Best practices are essential:

  • Use a hardware wallet or secure enclave as the signer.
  • Understand the signature scheme (e.g., EOA, multi-sig, passkey).
  • Plan for account recovery (social, guardians) if the smart account supports it, and assess the security of that recovery mechanism separately from factory security.
ACCOUNT ABSTRACTION

Comparison: Factory vs. Traditional Deployment

Key differences between deploying smart contract accounts via a factory contract versus direct, traditional deployment.

FeatureFactory DeploymentTraditional Deployment

Deployment Cost for Users

~0 (sponsored or batched)

Full gas cost (~$10-100+)

Contract Address Determinism

User Onboarding Complexity

Single transaction (UserOperation)

Multi-step (deploy, fund, interact)

Batch / Sponsored Transactions

Initialization Logic

Encapsulated in createAccount

Separate post-deploy call

Account Upgrade Path

Centralized via factory logic

Decentralized, owner-managed

Discovery & Indexing

Centralized event source (AccountCreated)

Decentralized, scan all deployments

Gas Overhead per Account

Lower (initcode pattern)

Higher (full constructor execution)

ACCOUNT FACTORY

Frequently Asked Questions

Common questions about Account Factories, the smart contracts that enable the programmatic creation of smart contract accounts (SCAs) like ERC-4337 wallets.

An Account Factory is a smart contract that programmatically deploys new smart contract accounts (SCAs) for users. It works by accepting a user's initial parameters—typically a signer's public key or a salt—and deterministically deploying a new account contract using the CREATE2 opcode. This allows a user's future account address to be computed before it's funded or deployed, enabling features like gas sponsorship and social recovery. The factory pattern is central to ERC-4337 (Account Abstraction) and ERC-7579 (Modular Account Abstraction), separating the logic of account creation from the account's core functionality.

ENQUIRY

Get In Touch
today.

Our experts will offer a free quote and a 30min call to discuss your project.

NDA Protected
24h Response
Directly to Engineering Team
10+
Protocols Shipped
$20M+
TVL Overall
NDA Protected Directly to Engineering Team