generateErc1167(implementation: Uint8Array): Uint8Array
Generates ERC-1167 minimal proxy bytecode for gas-efficient contract cloning.
Creates 55-byte creation code that deploys 45-byte runtime code delegating all calls to the implementation.
Parameters:
implementation: Uint8Array- 20-byte implementation address
Uint8Array - 55-byte creation code
Throws:
Error- If implementation address is not 20 bytes
Bytecode Structure
Creation Code (10 bytes)
| Opcode | Value | Description |
|---|---|---|
| 3d | RETURNDATASIZE | Push 0 (gas optimization) |
| 60 2d | PUSH1 45 | Runtime code length |
| 80 | DUP1 | Duplicate length |
| 60 0a | PUSH1 10 | Creation code length |
| 3d | RETURNDATASIZE | Push 0 |
| 39 | CODECOPY | Copy runtime code to memory |
| 81 | DUP2 | Duplicate length |
| f3 | RETURN | Return runtime code |
Runtime Code (45 bytes)
| Opcode | Description |
|---|---|
| 363d3d37 | Copy calldata to memory |
| 3d3d3d363d73 | Prepare DELEGATECALL |
| [implementation] | 20-byte implementation address |
| 5af4 | DELEGATECALL to implementation |
| 3d82803e | Copy returndata |
| 903d91602b57 | Check success |
| fd5bf3 | REVERT or RETURN |
Gas Efficiency
Deployment Cost Comparison
Clone Factory Pattern
CREATE2 Deterministic Clones
Use Cases
- Token Factories: Deploy minimal token clones
- NFT Collections: Gas-efficient NFT contract instances
- Wallet Clones: Account abstraction wallet instances
- Marketplace Listings: Per-listing contract instances
- DAO Modules: Modular DAO component instances
See Also
- parseErc1167 - Extract implementation from deployed clone
- isErc1167 - Check if bytecode is ERC-1167
- generateErc3448 - MetaProxy with metadata
- ERC-1167 Specification

