Solia saysThe Diamond Standard (EIP-2535) splits one contract into many "facets" routed by function selector — letting you ship contracts larger than the 24KB code limit and upgrade pieces independently.
Ethereum caps contract code at 24 KB (EIP-170). For complex protocols this is painful: a full ERC-20 + ERC-721 + governance contract bursts the limit. EIP-2535 Diamonds solve this with a proxy that routes calls based on the 4-byte function selector to one of many facets — separate implementation contracts each holding some subset of the protocol's functions.
You can add, replace, or remove facets via a diamondCut call, independently per function. The trade-off is complexity: storage must use a shared layout (DiamondStorage pattern), and the routing table itself takes storage. The demo dispatches four selectors to their facets.
Power-ups you unlock
One proxy routes selectors to many facets
Bypasses the 24KB single-contract code limit
diamondCut adds/replaces/removes facets per function
Storage uses a shared-layout pattern (DiamondStorage)
Standardized as EIP-2535
The Reentrancy Reaper attacks — common mistakes
Storing state with conflicting layouts across facets
Forgetting to remove old selectors when upgrading a facet
Treating diamonds as a default — they add real complexity
Skipping the loupe interface (introspection of facets)
Boss battleDispatch four function selectors to a 3-facet diamond and identify which facet each routes to.