πDiamond Proxies
ERC2535: Diamond Multi-Facet Proxy Standardβ describes a modular smart contract system that can be upgraded or extended after deployment, lives at a single address and practically has no code size limits. Essentially, a Diamond Proxy is a facade over multiple functionality components, called Facets, which structure the storage layout in an isolated manner. In a similar fashion, a Diamond implements the builder design pattern, that allows you to gradually create complex contracts and produce different types and representations of them.
Diamond smart contracts tackle some key limitations faced in programmable blockchain networks, such as code size restrictions, upgradeability, and modularity, while also not sacrificing immutability. Using Diamonds, you can obtain highly flexible and extensible smart contracts that can evolve or adapt over time, and whose history of upgrades is available on-chain.
Throughout the web3 space, can be found at the beautiful awesome diamonds GitHub repository. There are some promising projects using Diamond smart contracts, which emphasize themselves by supporting a wide range of complexity or as an aggregation tool of other protocols:
Aavegotchi β a pixelated universe of ghosts, where you collect items and participate in various activities, i.e. games, events, raffles, lending, governance, staking, and many more.
LI.FI β a cross-chain DeFi protocol for swapping and bridging assets that brings us one step closer to interoperability and widespread adoption.
Geo Web β a network that connects the real world to the decentralized space, where you can own a digital representation of a physically-tied location, such as your house.
The design specifies a fallback function that delegates to other library-like contracts called Facets, that contain the functionality and storage specifications, isolated through a dedicated storage slot pattern, i.e. Diamond Storage, in order to avoid data fragmentation problems. Every time a Facet is added, replaced or removed, the Diamond logs the upgrade on-chain in a retrievable manner. Besides that, a Diamond can perform custom initialization procedures in order to set up some data, like in a constructor or upon a migration.
Besides that, the standard allows immutability if we remove the function responsible for upgrade, which can be performed directly at deployment or any time after that. The possibilities for customizing are endless, and on top of that, the full history of changes is available on-chain and can be audited at any time. Therefore, you have all the necessary features for continuously building secure and powerful smart contracts and the possibility to turn them into precious web3 diamonds.
Last updated