ERC-7829 Data asset NFT
Review · NFTs & multi-token · created 2024-11-29
An ERC-721 extension that mints online digital creations such as blogs or videos (data assets) as NFTs, verifies the integrity of offchain data using proofs of storage, and allows a single token to have multiple readers.
Why it is needed
With existing ERC-721 NFTs, value is determined by the scarcity of metadata, and high transaction fees and storage costs skew them toward representing ownership of high-value assets. This makes it hard to capture online digital products created by creators, such as blogs, videos, small games, or music, that is, data assets, as NFTs. In addition, to reduce storage costs, content is often kept in offchain or cross-chain storage with only a link placed onchain, but a contract onchain cannot access that link and so has no way to know whether the data has disappeared, been tampered with, or expired. As a result, even when data diverges from its actual value, the NFT remains onchain and its copyright can keep being traded in the market. Existing integrity solutions have limitations: either they put the content entirely onchain, making the cost unaffordable, or they rely on proofs from a trusted third party, which introduces centralization problems.
What to implement
event UpdateReader(uint256 indexed tokenId, address indexed reader, bool valid);: An event emitted when a reader is added to or removed from a token.function setReader(uint256 tokenId, address reader, bool valid) external;: Registers an address as a reader for a specific token (valid=true) or removes it. A reader cannot call this itself.function isReader(uint256 tokenId, address reader) external view returns (bool);: Checks whether a given address is a reader of the specified token.function commitByTokenId(uint256 tokenId) external view returns (bytes);: Returns the commitment (unique identifier) of the data linked to the token.function sizeByTokenId(uint256 tokenId) external view returns (uint256);: Returns the size of the data linked to the token.function expireByTokenId(uint256 tokenId) external view returns (uint64);: Returns the expiration time of the data linked to the token.
In depth
The three components of a data asset
This proposal divides a data asset into three parts. Storage Metadata contains the commitment, size, expiration time (expire), and uploader address, and is held and managed by a storage contract onchain. Permission Metadata contains ownership and read permissions, as well as which addresses can modify this information, and is held by a permission contract. Data Content is the actual data a user uploads to the storage system, and it is stored on an offchain storage node.
The IERC7829 interface and the boundaries of the reader role
The permission contract must implement IERC7829, which inherits from IERC721. It manages readers via setReader and isReader, queries per-token storage metadata via commitByTokenId, sizeByTokenId, and expireByTokenId, and emits an UpdateReader event when a reader changes. A single token can have multiple readers. Since the reader role must not entail any permission change, a reader cannot call functions such as transfer, approve, setApprovalForAll, or setReader.
Rule for preserving readers on transfer
When Alice calls transfer to pass her data asset NFT to Bob, the owner address changes to Bob's address and the approved address is reset to zero. However, all registered readers remain unchanged. This design reflects a property of data assets, namely that copying data does not degrade its quality and multiple users can access it, and is intended to separate ownership transfer from reading rights in order to increase the asset's utility and market value.
Metadata schema and expiration time checks
The metadata JSON schema defines name and description along with commit, which points to the data resource, size, the data size, and expire, the expiration time. The metadata is uploaded by the user, and a certificate in which the storage node signs the metadata is required. In the extended storage contract, when the owner or an approved operator calls transfer, approve, or setReader, it must first check whether the current time block.timestamp is greater than expire. If block.timestamp is less than expire, the subsequent operation proceeds; if it is greater, the operation is halted and an exception message is returned. This is a mechanism to prevent a token bound to expired data from continuing to be traded.
KZG-based proof of storage
Storage proofs prove the availability of data content, underpinning the accuracy of NFT metadata, particularly expiration. The proof method is not restricted, but KZG polynomial commitments are recommended. At initialization, generators g1 and g2 are created, and a commitment C is generated from the data content, which is posted as the data's unique identifier when metadata is uploaded. When a verifier generates a random value z, the prover generates a proof P=(y, π) and verification is done via e(π, yg1-zg2) = e(C - y*g1, g2). Multiple proofs can also be aggregated into one, summing all commitments into an aggregate commitment C_n and verifying the aggregate proof P_n=(y_n, π_n) in two stages. To keep proof generation time short, the data to challenge is chosen via random sampling, for which the contract must provide a secure pseudorandom generation function, and this random value is also used as z in KZG.
Optimistic proofs and the challenge period
Summing all commitments to obtain the aggregate commitment during verification costs a lot of gas. So an optimistic proof is recommended, which assumes the aggregate commitment is correct and only checks e(π_n, y_ng1-zg2) = e(C_n - y_n*g1, g2) at verification time. Since verifying the aggregate proof alone does not fully prove data availability, a fixed challenge period is set. During this period, anyone can challenge the commitment proof C_n; if the challenge succeeds, the challenger is rewarded and the prover is penalized, and if it fails, the challenger is penalized and the prover gains an additional benefit.
DA layer proof cycle and backward compatibility
The DA layer handles off-chain storage of data content and on-chain storage of storage metadata, periodically submitting and verifying storage proofs to protect the integrity of data assets. The proof cycle has two stages. First, the DA provider generates storage proofs for sampled data, bundles them into a single aggregate proof, and submits it to the DA contract, which verifies its consistency. Next, the DA verifier checks off-chain whether the aggregate proof was correctly derived from the selected data, and if it is incorrect, submits a fraud proof to challenge it. This proposal combines an ERC-721 extension and is backward compatible with the ERC-721 standard.
Proposal status: Review
This proposal is currently in the Review stage. It is not yet a finalized standard, so the interface and detailed specification may change going forward.
Things to watch out for
- Security dependence on DA layer choice: The security of data asset NFTs depends not only on the blockchain but also on the modular data layer (DA). Implementers must therefore choose the modular data layer (DA) carefully.