The Zero-Knowledge Machine Lerning (zkML) AI-Generated Content (AIGC) non-fungible token (NFT) standard is an extension of the ERC-721 token standard for AIGC. It proposes a set of interfaces for basic interactions and enumerable interactions for AIGC-NFTs. The standard includes a new mint event and a JSON schema for AIGC-NFT metadata. Additionally, it incorporates zkML capabilities to enable verification of AIGC-NFT ownership. In this standard, the tokenId is indexed by the prompt.
Motivation
The zkML AIGC-NFTs standard aims to extend the existing ERC-721 token standard to accommodate the unique requirements of AI-Generated Content NFTs representing models in a collection. This standard provides interfaces to use zkML to verify whether or not the AIGC data for an NFT is generated from a certain ML model with certain input (prompt). The proposed interfaces allow for additional functionality related to minting, verifying, and enumerating AIGC-NFTs. Additionally, the metadata schema provides a structured format for storing information related to AIGC-NFTs, such as the prompt used to generate the content and the proof of ownership.
With this standard, model owners can publish their trained model and its ZKP verifier to Ethereum. Any user can claim an input (prompt) and publish the inference task, any node that maintains the model and the proving circuit can perform the inference and proving, then submit the output of inference and the ZK proof for the inference trace into the verifier that is deployed by the model owner. The user that initiates the inference task will own the output for the inference of that model and input (prompt).
Specification
The keywords “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “NOT RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119 and RFC 8174.
The zkML AIGC-NFTs standard includes the following interfaces:
IERC7007: Defines a mint event and a mint function for minting AIGC-NFTs. It also includes a verify function to check the validity of a combination of prompt and proof using zkML techniques.
pragmasolidity^0.8.18;/**
* @dev Required interface of an ERC7007 compliant contract.
* Note: the ERC-165 identifier for this interface is 0x7e52e423.
*/interfaceIERC7007isIERC165,IERC721{/**
* @dev Emitted when `tokenId` token is minted.
*/eventMint(uint256indexedtokenId,bytesindexedprompt,bytesindexedaigcData,stringuri,bytesproof);/**
* @dev Mint token at `tokenId` given `prompt`, `aigcData`, `uri` and `proof`.
*
* Requirements:
* - `tokenId` must not exist.'
* - verify(`prompt`, `aigcData`, `proof`) must return true.
*
* Optional:
* - `proof` should not include `aigcData` to save gas.
*/functionmint(bytescalldataprompt,bytescalldataaigcData,stringcalldatauri,bytescalldataproof)externalreturns(uint256tokenId);/**
* @dev Verify the `prompt`, `aigcData` and `proof`.
*/functionverify(bytescalldataprompt,bytescalldataaigcData,bytescalldataproof)externalviewreturns(boolsuccess);}
Optional Extension: Enumerable
The enumeration extension is OPTIONAL for ERC-7007 smart contracts. This allows your contract to publish its full list of mapping between tokenId and prompt and make them discoverable.
pragmasolidity^0.8.18;/**
* @title ERC7007 Token Standard, optional enumeration extension
* Note: the ERC-165 identifier for this interface is 0xfa1a557a.
*/interfaceIERC7007EnumerableisIERC7007{/**
* @dev Returns the token ID given `prompt`.
*/functiontokenId(bytescalldataprompt)externalviewreturns(uint256);/**
* @dev Returns the prompt given `tokenId`.
*/functionprompt(uint256tokenId)externalviewreturns(stringcalldata);}
ERC-7007 Metadata JSON Schema for reference
{"title":"AIGC Metadata","type":"object","properties":{"name":{"type":"string","description":"Identifies the asset to which this NFT represents"},"description":{"type":"string","description":"Describes the asset to which this NFT represents"},"image":{"type":"string","description":"A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."},"prompt":{"type":"string","description":"Identifies the prompt from which this AIGC NFT generated"},"aigc_type":{"type":"string","description":"image/video/audio..."},"aigc_data":{"type":"string","description":"A URI pointing to a resource with mime type image/* representing the asset to which this AIGC NFT represents."}}}
Rationale
TBD
Backwards Compatibility
This standard is backward compatible with the ERC-721 as it extends the existing functionality with new interfaces.
Test Cases
The reference implementation includes sample implementations of the ERC-7007 interfaces under contracts/ and corresponding unit tests under test/. This repo can be used to test the functionality of the proposed interfaces and metadata schema.