Diamond
Diamond standard
The Diamond standard is a finalized Ethereum Improvement Proposal (EIP-2535) that aims to make it easier for developers to modularize and upgrade their smart contracts.
The core idea is that you can control many implementation contracts from your single Diamond contract (proxy contract). Some key features of the Diamond standard include:
A single gateway to make proxy calls to n number of implementation contracts
Upgrade a single or multiple smart contract atomically
No storage limit to how many implementation contracts you can add to your Diamond
A log history of all the upgrades made on the Diamond
Can reduce gas costs (i.e., by reducing the number of external function calls)
Diamond
The diamond is the smart contract that serves as the proxy. It calls (delegatecall) other implementation contracts known as facets.
Facets
Implementation contract or lib -> contracts that hold external fn, that the proxy(diamond) will call to.
No limit on number of facets
Facets are deployed separately from your Diamond contract and can be added into your Diamond using
diamondCut
The benefit of Facets within a Diamond contract is that it allows you to modularize your code and only update what's needed. Unlike a typical proxy pattern where you would need to redeploy a new implementation contract, with Facets since you can have many implementation contracts, you can update multiple Facets (e.g., multiple implementation contracts) or an individual Facet.
Example
Last updated