Skip to main content

Diamonds

Learn how we use diamonds for upgradeable contracts.

What are Diamonds ?

EIP-2535 Diamonds is a standard for creating modular, upgradeable, and extendable smart contracts in Ethereum, also known as "Diamonds." The standard was proposed in Ethereum Improvement Proposal 2535 (EIP-2535) by Nick Mudge. Diamonds introduce a technique called "function selectors" to delegate and manage multiple contracts, enabling the creation of complex and efficient systems.

How do we use Diamonds

This allows contracts to grow beyond the code size limit of 24kb, and to consist of stateless logic functions. This allows us to use a Diamond Smart Contract Architecture to support standardized upgradeability, and to allow for you to install modular smart contract logic into your NFT. Every NFT or smart contract deployed on 1o1 is at it's core a Diamond

Diamond Core Components

  • Function Selectors: Diamonds use a concept called function selectors, which are unique identifiers for each function within a contract. These selectors are generated by taking the first four bytes of the Keccak-256 hash of the function signature.

  • Facets: A Diamond contract comprises multiple smaller contracts called Facets. Facets contain the actual functionality of the Diamond, and each Facet corresponds to a group of function selectors.

  • Diamond Storage: The Diamond contract holds the storage for all its Facets. The contract also includes a Diamond Storage that maps function selectors to their respective Facets.

  • DiamondCut: The DiamondCut function is used to add, replace, or remove Facets and their corresponding function selectors. This enables the upgradeability and extensibility of the Diamond contract.

  • Diamond Loupe: EIP-2535 also includes a set of standard functions called the Diamond Loupe. These functions allow users to inspect and interact with the Diamond's Facets and function selectors.

Learn More

Reference Links: