---
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/eip-8049/
lang: en
tldr: A minimal on-chain key-value store any contract can use to describe itself (name, description, ENS name, AI-agent endpoints), read with `contractMetadata(key)` and tracked through a standard event.
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:** A minimal on-chain key-value store any contract can use to describe itself (name, description, ENS name, AI-agent endpoints), read with `contractMetadata(key)` and tracked through a standard event.

## What problem does it solve?

Information *about* a contract, such as its name, description or project links, usually lives off-chain: a JSON file behind a URL or on IPFS. Servers go down, domains expire, and the content can change without any on-chain record. Wallets and explorers then either show nothing or depend on centralised databases.

ERC-8049 lets a contract store metadata about itself directly on chain, as simple key-value records, so clients can read verifiable information straight from the contract.

## How it works

- **Read:** `contractMetadata(string key) returns (bytes)`. Keys are strings, values are arbitrary bytes.
- **Event:** every update must emit `ContractMetadataUpdated(string indexed indexedKey, string key, bytes value)`, giving an audit trail and letting indexers filter by key.
- **Write (optional):** `setContractMetadata(key, value)`; who may call it is up to the contract.
- **Interface ID:** `0x8ec3f882` for [ERC-165](/eip-165/) detection.
- **Value interpretation:** if nothing else is specified, clients may treat a value as a UTF-8 string. Examples: `"name"` → `bytes("MyToken")`, `"ens_name"` → `bytes("mycontract.eth")`.
- **Optional Diamond Storage:** contracts may keep the mapping at the namespace `"erc8049.contract.metadata.storage"` ([ERC-8042](/eip-8042/)), giving a predictable storage slot for upgradeable contracts and cross-chain storage proofs.
- **Optional hooks:** resolution can be redirected to another contract via [ERC-8121](/eip-8121/).

**AI agent profile ("ERC-20Agent").** The spec reserves keys that tie an [ERC-20](/eip-20/) token contract to one AI agent: `context` (Markdown text), `endpoint[<type>]` with lowercase types `mcp`, `a2a`, `web`, `x402`, `address[<chain-id>]` for the agent's primary account, and optional `account[<chain-id>][<index>]`. `<chain-id>` is an [ERC-7930](/eip-7930/) chain identifier, e.g. `0x00010000010100` for Ethereum mainnet. No new functions or interface IDs are added; it is just a convention on keys.

## Sample code

A basic implementation with owner-only writes:

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

Reading it (ethers v6):

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

## Things to know

- **Status: Draft.** It references other drafts (ERC-8119 key parameters, ERC-8121 hooks), so details may shift.
- Values are whatever the contract owner writes. Clients should treat them, especially agent `context` and endpoints, as untrusted input.
- Keys are case-sensitive exact strings: `endpoint[mcp]` and `endpoint[MCP]` are different keys.
- Large values stored on chain are expensive; keep records short or store hashes and pointers where appropriate.


---

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