---
eip: 8049
label: ERC-8049
title: Contract-Level Onchain Metadata
status: Draft
type: Standards Track
category: ERC
created: 2025-10-10
requires: 20, 165, 7930
official: https://eips.ethereum.org/EIPS/eip-8049
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-8049.md
canonical: https://eips.huatuo.xyz/ko/eip-8049/
lang: ko
tldr: 어떤 컨트랙트든 자기 자신(이름, 설명, ENS 이름, AI 에이전트 엔드포인트)을 설명하는 데 쓸 수 있는 최소한의 온체인 key-value 저장소. `contractMetadata(key)`로 읽고 표준 이벤트로 변경을 추적한다.
tags: [metadata, onchain, interface, ai-agents, contracts]
---

# ERC-8049: Contract-Level Onchain Metadata

> Onchain metadata for arbitrary contracts with optional Diamond Storage for predictable data storage locations.

**TL;DR:** 어떤 컨트랙트든 자기 자신(이름, 설명, ENS 이름, AI 에이전트 엔드포인트)을 설명하는 데 쓸 수 있는 최소한의 온체인 key-value 저장소. `contractMetadata(key)`로 읽고 표준 이벤트로 변경을 추적한다.

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

컨트랙트 *자체에 대한* 정보, 예를 들어 이름, 설명, 프로젝트 링크는 보통 오프체인에 있습니다. URL 뒤나 IPFS에 있는 JSON 파일입니다. 서버는 다운되고, 도메인은 만료되며, 내용은 온체인 기록 없이 바뀔 수 있습니다. 그러면 지갑과 익스플로러는 아무것도 보여 주지 못하거나 중앙화된 데이터베이스에 의존하게 됩니다.

ERC-8049는 컨트랙트가 자신에 대한 메타데이터를 단순한 key-value 레코드로 체인에 직접 저장하게 해서, 클라이언트가 검증 가능한 정보를 컨트랙트에서 바로 읽을 수 있게 합니다.

## 어떻게 동작하나요?

- **읽기:** `contractMetadata(string key) returns (bytes)`. key는 문자열이고 값은 임의의 bytes입니다.
- **이벤트:** 모든 업데이트는 `ContractMetadataUpdated(string indexed indexedKey, string key, bytes value)`를 emit해야 하며, 감사 추적이 되고 인덱서가 key로 필터링할 수 있습니다.
- **쓰기(선택):** `setContractMetadata(key, value)`. 누가 호출할 수 있는지는 컨트랙트에 달려 있습니다.
- **인터페이스 ID:** [ERC-165](/eip-165/) 탐지용 `0x8ec3f882`.
- **값 해석:** 달리 지정된 것이 없으면 클라이언트는 값을 UTF-8 문자열로 취급해도 됩니다. 예: `"name"` → `bytes("MyToken")`, `"ens_name"` → `bytes("mycontract.eth")`.
- **선택적 Diamond Storage:** 컨트랙트는 mapping을 네임스페이스 `"erc8049.contract.metadata.storage"`([ERC-8042](/eip-8042/))에 둘 수 있어, 업그레이드 가능한 컨트랙트와 크로스체인 스토리지 증명을 위한 예측 가능한 스토리지 슬롯이 생깁니다.
- **선택적 훅:** [ERC-8121](/eip-8121/)을 통해 조회를 다른 컨트랙트로 리디렉션할 수 있습니다.

**AI 에이전트 프로필("ERC-20Agent").** 사양은 [ERC-20](/eip-20/) 토큰 컨트랙트를 AI 에이전트 하나에 연결하는 key를 예약해 둡니다. `context`(Markdown 텍스트), 소문자 타입 `mcp`, `a2a`, `web`, `x402`를 쓰는 `endpoint[<type>]`, 에이전트의 주 계정을 나타내는 `address[<chain-id>]`, 선택적인 `account[<chain-id>][<index>]`입니다. `<chain-id>`는 [ERC-7930](/eip-7930/) 체인 식별자이며, 예를 들어 이더리움 메인넷은 `0x00010000010100`입니다. 새 함수나 인터페이스 ID는 추가되지 않으며 key에 대한 관례일 뿐입니다.

## 샘플 코드

소유자만 쓸 수 있는 기본 구현:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;

contract ContractMetadata {
    event ContractMetadataUpdated(string indexed indexedKey, string key, bytes value);

    address public immutable owner = msg.sender;
    mapping(string => bytes) private _metadata;

    function contractMetadata(string calldata key) external view returns (bytes memory) {
        return _metadata[key];
    }

    function setContractMetadata(string calldata key, bytes calldata value) external {
        require(msg.sender == owner, "not owner");
        _metadata[key] = value;
        emit ContractMetadataUpdated(key, key, value);
    }
}
```

읽기(ethers v6):

```ts
const c = new Contract(addr, ["function contractMetadata(string) view returns (bytes)"], provider);
const name = toUtf8String(await c.contractMetadata("name"));
```

## 알아둘 점

- **상태: Draft.** 다른 초안(ERC-8119의 key 파라미터, ERC-8121의 훅)을 참조하므로 세부 내용이 바뀔 수 있습니다.
- 값은 컨트랙트 소유자가 쓴 그대로입니다. 클라이언트는 특히 에이전트의 `context`와 엔드포인트를 신뢰할 수 없는 입력으로 다뤄야 합니다.
- key는 대소문자를 구분하는 정확한 문자열입니다. `endpoint[mcp]`와 `endpoint[MCP]`는 서로 다른 key입니다.
- 큰 값을 체인에 저장하면 비용이 많이 듭니다. 레코드는 짧게 유지하거나, 적절한 경우 해시와 포인터를 저장하세요.


---

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