Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

Diamond Standard (EIP-2535)

1 min read
Pronunciation
[dahy-muhnd stan-derd]
Analogy
Imagine instead of having one large office building (a single logic contract) that's hard to renovate, you build your company headquarters (the Diamond) as a central hub connected to many smaller, specialized buildings (facets), each handling different functions (e.g., HR, Sales, R&D). You can upgrade or replace any specialized building independently without disrupting the others, and add new buildings as needed. The central hub directs visitors to the correct building based on what service they need.
Definition
An Ethereum Improvement Proposal (EIP-2535) that standardizes a modular smart contract system allowing contracts to be upgraded incrementally and have virtually no size limit. It uses a central proxy contract (the Diamond) that delegates function calls to multiple logic contracts (called 'facets') based on function signatures.
Key Points Intro
The Diamond Standard provides a highly modular and flexible approach to smart contract upgradeability and organization.
Key Points

Defined by EIP-2535.

Uses a main proxy contract (Diamond) that routes function calls to different implementation contracts (Facets) based on function selectors.

Allows adding, replacing, or removing functions granularly by updating which facet implements a particular function.

Overcomes contract size limits by splitting logic across multiple facets.

State is typically shared across facets, stored within the Diamond proxy.

Provides introspection capabilities to query which functions are supported by which facets.

Example
A complex DeFi protocol could use the Diamond Standard to manage its numerous functions. Separate facets could handle lending, borrowing, staking, governance voting, etc. The team could upgrade the lending facet without affecting the staking facet's code. New features could be added by deploying new facets and registering their functions with the Diamond.
Technical Deep Dive
The Diamond proxy maintains a mapping from function selectors (4-byte identifiers) to facet addresses. When a function is called on the Diamond, it looks up the selector in its mapping and uses `delegatecall` to forward the call to the appropriate facet address. Diamond Standard also defines standard functions (`diamondCut`) for adding/replacing/removing functions and facets, typically controlled by an owner or governance mechanism. It includes standards for managing storage layout (Diamond Storage) and event emission.
Security Warning
The Diamond Standard's flexibility also introduces complexity. The `diamondCut` function is extremely powerful and must be tightly secured. Careful state management (Diamond Storage) is needed to avoid storage collisions between different facets. Thorough auditing is crucial.

Diamond Standard (EIP-2535) - Related Articles

No related articles for this term.