Skip to content

dadadave80/diamond-lib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

πŸ’Ž 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/diamond-lib
  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

πŸ’Ž ERC-2535: Diamonds, Multi-Facet Proxy Library

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published