Simplicity of EIP-2535 Diamonds Standard
To implement EIP-2535 Diamonds the following is required:
A fallback function that executes external functions with delegatecall.
A DiamondCut event is emitted when functions are add/replaced/removed from a diamond. This is to make upgrades of diamonds transparent on blockchains.
A diamond has four read-only external functions:
facets()
facetFunctionSelectors(address _facet)
facetAddress(bytes4 _functionSelector)
facetAddresses()
These functions return information about the functions that have been added to a diamond.
That’s it. That is what is required to implement EIP-2535 Diamonds and make a diamond. If that seems small and simple, it is. It is smaller than any token standard. For example the ERC20 token standard requires 9 functions and 2 events. The EIP-2535 Diamonds standard requires 4 functions, 1 event and a fallback function.
The EIP-2535 Diamonds standard also has an optional `diamondCut` external function that can be used to add/replace/remove external functions, emit the DiamondCut event, and optionally execute an initializer function.
The standardization, simplicity and flexibility of EIP-2535 Diamonds provides a foundation upon which people can build many things.
There are many ways to implement EIP-2535 Diamonds. Some implementations are simpler than others. A simple and good implementation is embedded in the standard and also exists on github.
If a developer does not understand how Solidity stores data and does not understand how delegatecall works then he/she won’t understand how diamonds work. The actual problem here isn’t complexity of diamonds, it is a lack of knowledge/understanding/familiarity of Solidity storage and delegatecall. A good explanation of how delegatecall works can be found in the article here:
EIP-2535 diamonds enable developers to organize a lot of smart contract functionality under a single Ethereum address. So it is possible to use diamonds to build complex things.
Information about compliance with the EIP-2535 Diamonds standard is here: