Deployer
Introduction
MDCreate2 is a factory contract that enables deterministic deployment of distributor instances using CREATE2
. This ensures predictable contract addresses and provides a unified deployment interface for both Merkle and ECDSA distributors.
🚀 Quick Start
What is MDCreate2?
MDCreate2 is a factory contract that:
Deploys distributor contracts deterministically using
CREATE2
Manages implementation addresses for different distributor types
Configures fee collectors and fee tokens
Provides address prediction before deployment
Key Benefits
✅ Deterministic Addresses - Predict contract addresses before deployment
✅ Multiple Implementations - Support various distributor types
✅ Fee Management - Centralized fee configuration
✅ Gas Efficient - Minimal proxy pattern for deployments
📋 Factory Overview
Architecture
Key Components
Implementation Registry - Maps distributor types to implementation addresses
Deployment Tracking - Maps project IDs to deployed addresses
Fee Configuration - Manages fee collectors and tokens
Clone Factory - Uses OpenZeppelin's Clones library
🔧 Contract Details
Storage
Key Functions
Deployment Functions
deploy()
Deploys a new distributor instance
simulateDeploy()
Predicts deployment address without deploying
Configuration Functions
setImplementation()
Registers implementation for distributor type
setDefaultFeeParams()
Sets default fee collector
setDeploymentFeeParams()
Sets fee collector for specific deployment
View Functions
feeCollectors()
Returns fee collector for deployment
feeTokens()
Returns fee token for deployment
version()
Returns factory version
🔐 Security Considerations
Access Control
Owner
Register implementations, set fee parameters
Anyone
Deploy distributors, simulate deployments
Deployment Safety
Unique Project IDs - Each project ID can only be used once
Implementation Validation - Only registered implementations can be deployed
Initialization - Deployed contracts must be initialized by deployer
🛠️ CREATE2 Mechanics
Address Calculation
The deployment address is deterministically calculated using:
Benefits
Predictable Addresses - Know contract address before deployment
Cross-chain Consistency - Same address on different chains
Counterfactual Instantiation - Reference contracts before deployment
📊 Fee System Integration
Fee Flow
Fee Configuration
Default Collector - Applied to all new deployments
Custom Collector - Override for specific deployments
Fee Tokens - Retrieved from fee collector contract
🔄 Versioning
The factory maintains its own version independent of distributor implementations.
📡 Events
DidDeploy
Emitted when distributor is deployed
🔍 Error Handling
UnsupportedOperation
Project ID already used
0x9ba6061b
📚 Implementation Types
0
TokenTableMerkleDistributor
1
TokenTableNativeMerkleDistributor
2
SimpleERC721MerkleDistributor
3
NftGatedMerkleDistributor
4
CustomFeesNativeMerkleDistributor
5
SimpleNoMintERC721MerkleDistributor
6
FungibleTokenECDSADistributor
7
FungibleTokenWithFeesECDSADistributor
Last updated
Was this helpful?