A modular, upgradeable smart contract framework built using the EIP-2535 Diamond Standard. This template provides a clean foundation for building composable and gas-efficient smart contracts with facet-based architecture.
- ⚙️ Facets: Modular smart contract logic components
- 🔁 Upgradeable: Add, replace, or remove functions at runtime
- 🧪 Foundry test suite: Includes deployment and mutation tests
- 🔍 Loupe Functions: Introspect facet addresses and selectors
- 👑 Role-based Access Control via
OwnableRolesFacet - 📚 ERC165 Interface Support
- 🚀 Automated Deploy Script
.
├── src/
│ ├── Diamond.sol # Diamond core contract
│ ├── facets/ # All facets (logic modules)
│ ├── initializer/ # Initializer for setting up ERC165 and others
│ ├── interfaces/ # Diamond-compliant interfaces (e.g. IDiamondCut)
│ ├── libraries/ # DiamondStorage, LibDiamond, etc.
│ └── scripts/DeployDiamond.s.sol # Foundry deployment script
│
├── test/
│ ├── DiamondTest.t.sol # Tests for core diamond behavior
│ └── helpers/ # Reusable test helpers and states
│
└── foundry.toml # Foundry config- Forge install this repo
forge install DADADAVE80/erc2535-diamond-template- Import the Diamond contract and facets into your project
import {Diamond} from "@diamond/Diamond.sol";
import {DiamondCutFacet} from "@diamond/facets/DiamondCutFacet.sol";
import {DiamondLoupeFacet} from "@diamond/facets/DiamondLoupeFacet.sol";
import {OwnableRolesFacet} from "@diamond/facets/OwnableRolesFacet.sol";- Run Tests
forge test --ffi -vvv- Deploy Locally
forge script script/DeployDiamond.s.sol --fork-url <RPC_URL> --broadcast| Facet | Purpose |
|---|---|
| DiamondCutFacet | Adds/replaces/removes functions |
| DiamondLoupeFacet | View functions for facets/selectors |
| OwnableRolesFacet | Ownership & role-based access |
MIT © 2025
Built with ♥ by David Dada