1"use strict";(self.webpackChunkcompose_documentation=self.webpackChunkcompose_documentation||[]).push([["7600"],{11035(e,n,i){i.r(n),i.d(n,{assets:()=>d,contentTitle:()=>r,default:()=>p,frontMatter:()=>a,metadata:()=>t,toc:()=>l});var t=i(28407),o=i(62540),s=i(43023);let a={slug:"introducing-erc-8109-diamonds",title:"Introducing ERC-8109 Diamonds, a Standard for Simpler Diamond Contracts",authors:["mudgen"],tags:["architecture","standards"]},r,d={authorsImageUrls:[void 0]},l=[{value:"A Flawed Narrative",id:"a-flawed-narrative",level:2},{value:"How Diamonds Reduce Complexity",id:"how-diamonds-reduce-complexity",level:2},{value:"ERC-8109: Diamonds, Simplified",id:"erc-8109-diamonds-simplified",level:2},{value:"1. Simplifying terminology",id:"1-simplifying-terminology",level:3},{value:"2. Simplifying introspection",id:"2-simplifying-introspection",level:3},{value:"3. Standardizing simpler events",id:"3-standardizing-simpler-events",level:3},{value:"4. Defining an optional upgrade function",id:"4-defining-an-optional-upgrade-function",level:3},{value:"5. Providing an optional upgrade path",id:"5-providing-an-optional-upgrade-path",level:3},{value:"Compose",id:"compose",level:2},{value:"Call to Action",id:"call-to-action",level:2}];function c(e){let n={a:"a",blockquote:"blockquote",em:"em",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:["This post is adapted from an article originally ",(0,o.jsx)(n.a,{href:"https://eip2535diamonds.substack.com/p/introducing-erc-8109-diamonds-simplified",children:"published on my Substack"}),", and is reposted here because ERC-8109 directly informs the architecture and goals of Compose."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["While working on Compose, I decided to revisit parts of ",(0,o.jsx)(n.a,{href:"https://eips.ethereum.org/EIPS/eip-2535",children:"ERC-2535 Diamonds"})," to see how the standard could be improved. Initially, I thought this would be limited to terminology changes, which led to my post ",(0,o.jsx)(n.a,{href:"https://ethereum-magicians.org/t/revising-erc-2535-diamonds-to-simplify-and-improve-the-terminology/26973",children:"Revising ERC-2535 Diamonds to Simplify and Improve the Terminology"}),"."]}),"\n",(0,o.jsx)(n.p,{children:"However, that effort revealed deeper opportunities for improvement \u2014 enough that I ultimately decided to propose a new standard for diamond contracts."}),"\n","\n",(0,o.jsx)(n.h2,{id:"a-flawed-narrative",children:"A Flawed Narrative"}),"\n",(0,o.jsx)(n.p,{children:"The primary issue I wanted to address is complexity."}),"\n",(0,o.jsx)(n.p,{children:"Too many articles and discussions imply that diamonds are inherently complex, or that they should only be used when building complicated systems. That narrative is backwards."}),"\n",(0,o.jsxs)(n.p,{children:["Diamonds should be used when you want to build ",(0,o.jsx)(n.strong,{children:"large systems that remain simple"})," \u2014 systems that are easy to understand, reason about, test, audit, and evolve."]}),"\n",(0,o.jsx)(n.p,{children:"Any powerful tool can be used well or poorly. Diamonds can reduce complexity, or they can increase it if misapplied."}),"\n",(0,o.jsx)(n.p,{children:"Let\u2019s do this right."}),"\n",(0,o.jsx)(n.h2,{id:"how-diamonds-reduce-complexity",children:"How Diamonds Reduce Complexity"}),"\n",(0,o.jsx)(n.p,{children:"Diamonds reduce complexity in two fundamental ways:"}),"\n",(0,o.jsxs)(n.ol,{children:["\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsx)(n.p,{children:"A single contract address\nA diamond exposes a large surface area of functionality through one address, simplifying deployment, integration, tooling, and user interfaces."}),"\n"]}),"\n",(0,o.jsxs)(n.li,{children:["\n",(0,o.jsx)(n.p,{children:"Decomposition into focused facets\nLarge contracts are broken into small, purpose-built facets. Each facet is independently testable and understandable. The diamond then wires these facets together in a systematic, efficient, and documented manner."}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"The benefits of modularity are well understood in software engineering \u2014 and diamonds bring those benefits on-chain."}),"\n",(0,o.jsx)(n.h2,{id:"erc-8109-diamonds-simplified",children:"ERC-8109: Diamonds, Simplified"}),"\n",(0,o.jsxs)(n.p,{children:["The new standard, ",(0,o.jsx)(n.a,{href:"https://eips.ethereum.org/EIPS/eip-8109",children:"ERC-8109: Diamonds, Simplified"}),", focuses on reducing complexity while preserving the full power of diamond contracts. It does so by:"]}),"\n",(0,o.jsx)(n.h3,{id:"1-simplifying-terminology",children:"1. Simplifying terminology"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"\u201Cloupe\u201D \u2192 introspection"}),"\n",(0,o.jsx)(n.li,{children:"\u201Ccut\u201D \u2192 upgrade"}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"2-simplifying-introspection",children:"2. Simplifying introspection"}),"\n",(0,o.jsx)(n.p,{children:"Only two introspection functions are required:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"facetAddress(selector) \u2014 returns the facet address for a given function selector"}),"\n",(0,o.jsx)(n.li,{children:"functionFacetPairs() \u2014 returns all (selector, facet) pairs"}),"\n"]}),"\n",(0,o.jsx)(n.h3,{id:"3-standardizing-simpler-events",children:"3. Standardizing simpler events"}),"\n",(0,o.jsx)(n.p,{children:"Replaces the monolithic DiamondCut event with per-function events:"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"DiamondFunctionAdded"}),"\n",(0,o.jsx)(n.li,{children:"DiamondFunctionReplaced"}),"\n",(0,o.jsx)(n.li,{children:"DiamondFunctionRemoved"}),"\n"]}),"\n",(0,o.jsx)(n.p,{children:"These events simplify the implementation of functions that add/replace/remove functions and are easier for block explorers, indexers, and other tooling to consume."}),"\n",(0,o.jsx)(n.h3,{id:"4-defining-an-optional-upgrade-function",children:"4. Defining an optional upgrade function"}),"\n",(0,o.jsx)(n.p,{children:"An explicitly specified, optional, upgrade function, including metadata support, to ensure consistent behavior across tooling."}),"\n",(0,o.jsx)(n.h3,{id:"5-providing-an-optional-upgrade-path",children:"5. Providing an optional upgrade path"}),"\n",(0,o.jsx)(n.p,{children:"Existing ERC-2535 diamonds can adopt the new standard."}),"\n",(0,o.jsx)(n.h2,{id:"compose",children:"Compose"}),"\n",(0,o.jsx)(n.p,{children:"Compose goes beyond standards and documentation. Compose is the practical application of the ideas behind ERC-8109."}),"\n",(0,o.jsxs)(n.p,{children:["Together with ",(0,o.jsx)(n.a,{href:"https://github.com/maxnorm",children:"maxnorm"})," and others, I\u2019m building Compose to help developers use ERC-8109 Diamonds to construct modular smart-contract systems. Compose will provide:"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:"A library of reusable, on-chain facets."}),"\n",(0,o.jsx)(n.li,{children:"Tooling for deploying, testing, and working with diamonds."}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["Compose is intended to make the ",(0,o.jsx)(n.em,{children:"right"})," way to build diamond systems the ",(0,o.jsx)(n.em,{children:"easy"})," way."]}),"\n",(0,o.jsx)(n.h2,{id:"call-to-action",children:"Call to Action"}),"\n",(0,o.jsxs)(n.p,{children:["Please read the new standard here:\n",(0,o.jsx)(n.a,{href:"https://eips.ethereum.org/EIPS/eip-8109",children:"ERC-8109: Diamonds, Simplified"})]}),"\n",(0,o.jsxs)(n.p,{children:["Share your feedback here:\n",(0,o.jsx)(n.a,{href:"https://ethereum-magicians.org/t/erc-8109-diamonds-simplified/27119",children:"Feedback for ERC-8109: Diamonds, Simplified"})]}),"\n",(0,o.jsx)(n.p,{children:"If you care about building large smart contract systems that remain simple, understandable, and robust, I invite your collaboration."})]})}function p(e={}){let{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(c,{...e})}):c(e)}},43023(e,n,i){i.d(n,{R:()=>a,x:()=>r});var t=i(63696);let o={},s=t.createContext(o);function a(e){let n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:a(e.components),t.createElement(s.Provider,{value:n},e.children)}},28407(e){e.exports=JSON.parse('{"permalink":"/blog/introducing-erc-8109-diamonds","editUrl":"https://github.com/Perfect-Abstractions/Compose/tree/main/website/blog/2025-12-31-introducing-erc-8109-diamonds.md","source":"@site/blog/2025-12-31-introducing-erc-8109-diamonds.md","title":"Introducing ERC-8109 Diamonds, a Standard for Simpler Diamond Contracts","de
1scription":"This post is adapted from an article originally published on my Substack, and is reposted here because ERC-8109 directly informs the architecture and goals of Compose.","date":"2025-12-31T00:00:00.000Z","tags":[{"inline":false,"label":"Architecture","permalink":"/blog/tags/architecture","description":"Architecture in Compose"},{"inline":false,"label":"Standards","permalink":"/blog/tags/standards","description":"Standards in Compose"}],"readingTime":2.85,"hasTruncateMarker":true,"authors":[{"name":"Nick Mudge","title":"Maintainer @ Compose","socials":{"x":"https://x.com/mudgen","linkedin":"https://www.linkedin.com/in/mudge/","github":"https://github.com/mudgen"},"imageURL":"https://github.com/mudgen.png","key":"mudgen","page":null}],"frontMatter":{"slug":"introducing-erc-8109-diamonds","title":"Introducing ERC-8109 Diamonds, a Standard for Simpler Diamond Contracts","authors":["mudgen"],"tags":["architecture","standards"]},"unlisted":false,"nextItem":{"title":"Diamond Architecture Metaphors","permalink":"/blog/diamond-architecture-metaphors"}}')}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.