Achieving Universal and Reusable Smart Contracts via ERC2535 Diamond Proxy Standard

Achieving Universal and Reusable Smart Contracts via ERC2535 Diamond Proxy Standard

Achieving Universal and Reusable Smart Contracts via ERC2535 Diamond Proxy Standard

Smart contracts revolutionized the blockchain ecosystem by enabling a wide range of decentralized applications (dApps) for various purposes. However, their complexity and the need for skilled developers and auditors hinder the mass adoption.

This article explores the concept of universal and reusable smart contracts using a Diamond Management System, and how it can be structured to allow cooperation between developers, auditors, and non-technical users alike. The aim is to create a more accessible and efficient protocol for building and managing smart contracts across the web3 landscape.

By having a Diamond Factory for users, and a Facet Registry for developers and auditors, along with a DAO representing the whole community, it is possible to create a system that is both flexible and secure, while also making it easy for non-technical enthusiasts to create their own smart contracts without any coding skills.

Universal & Reusable Smart Contracts

Smart Contracts are the back-bone of all decentralized applications (dApps), i.e. fungible (ERC20) and non-fungible tokens (NFT), DeFi exchanges, DAO governance systems, Smart wallets, Oracles, Marketplaces and other protocols that operate with assets of billions in value.

One aspect that hinders adoption is that smart contracts are hard to learn, develop and audit, and besides that there is a huge demand for building them. At the same time, the Ethereum network is congested with highly homogeneous code used only in a small portion, therefore node providers have to store redundant information. Certainly, the blockchain ecosystem would benefit from a way to create and reuse trusted smart contracts, which decreases the network load and speeds up the development of dApps.

Diamond Management System: A Solution

In the previous article, the notion of a Diamond Management System was introduced, which allows us to basically create an on-chain library for smart contracts that can be extended with the modular system described in the ERC2353 Diamond Proxy Standard.

Using this standard we can achieve universal and reusable smart contracts that can be created by anyone given a library of powerful and secure template-like contracts called Facets.

However, for this to be possible the ecosystem has to be backed by a community of developers, that write the functionality, and one consisting of auditors that review and provide feedback on security vulnerabilities and disallow the use of malicious contracts.

This article describes in more detail how such a protocol can be structured and provides technical insights that can be helpful for on-boarding future smart contract developers and auditors.

An ecosystem for creating universal and reusable smart contracts.

At its core, the protocol is built around two key concepts: the Diamond Factory and the Facet Registry. The factory is responsible for creating new Diamond proxies and interacting with the registry on adding or removing the Facets correctly. At the same time, the Diamond Factory has to abstract away the process of customizing the Diamond, in order to batch multiple upgrades into a single transaction and protect the user from accidentally messing up some state.

At its level, the Facet Registry is responsible for keeping track of the implementation addresses of Facets and their type of behavior, as it would be better to handle smart contract introspection automatically and don’t let non-technical users worry about it. Similarly, the Facets can include initializers (i.e. if they are stateful) as well as custom migration and upgrade methods, which a Diamond proxy calls on its behalf to set up the initial state for some variables. Therefore, the user also doesn’t have to know the intrinsics of App or Diamond Storage and the risks of overwriting state.

The Role of Developers and Auditors in the Ecosystem

Within the protocol, smart contract developers and auditors cooperate in various methods, first by proposing a PR of the Facet on GitHub and submitting an RFC on the governance forum, then through feedback, validation, and voting such that finally a Facet is registered and can be used within a Diamond.

To further protect the community of builders using these Facets, an auditor role requires a decent amount of hard work and is reserved for the ones with the most capable craftsmanship skills and attention to detail.

On the other hand, anyone who knows Solidity can propose Facets with interesting functionality, as long as it is up to the rules specified in the protocol (e.g. code conventions, no duplicates, passes tests, etc.). In this way, the ecosystem allows diversification and new opportunities for engineers to manifest, and possibly even earn rewards based on their contributions (the incentive mechanism will be described in future articles).

Building Custom Smart Contracts with Diamonds and Facets

When a new Diamond proxy is created, it is constructed from a set of Base Facets stored in the Registry, some of which are mandatory in order to correspond with Ethereum standards. After deployment, the user has the choice to extend the functionality of these base facets or add more on top of them, i.e. a base facet for creating ERC20 tokens, ERC721 tokens, ERC1155 tokens, ERC-4337 Smart Accounts, DAO governors, etc.

For example, if a user wants to create an NFT collection of soul-bound tokens, then she/he creates a diamond with the ERC721 base Facet and adds another Facet implementing the soul-bound functionality, which of course has gone through the entire validation process and is listed on the Facet Registry.

After adding the Facet to your Diamond Proxy, it will automatically start delegating calls to that new Facet, thus supporting its functionality, all of that without requiring any coding or learning activities on the behalf of the user.

The DAO: A Community-Driven Approach

Essentially, the ecosystem behind the protocol is backed by a community of web3 users and builders, smart contract developers, and auditors that constitute the DAO (Decentralized Autonomous Organization). Each peer participates in establishing decisions regarding the protocol depending on their technical expertise.

Users vote for a list of the most wanted functionality, developers vote for their auditors, which at their level vote for the upgrades within the protocol, and everyone votes for expenses of the DAO treasury and the next directions for involving the larger community.


Let’s work together to shape the future of smart contract development and management. Share your thoughts, feedback, and ideas with us on Twitter, Telegram or Discord, and join the conversation as we refine the Diamond Management System .

Don’t forget to follow my channel for updates on future articles and discussions.

Your input is invaluable in creating a more accessible and efficient blockchain ecosystem for everyone..

Hope this was helpful and interesting for you!