Factory Contract
A smart contract designed to deploy or create other contracts using standardized logic.
Explain Like I'm 12
A smart contract designed to deploy or create other contracts using standardized logic.
Why It Matters
Smart-contract concepts are essential for understanding programmable blockchain applications.
How It Works
The factory contract contains a 'create' or 'create2' function. When invoked, it reads the bytecode of a template contract and uses it to deploy a new address on the blockchain. The factory can keep a record (an array or mapping) of all addresses it has deployed for easy lookup.
Real-World Example
Uniswap v2 uses a Factory contract to deploy a unique Pair contract for every single token liquidity pool that is created on the platform.
Advantages
- Standardizes deployment of related contracts
- Easily manages and lists created instances
- Reduces individual deployment complexity
Limitations
- Increases gas cost for the factory call
- Requires careful management of factory security
- Logic changes require new template contracts
Common Misconceptions
- People think the factory contract acts as a hub for all child data, but child contracts are independent.
- Some believe creating contracts via a factory is free, but it still costs substantial gas for the creation operation.
Knowledge Explorer
Explore This Concept in the Knowledge Graph
See how Factory Contract connects to other concepts, books, research, and developer resources.
Related Terms
ABI
An Application Binary Interface defines how external software encodes calls to and decodes results from a smart contract.
EVM
The Ethereum Virtual Machine (EVM) is a decentralized, Turing-complete computation engine that executes smart contracts on the Ethereum network. It functions as a global state machine, where the state is updated based on code execution on the blockchain. Because the EVM is implemented by every node in the network, it ensures that smart contracts run exactly as intended across all devices, regardless of local hardware differences. This allows for complex, programmable logic to be embedded into the blockchain.
Smart Contract
A smart contract is a self-executing program stored on a blockchain that automatically runs when predetermined conditions are met. These contracts eliminate the need for intermediaries by encoding terms directly into lines of code, ensuring that the agreement is enforced exactly as written without human interference. Because they reside on an immutable ledger, the execution results are verifiable, transparent, and impossible to tamper with once deployed.
Smart Contract
A self-executing program stored on a blockchain that automatically enforces and executes the terms of an agreement when predetermined conditions are met. Smart contracts are deterministic, immutable once deployed, and form the backbone of decentralized applications.
Solidity
Solidity is the primary high-level, object-oriented programming language used for writing smart contracts that execute on the Ethereum Virtual Machine (EVM). It is statically typed and supports inheritance, libraries, and complex user-defined types. Solidity was designed specifically for blockchain environments to facilitate the creation of self-executing contracts with contract-based accountability. It is heavily influenced by C++, Python, and JavaScript, making it relatively accessible to developers coming from traditional software engineering backgrounds who are transitioning into the Web3 ecosystem.