---
eip: 7508
label: ERC-7508
title: Dynamic On-Chain Token Attributes Repository
status: Draft
type: Standards Track
category: ERC
created: 2023-08-15
requires: 165
official: https://eips.ethereum.org/EIPS/eip-7508
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7508.md
canonical: https://eips.huatuo.xyz/ko/eip-7508/
lang: ko
tldr: 기존 컬렉션을 포함한 모든 ERC-721 또는 ERC-1155 컬렉션이 토큰별 타입 지정 속성을 저장하고, 다른 컨트랙트가 직접 읽을 수 있는 공유 온체인 저장소.
tags: [nft, attributes, metadata, on-chain, repository]
---

# ERC-7508: Dynamic On-Chain Token Attributes Repository

> Dynamic on-chain storage of token attributes in a public-good repository.

**TL;DR:** 기존 컬렉션을 포함한 모든 ERC-721 또는 ERC-1155 컬렉션이 토큰별 타입 지정 속성을 저장하고, 다른 컨트랙트가 직접 읽을 수 있는 공유 온체인 저장소.

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

대부분의 NFT 속성("strength: 12", "rarity: gold")은 오프체인 JSON에 있습니다. 스마트 컨트랙트는 이를 읽을 수 없으므로 게임은 오라클 없이는 캐릭터 스탯을 신뢰할 수 없고, 호스팅이 사라지면 속성도 함께 사라집니다.

ERC-7508은 모든 [ERC-721](/eip-721/) 또는 [ERC-1155](/eip-1155/) 컬렉션이 쓸 수 있는 하나의 퍼미션리스 **속성 저장소(attributes repository)** 컨트랙트를 제안합니다. 확장이 아니라 별도의 공공재 컨트랙트이기 때문에, 훨씬 전에 배포된 컬렉션도 속성을 온체인에 저장하기 시작할 수 있습니다. 사양에 나오는 사용 사례로는 컬렉션 간 게임, 소유자의 행동에 따라 진화하는 토큰, 상태가 "pending"에서 "shipped", "delivered"로 바뀌는 공급망 아이템이 있습니다.

## 어떻게 동작하나요?

- **타입 지정 키/값 저장.** 속성은 `(collection, tokenId, key)`별로 저장되며 `address`, `bool`, `bytes`, `int256`, `string`, `uint256` 여섯 가지 타입이 있습니다. 각각 getter와 setter(`getUintAttribute`, `setStringAttribute` 등)가 있고, 배치 변형과 통합된 `getAttributes`/`setAttributes`도 있습니다.
- **컬렉션 전체 값.** `tokenId = type(uint256).max`를 사용하면 컬렉션 전체가 공유하는 속성을 저장합니다.
- **키별 접근 제어.** 컬렉션은 먼저 `registerAccessControl`로 등록합니다(소유자는 `Ownable`에서 읽거나 수동으로 설정). 이후 소유자가 키마다 누가 쓸 수 있는지 고릅니다. `Owner`, `Collaborator`, `OwnerOrCollaborator`, `TokenOwner`, `SpecificAddress` 중 하나입니다.
- **사전 서명 쓰기.** 권한 있는 설정자는 속성 업데이트를 오프체인에서(마감 시한과 체인별 `DOMAIN_SEPARATOR` 포함) 서명할 수 있고, 누구나 `presignedSet…Attribute`로 제출할 수 있습니다.
- **스키마.** 컬렉션은 속성(이름, 타입, 표시 힌트, 최소/최대 등)을 설명하는 메타데이터 URI를 게시할 수 있으며 `setAttributesMetadataURIForCollection`으로 설정합니다.
- **가스.** 키와 값 문자열은 한 번만 저장되고 인덱스로 참조되므로, 같은 문자열을 나중에 쓰는 사용자는 비용이 줄어듭니다.

모든 쓰기는 타입별 `…AttributeUpdated` 이벤트를 emit합니다. ERC-165 인터페이스 ID는 `0x212206a8`입니다.

## 샘플 코드

저장소에서 캐릭터의 레벨을 읽고 업데이트하는 게임 컨트랙트:

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

interface IERC7508Min {
    function getUintAttribute(address collection, uint256 tokenId, string memory key)
        external view returns (uint256);
    function setUintAttribute(address collection, uint256 tokenId, string memory key, uint256 value)
        external;
}

contract Arena {
    IERC7508Min public immutable repo;
    address public immutable heroes;

    constructor(IERC7508Min _repo, address _heroes) { repo = _repo; heroes = _heroes; }

    // Requires the collection owner to have granted this contract write access
    // to the "level" key (e.g. as a Collaborator or SpecificAddress).
    function win(uint256 heroId) external {
        uint256 level = repo.getUintAttribute(heroes, heroId, "level");
        repo.setUintAttribute(heroes, heroId, "level", level + 1);
    }
}
```

## 알아둘 점

- 상태는 **Draft**입니다. 인터페이스는 아직 바뀔 수 있습니다.
- 사양은 모든 체인에서 같은 주소(`0xA77B75`로 시작)에 하나를 배포하는 것을 의도하지만 최종 주소는 TBD로 표기되어 있습니다. 비공식 출처의 주소를 하드코딩하지 마세요.
- `TokenOwner` 접근 유형이 소유자 조회를 필요로 하는 경우를 제외하면, 저장소는 토큰이 존재하는지 확인하지 않습니다.
- 사전 서명된 메시지는 마감 시한까지 리플레이될 수 있습니다. 로직이 속성이 나중에 원래대로 돌아갈 것을 기대한다면 마감 시한을 짧게 두세요.
- 중첩 가능 NFT([ERC-7401](/eip-7401/))와 같은 저자들이 만들었으며 함께 조합해 쓸 수 있습니다.


---

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