Skip to content

dadadave80/oz-diamond-compatible-contracts

Repository files navigation

💎 Diamond Template

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.


📦 Features

  • ⚙️ 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

🛠️ Project Structure

.
├── 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

🚀 Getting Started

  1. Forge install this repo
forge install DADADAVE80/erc2535-diamond-template
  1. 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";
  1. Run Tests
forge test --ffi -vvv
  1. Deploy Locally
forge script script/DeployDiamond.s.sol --fork-url <RPC_URL> --broadcast

🧩 Facets Included

Facet Purpose
DiamondCutFacet Adds/replaces/removes functions
DiamondLoupeFacet View functions for facets/selectors
OwnableRolesFacet Ownership & role-based access

📘 References


🧠 License

MIT © 2025
Built with ♥ by David Dada


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published