ERC-2535

ERC-2535 (the Diamond standard) is an upgradeable contract pattern where a single proxy delegates calls to multiple implementation contracts (facets) based on function selectors.

In Depth

ERC-2535 defines the Diamond proxy pattern, the most structurally complex upgradeable contract architecture in Solidity. A single proxy maintains a mapping from function selectors to facet addresses, and the diamondCut() function modifies this mapping to add, replace, or remove facets. Four loupe functions provide read access to the current routing configuration. This design creates bug classes around selector collisions, storage slot corruption across facets, upgrade atomicity violations, and dangling selectors after facet removal. Fuzzing is critical because these bugs emerge from sequences of upgrades, not individual operations. For the full invariant breakdown, see How to Fuzz ERC-2535 Diamond Proxies.

Frequently Asked Questions

What is ERC-2535?

ERC-2535, also known as the Diamond standard, is a Solidity proxy pattern that delegates function calls to multiple implementation contracts called facets. Each facet handles a different set of function selectors, and the diamond can be upgraded by adding, replacing, or removing facets through the diamondCut() function.

How do you test diamond proxy upgrades?

Testing diamond proxies means writing invariants for selector uniqueness (no two facets claim the same selector), loupe/routing consistency (loupe functions reflect the actual routing table), storage isolation (facet A's writes don't corrupt facet B's state), and upgrade atomicity (multi-facet upgrades are all-or-nothing). See the ERC-2535 fuzzing guide for the complete approach.

Related Terms

Related Blog Posts

Need expert help with erc-2535?