This repository provides a convenient way to implement the Diamond Proxy pattern (EIP-2535) in a Foundry (Forge) environment, along with CreateX integration for multiple deployment methods (create2, create3, etc.).
The main goal is to simplify the creation and management of modular, upgradeable smart contracts by leveraging the Diamond Proxy pattern. This project is inspired by diamond-3-hardhat.
You can find the sample boilerplate code at diamond-boilerplate. To get started immediately, clone this repository.
forge install JhChoy/diamond
- Diamond Proxy pattern implementation
- CreateX integration for deterministic deployments
- Modular contract architecture
- Upgradeable smart contracts
- Chain-agnostic deployment addresses
diamond/
├── src/
│ ├── diamond/ # Core Diamond implementation
│ ├── interfaces/ # Contract interfaces
│ └── libraries/ # Shared libraries
├── test/ # Test files
└── script/ # Deployment scripts
forge test
Create3: Since DiamondApp should be deployed only once per project, we use Create3 to ensure a deterministic, chain-agnostic address for deployment. Create2: Facets are implementation contracts that need to be deployed once per chain. During upgrades, if the contract code changes, new deployments are required, which is why we utilize Create2.
All contributions are welcome. If you find any issues, please report them in the Issues section.
MIT