---
eip: 7829
label: ERC-7829
title: Data Asset NFT
status: Review
type: Standards Track
category: ERC
created: 2024-11-29
requires: 165, 721
official: https://eips.ethereum.org/EIPS/eip-7829
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-7829.md
canonical: https://eips.huatuo.xyz/zh/eip-7829/
lang: zh
tldr: 一个用于将数字内容作为 NFT 出售的 ERC-721 扩展，为每个代币增加多个 Reader，并增加由存储证明支撑的链上存储元数据（承诺、大小、过期时间）。
tags: [nft, erc721, data, storage, access-control]
---

# ERC-7829: Data Asset NFT

> Bring Data Assets—online digital products—to NFTs and ensure their integrity through a storage proof.

**TL;DR:** 一个用于将数字内容作为 NFT 出售的 ERC-721 扩展，为每个代币增加多个 Reader，并增加由存储证明支撑的链上存储元数据（承诺、大小、过期时间）。

## 它解决什么问题？

NFT 通常只保存指向其内容的链接。合约无法得知该内容是否仍然存在、是否被篡改，或是否已在存储提供方处过期，因此在代币所代表的东西消失之后，代币仍可能继续交易。NFT 也大多适用于高价值的稀缺物品，而日常的数字产品（帖子、视频、小游戏、音乐）天然可复制，并出售给许多买家。

ERC-7829 面向这些“数据资产”。它把每个代币与存储元数据绑定，这些元数据由数据可用性（DA）层保持可证明的正确性，并允许一个代币向多个地址授予读取权限。

## 它如何运作

数据资产分为三部分：

- **存储元数据**（链上，位于存储合约中）：承诺、大小、过期时间和上传者。
- **权限元数据**（链上，位于 [ERC-721](/eip-721/) 合约中）：所有者、授权和 reader。
- **数据内容**（链下，位于存储节点上）。

代币合约实现 `IERC7829`：

| 函数 | 用途 |
| --- | --- |
| `setReader(tokenId, reader, valid)` | 授予或撤销读取权限；触发 `UpdateReader` |
| `isReader(tokenId, reader)` | 检查权限 |
| `commitByTokenId` / `sizeByTokenId` / `expireByTokenId` | 暴露存储元数据 |

reader 不能转让、授权，也不能添加其他 reader。转让会改变所有者并清除授权，但**保留所有 reader**。一旦 `block.timestamp` 超过代币的 `expire`，`transfer`、`approve` 和 `setReader` 必须失败。

为保证完整性，DA 提供方会定期提交存储证明。规范推荐使用带随机采样和聚合的 KZG 多项式承诺，并以乐观方式验证：聚合后的证明在链上检查，任何人都可以在一个窗口期内对其发起挑战，挑战者和证明者各有奖励和惩罚。

## 示例代码

基于 OpenZeppelin `ERC721` 的最小 reader 逻辑：

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

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract DataAssetNFT is ERC721 {
    event UpdateReader(uint256 indexed tokenId, address indexed reader, bool valid);

    struct Meta { bytes commit; uint256 size; uint64 expire; }
    mapping(uint256 => Meta) public meta;
    mapping(uint256 => mapping(address => bool)) private _readers;

    constructor() ERC721("Data Asset", "DATA") {}

    modifier notExpired(uint256 id) {
        require(block.timestamp <= meta[id].expire, "expired");
        _;
    }

    function setReader(uint256 id, address reader, bool valid) external notExpired(id) {
        require(_isAuthorized(ownerOf(id), msg.sender, id), "not owner/approved");
        _readers[id][reader] = valid;
        emit UpdateReader(id, reader, valid);
    }

    function isReader(uint256 id, address reader) external view returns (bool) {
        return _readers[id][reader];
    }

    function commitByTokenId(uint256 id) external view returns (bytes memory) { return meta[id].commit; }
    function sizeByTokenId(uint256 id) external view returns (uint256) { return meta[id].size; }
    function expireByTokenId(uint256 id) external view returns (uint64) { return meta[id].expire; }
}
```

## 需要注意

- 状态：**Review**。
- “Reader”是一个链上的权限标志。真正对链下内容进行访问控制（解密密钥、网关检查）取决于存储系统。
- 安全性在很大程度上取决于所选的 DA 层和存储节点；该 ERC 把这一选择留给实现者。
- KZG 和欺诈证明流程只是高层描述，并不是固定的合约接口。
- 对于 NFT 上有时间限制的“用户”权限，可对比 [ERC-4907](/eip-4907/)（租赁），它为每个代币只设一个 user。


---

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