---
eip: 5625
label: ERC-5625
title: NFT Metadata JSON Schema dStorage Extension
status: Final
type: Standards Track
category: ERC
created: 2022-09-08
requires: 721, 1155
official: https://eips.ethereum.org/EIPS/eip-5625
source: https://github.com/ethereum/ERCs/blob/master/ERCS/erc-5625.md
canonical: https://eips.huatuo.xyz/zh/eip-5625/
lang: zh
tldr: 为 ERC-721 和 ERC-1155 元数据 JSON 增加一个可选的 dStorage 对象，记录哪个去中心化存储网络保存了 NFT 的资产，以及如何验证。
tags: [nft, metadata, storage, json]
---

# ERC-5625: NFT Metadata JSON Schema dStorage Extension

> Add a dStorage property to non-fungible tokens (NFTs) metadata JSON schema to provide decentralized storage information of NFT assets

**TL;DR:** 为 ERC-721 和 ERC-1155 元数据 JSON 增加一个可选的 dStorage 对象，记录哪个去中心化存储网络保存了 NFT 的资产，以及如何验证。

## 它解决什么问题？

NFT 合约在链上记录所有权，但代币所代表的图片、视频或文件几乎总是存放在别处。[ERC-721](/eip-721/) 和 [ERC-1155](/eip-1155/) 的元数据 schema（以及建立在其上的市场惯例）描述了 `name`、`description`、`image` 等，却完全没有说明资产存放在*哪里*，或者*存得有多持久*。

ERC-5625 用一个可选的元数据字段填补了这个空白，让收藏者和工具能看到资产是否存放在 Arweave、Filecoin、Swarm 或 Crust 等去中心化存储网络上，并找到可证明其已被存储的指针。

## 它如何运作

`tokenURI`（ERC-721）或 `uri`（ERC-1155）返回的元数据 JSON 可以包含一个 `dStorage` 对象。如果存在，它的六个字符串字段全部为必填：

| 字段 | 含义 |
| --- | --- |
| `platform` | 存储网络的名称（例如 Arweave、Filecoin） |
| `description` | 对该平台的简短描述 |
| `persistence_mechanism` | 数据如何被持续保存或获得激励，例如 "blockchain-based"、"contract-based" |
| `challenge_mechanism` | 如何证明存储，例如 Arweave 的 proof-of-access |
| `consensus` | 该平台的共识机制，例如 PoW、PoS |
| `dstorage_note` | 该资产已被存储的证据，例如 Filecoin 的 deal id 或 Crust 存储订单的交易哈希 |

智能合约无需任何改动。作者有意选择扩展 JSON schema 而不是新增接口，这样已经部署的合集只需更新元数据文件就能采用。

## 示例代码

带有 `dStorage` 块的 ERC-721 元数据（值为示意用的占位符）：

```json
{
  "name": "Sunset #42",
  "description": "A generative sunset.",
  "image": "ar://<arweave-tx-id>",
  "dStorage": {
    "platform": "Arweave",
    "description": "Permanent, pay-once decentralized storage",
    "persistence_mechanism": "blockchain-based",
    "challenge_mechanism": "proof-of-access",
    "consensus": "<platform consensus>",
    "dstorage_note": "<arweave-tx-id>"
  }
}
```

从客户端读取（ethers v6）：

```ts
import { Contract, JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const nft = new Contract(nftAddress, ["function tokenURI(uint256) view returns (string)"], provider);
const uri: string = await nft.tokenURI(42n);
const meta = await (await fetch(uri.replace("ipfs://", "https://ipfs.io/ipfs/"))).json();
if (meta.dStorage) console.log(`stored on ${meta.dStorage.platform}: ${meta.dStorage.dstorage_note}`);
```

## 需要注意

- 状态为 **Final**，但该字段是可选的；大多数 NFT 元数据并不包含它，所以请把它的缺失视为"未知"，而不是"中心化"。
- 该字段纯属信息性质，本身不能证明任何事情：关心这一点的客户端必须自行对照所指明的存储网络核对 `dstorage_note`。
- 它不影响合约行为或转移的有效性，并且与 ERC-721 和 ERC-1155 的元数据完全向后兼容。


---

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