{"eip":7508,"title":"Dynamic On-Chain Token Attributes Repository","description":"Dynamic on-chain storage of token attributes in a public-good repository.","authors":["Steven Pineda (@steven2308)","Jan Turk (@ThunderDeliverer)"],"status":"Draft","type":"Standards Track","category":"ERC","created":"2023-08-15","requires":[165],"discussionsTo":"https://ethereum-magicians.org/t/dynamic-on-chain-token-attributes-repository/15667","repo":"ERCs","label":"ERC-7508","officialUrl":"https://eips.ethereum.org/EIPS/eip-7508","sourceUrl":"https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7508.md","url":"https://eips.huatuo.xyz/eip-7508/","tldr":{"en":"A shared on-chain repository where any ERC-721 or ERC-1155 collection, including existing ones, can store typed per-token attributes that other contracts can read directly.","ja":"あらゆる ERC-721 / ERC-1155 コレクション（既存のものを含む）が、型付きのトークン単位の属性を保存でき、他のコントラクトが直接読み取れる、共有のオンチェーンリポジトリ。","ko":"기존 컬렉션을 포함한 모든 ERC-721 또는 ERC-1155 컬렉션이 토큰별 타입 지정 속성을 저장하고, 다른 컨트랙트가 직접 읽을 수 있는 공유 온체인 저장소.","zh":"一个共享的链上仓库，任何 ERC-721 或 ERC-1155 合集（包括已有的）都可以在其中存储带类型的逐代币属性，其他合约可以直接读取。"},"tags":["nft","attributes","metadata","on-chain","repository"],"explainers":{"en":{"lang":"en","tldr":"A shared on-chain repository where any ERC-721 or ERC-1155 collection, including existing ones, can store typed per-token attributes that other contracts can read directly.","tags":["nft","attributes","metadata","on-chain","repository"],"related":[721,1155,7401,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-7508/","markdown":"## What problem does it solve?\n\nMost NFT attributes (\"strength: 12\", \"rarity: gold\") live in off-chain JSON. Smart contracts cannot read them, so a game cannot trust a character's stats without an oracle, and if the hosting disappears the attributes disappear too.\n\nERC-7508 proposes a single, permissionless **attributes repository** contract that any [ERC-721](/eip-721/) or [ERC-1155](/eip-1155/) collection can use. Because it is a separate common-good contract rather than an extension, even collections deployed long before it can start storing attributes on-chain. Use cases in the spec include cross-collection games, tokens that evolve as their owners act, and supply-chain items whose state moves from \"pending\" to \"shipped\" to \"delivered\".\n\n## How it works\n\n- **Typed key/value storage.** Attributes are stored per `(collection, tokenId, key)` in six types: `address`, `bool`, `bytes`, `int256`, `string` and `uint256`. Each has a getter and setter (`getUintAttribute`, `setStringAttribute`, …), plus batch variants and a combined `getAttributes`/`setAttributes`.\n- **Collection-wide values.** Using `tokenId = type(uint256).max` stores attributes shared by the whole collection.\n- **Access control per key.** A collection is first registered with `registerAccessControl` (owner either read from `Ownable` or set manually). The owner then chooses, per key, who may write: `Owner`, `Collaborator`, `OwnerOrCollaborator`, `TokenOwner` or a `SpecificAddress`.\n- **Presigned writes.** An authorised setter can sign an attribute update off-chain (with a deadline and a chain-specific `DOMAIN_SEPARATOR`) and anyone can submit it via `presignedSet…Attribute`.\n- **Schema.** Collections can publish a metadata URI describing their attributes (name, type, display hints, min/max…), set with `setAttributesMetadataURIForCollection`.\n- **Gas.** Strings for keys and values are stored once and referenced by index, so later users of the same string pay less.\n\nEvery write emits a typed `…AttributeUpdated` event. The ERC-165 interface ID is `0x212206a8`.\n\n## Sample code\n\nA game contract reading and updating a character's level in the repository:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.21;\n\ninterface IERC7508Min {\n    function getUintAttribute(address collection, uint256 tokenId, string memory key)\n        external view returns (uint256);\n    function setUintAttribute(address collection, uint256 tokenId, string memory key, uint256 value)\n        external;\n}\n\ncontract Arena {\n    IERC7508Min public immutable repo;\n    address public immutable heroes;\n\n    constructor(IERC7508Min _repo, address _heroes) { repo = _repo; heroes = _heroes; }\n\n    // Requires the collection owner to have granted this contract write access\n    // to the \"level\" key (e.g. as a Collaborator or SpecificAddress).\n    function win(uint256 heroId) external {\n        uint256 level = repo.getUintAttribute(heroes, heroId, \"level\");\n        repo.setUintAttribute(heroes, heroId, \"level\", level + 1);\n    }\n}\n```\n\n## Things to know\n\n- Status is **Draft**. The interface may still change.\n- The spec intends one deployment at the same address on every chain (starting `0xA77B75`), but the final address is listed as TBD. Do not hard-code one from unofficial sources.\n- The repository does not check that a token exists, except where the `TokenOwner` access type requires an owner lookup.\n- A presigned message can be replayed until its deadline. Keep deadlines short if your logic expects attributes to change back later.\n- It comes from the same authors as nestable NFTs ([ERC-7401](/eip-7401/)) and can be combined with them.\n"},"ja":{"lang":"ja","tldr":"あらゆる ERC-721 / ERC-1155 コレクション（既存のものを含む）が、型付きのトークン単位の属性を保存でき、他のコントラクトが直接読み取れる、共有のオンチェーンリポジトリ。","tags":["nft","attributes","metadata","on-chain","repository"],"related":[721,1155,7401,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-7508/","markdown":"## 何を解決するのか\n\nNFT の属性（「strength: 12」「rarity: gold」など）の多くは、オフチェーンの JSON にあります。スマートコントラクトはそれを読めないため、ゲームはオラクルなしにキャラクターのステータスを信頼できず、ホスティングが消えれば属性も消えてしまいます。\n\nERC-7508 は、あらゆる [ERC-721](/eip-721/) または [ERC-1155](/eip-1155/) コレクションが使える、単一でパーミッションレスな**属性リポジトリ**コントラクトを提案します。拡張ではなく独立した公共財コントラクトなので、ずっと前にデプロイされたコレクションでも属性のオンチェーン保存を始められます。仕様に挙げられているユースケースには、コレクションをまたぐゲーム、所有者の行動に応じて進化するトークン、状態が「pending」から「shipped」、「delivered」へと移るサプライチェーンのアイテムなどがあります。\n\n## 仕組み\n\n- **型付きのキー／値ストレージ。** 属性は `(collection, tokenId, key)` ごとに保存され、型は `address`、`bool`、`bytes`、`int256`、`string`、`uint256` の 6 種類です。それぞれにゲッターとセッター（`getUintAttribute`、`setStringAttribute` など）があり、バッチ版と、まとめて扱う `getAttributes` / `setAttributes` もあります。\n- **コレクション全体の値。** `tokenId = type(uint256).max` を使うと、コレクション全体で共有される属性を保存できます。\n- **キーごとのアクセス制御。** まずコレクションを `registerAccessControl` で登録します（所有者は `Ownable` から読み取るか、手動で設定）。その後、所有者がキーごとに書き込める者を選びます。`Owner`、`Collaborator`、`OwnerOrCollaborator`、`TokenOwner`、`SpecificAddress` のいずれかです。\n- **事前署名による書き込み。** 権限のある設定者は、属性の更新をオフチェーンで（期限とチェーン固有の `DOMAIN_SEPARATOR` 付きで）署名でき、誰でも `presignedSet…Attribute` でそれを送信できます。\n- **スキーマ。** コレクションは、属性（名前、型、表示のヒント、最小／最大など）を記述するメタデータ URI を公開でき、`setAttributesMetadataURIForCollection` で設定します。\n- **ガス。** キーと値の文字列は一度だけ保存されてインデックスで参照されるため、同じ文字列を後から使う人のコストは下がります。\n\n書き込みのたびに、型付きの `…AttributeUpdated` イベントが emit されます。ERC-165 のインターフェース ID は `0x212206a8` です。\n\n## サンプルコード\n\nリポジトリ内のキャラクターのレベルを読み取り、更新するゲームコントラクト:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.21;\n\ninterface IERC7508Min {\n    function getUintAttribute(address collection, uint256 tokenId, string memory key)\n        external view returns (uint256);\n    function setUintAttribute(address collection, uint256 tokenId, string memory key, uint256 value)\n        external;\n}\n\ncontract Arena {\n    IERC7508Min public immutable repo;\n    address public immutable heroes;\n\n    constructor(IERC7508Min _repo, address _heroes) { repo = _repo; heroes = _heroes; }\n\n    // Requires the collection owner to have granted this contract write access\n    // to the \"level\" key (e.g. as a Collaborator or SpecificAddress).\n    function win(uint256 heroId) external {\n        uint256 level = repo.getUintAttribute(heroes, heroId, \"level\");\n        repo.setUintAttribute(heroes, heroId, \"level\", level + 1);\n    }\n}\n```\n\n## 知っておくべきこと\n\n- ステータスは **Draft** です。インターフェースはまだ変わる可能性があります。\n- 仕様は、すべてのチェーンで同じアドレス（`0xA77B75` で始まる）に 1 つデプロイすることを意図していますが、最終的なアドレスは TBD とされています。非公式な情報源から得たアドレスをハードコードしないでください。\n- `TokenOwner` アクセスタイプが所有者の照会を必要とする場合を除き、リポジトリはトークンが存在するかを確認しません。\n- 事前署名されたメッセージは、期限までリプレイされる可能性があります。属性が後で元に戻ることをロジックが想定している場合は、期限を短くしてください。\n- ネスト可能な NFT（[ERC-7401](/eip-7401/)）と同じ作者によるもので、組み合わせて使えます。\n"},"ko":{"lang":"ko","tldr":"기존 컬렉션을 포함한 모든 ERC-721 또는 ERC-1155 컬렉션이 토큰별 타입 지정 속성을 저장하고, 다른 컨트랙트가 직접 읽을 수 있는 공유 온체인 저장소.","tags":["nft","attributes","metadata","on-chain","repository"],"related":[721,1155,7401,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-7508/","markdown":"## 어떤 문제를 해결하나요?\n\n대부분의 NFT 속성(\"strength: 12\", \"rarity: gold\")은 오프체인 JSON에 있습니다. 스마트 컨트랙트는 이를 읽을 수 없으므로 게임은 오라클 없이는 캐릭터 스탯을 신뢰할 수 없고, 호스팅이 사라지면 속성도 함께 사라집니다.\n\nERC-7508은 모든 [ERC-721](/eip-721/) 또는 [ERC-1155](/eip-1155/) 컬렉션이 쓸 수 있는 하나의 퍼미션리스 **속성 저장소(attributes repository)** 컨트랙트를 제안합니다. 확장이 아니라 별도의 공공재 컨트랙트이기 때문에, 훨씬 전에 배포된 컬렉션도 속성을 온체인에 저장하기 시작할 수 있습니다. 사양에 나오는 사용 사례로는 컬렉션 간 게임, 소유자의 행동에 따라 진화하는 토큰, 상태가 \"pending\"에서 \"shipped\", \"delivered\"로 바뀌는 공급망 아이템이 있습니다.\n\n## 어떻게 동작하나요?\n\n- **타입 지정 키/값 저장.** 속성은 `(collection, tokenId, key)`별로 저장되며 `address`, `bool`, `bytes`, `int256`, `string`, `uint256` 여섯 가지 타입이 있습니다. 각각 getter와 setter(`getUintAttribute`, `setStringAttribute` 등)가 있고, 배치 변형과 통합된 `getAttributes`/`setAttributes`도 있습니다.\n- **컬렉션 전체 값.** `tokenId = type(uint256).max`를 사용하면 컬렉션 전체가 공유하는 속성을 저장합니다.\n- **키별 접근 제어.** 컬렉션은 먼저 `registerAccessControl`로 등록합니다(소유자는 `Ownable`에서 읽거나 수동으로 설정). 이후 소유자가 키마다 누가 쓸 수 있는지 고릅니다. `Owner`, `Collaborator`, `OwnerOrCollaborator`, `TokenOwner`, `SpecificAddress` 중 하나입니다.\n- **사전 서명 쓰기.** 권한 있는 설정자는 속성 업데이트를 오프체인에서(마감 시한과 체인별 `DOMAIN_SEPARATOR` 포함) 서명할 수 있고, 누구나 `presignedSet…Attribute`로 제출할 수 있습니다.\n- **스키마.** 컬렉션은 속성(이름, 타입, 표시 힌트, 최소/최대 등)을 설명하는 메타데이터 URI를 게시할 수 있으며 `setAttributesMetadataURIForCollection`으로 설정합니다.\n- **가스.** 키와 값 문자열은 한 번만 저장되고 인덱스로 참조되므로, 같은 문자열을 나중에 쓰는 사용자는 비용이 줄어듭니다.\n\n모든 쓰기는 타입별 `…AttributeUpdated` 이벤트를 emit합니다. ERC-165 인터페이스 ID는 `0x212206a8`입니다.\n\n## 샘플 코드\n\n저장소에서 캐릭터의 레벨을 읽고 업데이트하는 게임 컨트랙트:\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.21;\n\ninterface IERC7508Min {\n    function getUintAttribute(address collection, uint256 tokenId, string memory key)\n        external view returns (uint256);\n    function setUintAttribute(address collection, uint256 tokenId, string memory key, uint256 value)\n        external;\n}\n\ncontract Arena {\n    IERC7508Min public immutable repo;\n    address public immutable heroes;\n\n    constructor(IERC7508Min _repo, address _heroes) { repo = _repo; heroes = _heroes; }\n\n    // Requires the collection owner to have granted this contract write access\n    // to the \"level\" key (e.g. as a Collaborator or SpecificAddress).\n    function win(uint256 heroId) external {\n        uint256 level = repo.getUintAttribute(heroes, heroId, \"level\");\n        repo.setUintAttribute(heroes, heroId, \"level\", level + 1);\n    }\n}\n```\n\n## 알아둘 점\n\n- 상태는 **Draft**입니다. 인터페이스는 아직 바뀔 수 있습니다.\n- 사양은 모든 체인에서 같은 주소(`0xA77B75`로 시작)에 하나를 배포하는 것을 의도하지만 최종 주소는 TBD로 표기되어 있습니다. 비공식 출처의 주소를 하드코딩하지 마세요.\n- `TokenOwner` 접근 유형이 소유자 조회를 필요로 하는 경우를 제외하면, 저장소는 토큰이 존재하는지 확인하지 않습니다.\n- 사전 서명된 메시지는 마감 시한까지 리플레이될 수 있습니다. 로직이 속성이 나중에 원래대로 돌아갈 것을 기대한다면 마감 시한을 짧게 두세요.\n- 중첩 가능 NFT([ERC-7401](/eip-7401/))와 같은 저자들이 만들었으며 함께 조합해 쓸 수 있습니다.\n"},"zh":{"lang":"zh","tldr":"一个共享的链上仓库，任何 ERC-721 或 ERC-1155 合集（包括已有的）都可以在其中存储带类型的逐代币属性，其他合约可以直接读取。","tags":["nft","attributes","metadata","on-chain","repository"],"related":[721,1155,7401,165],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-7508/","markdown":"## 它解决什么问题？\n\n大多数 NFT 属性（\"strength: 12\"、\"rarity: gold\"）都存放在链下的 JSON 中。智能合约读不到它们，因此游戏离开预言机就无法信任角色的数值，而且一旦托管消失，属性也随之消失。\n\nERC-7508 提出一个单一的、无需许可的**属性仓库（attributes repository）**合约，任何 [ERC-721](/eip-721/) 或 [ERC-1155](/eip-1155/) 合集都可以使用。由于它是独立的公共物品合约而不是扩展，即使是早在它出现之前部署的合集，也可以开始在链上存储属性。规范中列出的用例包括跨合集游戏、随所有者行为而演化的代币，以及状态从\"pending\"变为\"shipped\"再到\"delivered\"的供应链物品。\n\n## 它如何运作\n\n- **带类型的键/值存储。** 属性按 `(collection, tokenId, key)` 存储，有六种类型：`address`、`bool`、`bytes`、`int256`、`string` 和 `uint256`。每种类型都有 getter 和 setter（`getUintAttribute`、`setStringAttribute` 等），还有批量版本以及组合的 `getAttributes`/`setAttributes`。\n- **合集级的值。** 使用 `tokenId = type(uint256).max` 可以存储整个合集共享的属性。\n- **按键的访问控制。** 合集首先通过 `registerAccessControl` 注册（所有者可从 `Ownable` 读取，或手动设置）。然后所有者针对每个键选择谁可以写入：`Owner`、`Collaborator`、`OwnerOrCollaborator`、`TokenOwner` 或 `SpecificAddress`。\n- **预签名写入。** 有权限的设置者可以在链下签署属性更新（带有截止时间和特定于链的 `DOMAIN_SEPARATOR`），任何人都可以通过 `presignedSet…Attribute` 提交。\n- **模式（Schema）。** 合集可以发布一个描述其属性的元数据 URI（名称、类型、显示提示、最小/最大值等），通过 `setAttributesMetadataURIForCollection` 设置。\n- **Gas。** 键和值的字符串只存储一次并通过索引引用，因此之后使用相同字符串的人支付更少。\n\n每次写入都会触发带类型的 `…AttributeUpdated` 事件。ERC-165 接口 ID 为 `0x212206a8`。\n\n## 示例代码\n\n一个在仓库中读取并更新角色等级的游戏合约：\n\n```solidity\n// SPDX-License-Identifier: CC0-1.0\npragma solidity ^0.8.21;\n\ninterface IERC7508Min {\n    function getUintAttribute(address collection, uint256 tokenId, string memory key)\n        external view returns (uint256);\n    function setUintAttribute(address collection, uint256 tokenId, string memory key, uint256 value)\n        external;\n}\n\ncontract Arena {\n    IERC7508Min public immutable repo;\n    address public immutable heroes;\n\n    constructor(IERC7508Min _repo, address _heroes) { repo = _repo; heroes = _heroes; }\n\n    // Requires the collection owner to have granted this contract write access\n    // to the \"level\" key (e.g. as a Collaborator or SpecificAddress).\n    function win(uint256 heroId) external {\n        uint256 level = repo.getUintAttribute(heroes, heroId, \"level\");\n        repo.setUintAttribute(heroes, heroId, \"level\", level + 1);\n    }\n}\n```\n\n## 需要注意\n\n- 状态为 **Draft**。接口仍可能变化。\n- 规范希望在每条链上的同一地址（以 `0xA77B75` 开头）部署一份，但最终地址标注为 TBD。不要硬编码来自非官方来源的地址。\n- 除非 `TokenOwner` 访问类型需要查询所有者，否则仓库不会检查代币是否存在。\n- 预签名消息在截止时间之前可以被重放。如果你的逻辑预期属性之后会改回去，请把截止时间设得短一些。\n- 它与可嵌套 NFT（[ERC-7401](/eip-7401/)）出自同一批作者，可以与之组合使用。\n"}}}
