---
eip: 8153
label: ERC-8153
title: Facet-Based Diamonds
status: Final
type: Standards Track
category: ERC
created: 2026-02-07
requires: 2535
official: https://eips.ethereum.org/EIPS/eip-8153
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8153.md
canonical: https://eips.huatuo.xyz/eip-8153/
lang: en
tldr: Diamond proxies where each facet reports its own function selectors via exportSelectors(), so deploys and upgrades operate on whole facets and need no off-chain selector plumbing.
tags: [diamond, proxy, upgradeability, facets]
---

# ERC-8153: Facet-Based Diamonds

> Simplifies diamond management, deployment and upgrades.

**TL;DR:** Diamond proxies where each facet reports its own function selectors via exportSelectors(), so deploys and upgrades operate on whole facets and need no off-chain selector plumbing.

## What problem does it solve?

A **diamond** ([ERC-2535](/eip-2535/)) is one contract address that routes each call by its 4-byte selector to one of many implementation contracts (**facets**) using `delegatecall`. It lets large systems be split into modules while appearing as a single contract.

In practice, deploying or upgrading a diamond meant gathering every function selector off-chain with custom scripts, because Hardhat and Foundry do not manage diamond selectors natively. Passing long selector arrays in calldata and storing them one by one also cost gas.

ERC-8153 moves selector discovery on-chain: every facet describes itself, and the diamond reads that description when it adds, replaces or removes the facet.

## How it works

- **`exportSelectors()` on every facet.** A `pure` function returning a packed `bytes` value whose length is a multiple of 4; each 4-byte chunk is a selector the facet wants added. No duplicates. `bytes` is used instead of `bytes4[]` to avoid wasting memory.
- **Facet-based events.** The diamond emits `FacetAdded`, `FacetReplaced(old, new)` and `FacetRemoved`. Tools call `exportSelectors()` on the referenced facet to learn which selectors changed. These replace ERC-2535's `DiamondCut` event.
- **Same introspection as ERC-2535.** `facets()`, `facetFunctionSelectors()`, `facetAddresses()` and `facetAddress()` are still required, so existing diamond tooling that reads them keeps working.
- **Fallback routing** is unchanged: look up `msg.sig`, `delegatecall` the facet, revert with `FunctionNotFound(bytes4)` if nothing handles it.
- **Optional `upgradeDiamond`.** Takes arrays of facets to add, `(oldFacet, newFacet)` pairs to replace, and facets to remove, applied in that order, plus an optional `delegatecall` for initialization or migration and optional metadata. Replacing a facet diffs the old and new selector lists: new ones are added, shared ones repointed, missing ones removed. It must revert with specific errors for mistakes such as adding an existing selector, replacing a facet with itself, or a facet with no bytecode or no selectors.

Because only facet addresses are passed in, a constructor can simply take an array of facets and register them all on-chain.

## Sample code

A facet that exports its own selectors:

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

interface IFacet {
    function exportSelectors() external pure returns (bytes memory selectors);
}

contract CounterFacet is IFacet {
    bytes32 constant SLOT = keccak256("example.counter.storage");

    function increment() external {
        bytes32 s = SLOT;
        assembly { sstore(s, add(sload(s), 1)) }
    }

    function count() external view returns (uint256 c) {
        bytes32 s = SLOT;
        assembly { c := sload(s) }
    }

    function exportSelectors() external pure returns (bytes memory) {
        return bytes.concat(this.increment.selector, this.count.selector);
    }
}
```

Upgrading through the optional function (ethers v6):

```ts
import { Contract, ZeroAddress, encodeBytes32String } from "ethers";

const diamond = new Contract(diamondAddress, [
  "function upgradeDiamond(address[] addFacets, tuple(address oldFacet, address newFacet)[] replaceFacets, address[] removeFacets, address delegate, bytes delegateCalldata, bytes32 tag, bytes metadata)",
], signer);

await diamond.upgradeDiamond(
  [],                                   // add
  [{ oldFacet: counterV1, newFacet: counterV2 }], // replace
  [],                                   // remove
  ZeroAddress, "0x",                    // no init delegatecall
  encodeBytes32String("v2"), "0x",      // release tag
);
```

## Things to know

- **Status: Final.** It supersedes the withdrawn [ERC-8109](/eip-8109/).
- It breaks compatibility with ERC-2535 events and upgrade functions, and ERC-2535 facets without `exportSelectors()` cannot be reused as-is.
- `exportSelectors()` must be `pure` and should never change; facets should be immutable, otherwise an upgrade can add or remove the wrong selectors.
- `upgradeDiamond` can run arbitrary code with access to the diamond's storage. Restrict who can call it, and only add trusted, verified facets. Avoid `selfdestruct` in facets.
- Storage layout is your choice; [ERC-8042](/eip-8042/) and [ERC-7201](/eip-7201/) are the patterns the spec cites.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-8153
