---
eip: 8109
label: ERC-8109
title: Diamonds, Simplified
status: Withdrawn
type: Standards Track
category: ERC
created: 2025-12-21
official: https://eips.ethereum.org/EIPS/eip-8109
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8109.md
canonical: https://eips.huatuo.xyz/ko/eip-8109/
lang: ko
tldr: 함수별 이벤트와 단 두 개의 인트로스펙션 함수로 ERC-2535 Diamonds를 단순화하려던 시도. 철회되었으며 ERC-8153으로 대체되었다.
tags: [diamond, proxy, upgradeability, facets, withdrawn]
---

# ERC-8109: Diamonds, Simplified

> A simplified diamond architecture for modular smart contract systems.

**TL;DR:** 함수별 이벤트와 단 두 개의 인트로스펙션 함수로 ERC-2535 Diamonds를 단순화하려던 시도. 철회되었으며 ERC-8153으로 대체되었다.

## 어떤 문제를 해결하나요?

**다이아몬드**는 하나의 주소 뒤에서 **파셋(facet)**이라 불리는 여러 구현 컨트랙트로 `delegatecall`하는 프록시 컨트랙트입니다. 다이아몬드의 함수는 자체 바이트코드가 아니라 런타임의 셀렉터-파셋 테이블로 결정되므로, 블록 탐색기와 도구가 다이아몬드가 무엇을 할 수 있는지 알아내려면 표준 함수와 이벤트가 필요합니다.

[ERC-2535](/eip-2535/)가 이를 표준화했지만, 여러 개의 인트로스펙션 함수와 emit하기도 인덱싱하기도 번거로운 하나의 큰 `DiamondCut` 이벤트를 사용합니다. ERC-8109는 다이아몬드가 할 수 있는 모든 것을 유지하면서 구현하고 읽기 더 쉽게 만들려 했습니다.

## 어떻게 동작하나요?

- **폴백 라우팅.** 모든 호출은 다이아몬드의 `fallback()`에 도달하고, 이는 `msg.sig`에 해당하는 파셋을 찾아 `delegatecall`합니다. 스토리지, `msg.sender`, `msg.value`는 다이아몬드의 것으로 유지됩니다. 파셋(또는 기본 핸들러)이 없으면 `FunctionNotFound(bytes4)`로 revert해야 합니다.
- **함수별 이벤트(필수).** 모든 변경은 셀렉터마다 이벤트 하나(`DiamondFunctionAdded`, `DiamondFunctionReplaced`, `DiamondFunctionRemoved` 중 하나)를 emit합니다. 인덱서는 이를 바탕으로 전체 업그레이드 이력을 재구성할 수 있습니다.
- **두 개의 인트로스펙션 함수(필수).** `facetAddress(bytes4)`와 `functionFacetPairs()`입니다. 후자는 전체 셀렉터-파셋 매핑을 `(selector, facet)` 쌍으로 반환하며, 오프체인에서 호출하도록 만들어졌습니다.
- **선택적 이벤트.** `DiamondDelegateCall`은 라우팅이 아닌 `delegatecall`(예: 초기화나 마이그레이션 코드)을 기록하고, `DiamondMetadata`는 릴리스 버전 같은 임의의 태그를 기록합니다.
- **업그레이드 함수는 규정하지 않습니다.** 다이아몬드는 생성자에서 전부 구성하고 불변으로 만들 수도 있고, 위 이벤트를 emit하기만 하면 자체 업그레이드 함수를 정의할 수도 있습니다.
- 다이아몬드에 직접 정의된 **불변 함수**도 다이아몬드 자신의 주소를 파셋으로 하여 인트로스펙션으로 보고해야 하며, 교체할 수 있어서는 안 됩니다.

기존 ERC-2535 다이아몬드는 새 업그레이드 함수로 교체하고, `functionFacetPairs()`를 추가하고, 현재의 모든 함수에 대해 "스냅숏"으로 `DiamondFunctionAdded`를 emit하는 방식으로 마이그레이션할 수 있습니다.

## 샘플 코드

필수 인터페이스:

```solidity
// 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);
}
```

오프체인에서 다이아몬드의 함수 나열하기(ethers v6):

```ts
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);
}
```

## 알아둘 점

- **상태: Withdrawn.** [ERC-8153](/eip-8153/)(Facet-Based Diamonds)으로 대체되었다며 작성자가 철회했습니다. 새 작업에는 ERC-8153을 사용하세요. ERC-8153은 ERC-2535의 인트로스펙션 함수를 유지하고 파셋 단위 이벤트로 바꿉니다.
- 스토리지 레이아웃 패턴은 범위 밖입니다. 스펙이 예로 드는 것은 [ERC-8042](/eip-8042/) Diamond Storage와 [ERC-7201](/eip-7201/) 네임스페이스 스토리지입니다.
- 업그레이드의 소유권과 접근 제어는 표준에 포함되지 않으므로 신중하게 설계해야 합니다.
- 같은 시그니처를 가진 두 함수는 하나의 다이아몬드에 동시에 존재할 수 없습니다.


---

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