EIPs Explained

ERC-8109 · Withdrawn · ERC · 2025-12-21

ERC-8109: Diamonds, Simplified

A withdrawn attempt to simplify ERC-2535 Diamonds with per-function events and just two introspection functions; it was superseded by ERC-8153.

What problem does it solve?

A diamond is a proxy contract that delegatecalls to many implementation contracts, called facets, behind one address. Because the diamond's functions are decided at runtime by a selector-to-facet table rather than by its own bytecode, block explorers and tools need standard functions and events to discover what a diamond can do.

ERC-2535 standardized that, but with several introspection functions and a single large DiamondCut event that is awkward to emit and to index. ERC-8109 tried to keep everything diamonds can do while making them easier to implement and to read.

How it works

  • Fallback routing. Any call hits the diamond's fallback(), which looks up the facet for msg.sig and delegatecalls it. Storage, msg.sender and msg.value stay the diamond's. If no facet (or default handler) exists, it must revert with FunctionNotFound(bytes4).
  • Per-function events (required). Every change emits one event per selector: DiamondFunctionAdded, DiamondFunctionReplaced or DiamondFunctionRemoved. Indexers can rebuild the full upgrade history from these.
  • Two introspection functions (required). facetAddress(bytes4) and functionFacetPairs(), which returns the whole selector-to-facet mapping as (selector, facet) pairs. It is meant to be called off-chain.
  • Optional events. DiamondDelegateCall records non-routing delegatecalls (for example, init or migration code), and DiamondMetadata records arbitrary tags such as a release version.
  • No upgrade function is specified. A diamond can be built entirely in its constructor and be immutable, or define its own upgrade function as long as it emits the events above.
  • Immutable functions defined directly in the diamond must still be reported by introspection, with the diamond's own address as the facet, and must not be replaceable.

Existing ERC-2535 diamonds could migrate by swapping in a new upgrade function, adding functionFacetPairs(), and emitting DiamondFunctionAdded for every current function as a "snapshot".

Sample code

The required interface:

// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.20;

interface IDiamond8109 {
    error FunctionNotFound(bytes4 _selector);

    event DiamondFunctionAdded(bytes4 indexed _selector, address indexed _facet);
    event DiamondFunctionReplaced(bytes4 indexed _selector, address indexed _oldFacet, address indexed _newFacet);
    event DiamondFunctionRemoved(bytes4 indexed _selector, address indexed _oldFacet);

    struct FunctionFacetPair {
        bytes4 selector;
        address facet;
    }

    function facetAddress(bytes4 _functionSelector) external view returns (address);
    function functionFacetPairs() external view returns (FunctionFacetPair[] memory pairs);
}

Listing a diamond's functions off-chain (ethers v6):

import { Contract, JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const diamond = new Contract(diamondAddress, [
  "function functionFacetPairs() view returns (tuple(bytes4 selector, address facet)[])",
], provider);

for (const { selector, facet } of await diamond.functionFacetPairs()) {
  console.log(selector, "->", facet);
}

Things to know

  • Status: Withdrawn. The author withdrew it as superseded by ERC-8153 (Facet-Based Diamonds), which is the version to use for new work. ERC-8153 keeps ERC-2535's introspection functions and switches to facet-level events.
  • The storage layout pattern is out of scope; ERC-8042 Diamond Storage or ERC-7201 namespaced storage are the examples the spec points to.
  • Ownership and access control for upgrades are not part of the standard and must be designed carefully.
  • Two functions with the same signature cannot live in one diamond at the same time.

#diamond #proxy #upgradeability #facets #withdrawn

Details

Authors
Nick Mudge (@mudgen)
Status
Withdrawn
Type
Standards Track / ERC
Created
2025-12-21

Machine-readable: Markdown · JSON