This project implements a comprehensive NFT ecosystem using the EIP-2535 Diamond Pattern. It transitions from a centralized ownership model to a fully decentralized, DAO-governed protocol where all upgrades are managed by a Multi-Signature governance system.
The protocol uses a single proxy (the Diamond) that delegatecalls to multiple facets. This allows the system to bypass the 24KB contract size limit and remain modular and upgradeable.
All facets share a central storage state through LibAppStorage.sol. This prevents storage collisions and allows different facets (like the Marketplace and Staking pool) to interact with the same underlying data efficiently.
The protocol is governed by a Multi-Sig facet (DiamondMultisig.sol). No single owner has control over the system.
- Proposals: Any signer can propose a
diamondCutupgrade. - Quorum: A required number of signers must approve the proposal.
- Execution: Once quorum is met, the Diamond automatically executes the upgrade and updates its internal function selectors.
A custom implementation of the ERC721 standard written from scratch.
- On-Chain Metadata: Generates a high-end SVG card directly on-chain.
- Ownership Logic: Custom transfer and approval mechanisms optimized for Diamond storage.
A custom ERC20 implementation used as the primary currency within the marketplace. It manages balances and allowances for P2P trading.
Allows users to list and buy NFTs using the custom ERC20 token.
- Escrowless Listing: NFTs remain in the user's wallet until bought (requires approval).
- Consensus-Based Trading: Ensures atomicity between payment and transfer.
A peer-to-peer lending economy.
- Staking: Users lock NFTs into the Diamond escrow.
- Borrowing: Other users can borrow staked NFTs for a set duration.
- Escrow Management: The system automatically tracks due dates and ownership status.
- Foundry (Forge & Cast)
git clone <repository-url>
cd Foundry-Hardhat-Diamonds
forge installThe project includes a robust test suite that simulates the entire lifecycle, including Multi-Sig upgrades and DeFi interactions.
Run all tests:
forge test -vvRun specific ecosystem tests:
forge test --match-path "test/NFT*.t.sol" -vv- All sensitive functions are protected by the
onlySignermodifier. - State management is strictly controlled via the
AppStoragestruct to ensure consistency across upgrades. - Error handling uses gas-efficient custom errors (
if (...) revert ERROR()).