Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines ERC-7662, which proposes a mechanism for creating, managing, and trading AI agents as NFTs.
This article translates, summarizes, and expands on the specification linked below.
I also cover a variety of EIPs, BIPs, SLIPs, CAIPs, ENSIPs, RFCs, and ACPs.
Overview
Conventional NFT designs fall short when representing AI agents. ERC-7662 proposes an NFT standard specifically for AI agents to address these limitations.
Why ordinary NFT metadata is insufficient
A typical NFT stores information such as an image URL and description in JSON-formatted token metadata. AI agents, however, need to handle information such as the following.
- Prompts that determine the AI agent's behavior
- System instructions and constraints
- Configuration information specifying how to use the model
A prompt is text that tells an AI system how to behave and what objective to pursue. This is not merely descriptive text; it is important data that determines the value of the agent itself.
Including such data directly in ordinary NFT metadata is inappropriate. There are two main reasons.
First, prompts tend to be lengthy and may be too large for NFT metadata. Second, the prompts themselves may constitute intellectual property that should not be readable by everyone.
Defining data with a custom struct
ERC-7662 defines the information required for an AI agent NFT using a custom struct. A custom struct is a collection of data fields defined within a smart contract.
This makes it possible to:
- Standardize the format of information required by AI agents
- Allow marketplaces and management tools to read and write data in a common format
Why the data is stored off-chain and the role of decentralized storage
Under ERC-7662, actual data such as prompts is not stored directly on-chain.
On-chain storage means writing data directly to a blockchain such as Ethereum. Although on-chain storage offers transparency, it has several limitations.
- Gas costs are very high
- It is unsuitable for large amounts of data
- The contents are generally visible to anyone
ERC-7662 therefore represents data such as prompts using decentralized storage URLs. Decentralized storage refers to storage networks such as IPFS that do not rely on a central administrator.
The NFT stores only the URL specifying where the data is located, while the underlying data resides in decentralized storage.
Restricting access to the NFT owner
An AI agent's prompts are a central part of its value. ERC-7662 therefore assumes a mechanism that allows only the NFT owner to read them.
ERC-7662 presents two options for keeping the data private.
- Encrypt the data so that only the owner can decrypt it.
- Use another access-control mechanism.
The recommended approach is to encrypt the data using contract-specific parameters and allow only the NFT owner to decrypt it.
Encryption transforms data into a form that third parties cannot understand. Decryption restores the original contents.
This mechanism is intended to allow only the NFT holder to access the internal contents of the AI agent.
Motivation
Why AI agents are a good fit for NFTs
AI agents are entities that can be created, used, and evaluated for their value. These characteristics make them a natural fit for NFTs.
NFTs are well suited to:
- Establishing ownership
- Enabling sales and transfers
- Representing scarcity and value
Representing AI agents as NFTs makes it possible to establish an on-chain market for trading AI agents themselves.
Why standardization is necessary
Issuing an NFT alone is insufficient to support the actual distribution of AI agent NFTs.
Products such as the following must understand the same data format.
- NFT marketplaces
- AI agent management tools
- No-code AI development services
- Infrastructure providers
The data structure of AI agent NFTs therefore needs to be standardized.
Standardization establishes a common rule so that anyone interpreting data in the specified format can understand it in the same way.
ERC-7662 defines the custom struct needed for AI agent NFTs and aims to enable different products to create and interpret them using the same approach.
Creating new NFT use cases and liquidity
The goal of ERC-7662 goes beyond creating technically valid NFTs.
- Provide new applications for NFTs in AI.
- Give AI agents access to the liquidity of NFT markets.
Liquidity refers to the ability to sell when you want to sell and buy when you want to buy.
Widespread adoption of ERC-7662 could support an ecosystem comprising:
- Creators who build AI agents for specific fields
- Users who purchase and use AI agents
- Marketplaces that handle AI agent NFTs
The goal is to treat AI agents not merely as tools, but as assets whose value can circulate on-chain.
Specification
ERC721 compatibility and Agent interface requirements
A contract conforming to ERC-7662 must first support ordinary NFT minting and transfers as an ERC721 contract. It must additionally implement the Agent interface.
For more information about ERC721, see the article below.
[ERC721] An Introduction to ERC721
An interface here is an agreement defining the signatures of externally callable functions and the types of events.
The specification defines the following interface.
interface IERC7662 is IERC721 {
function getAgentData(uint256 tokenId) external view returns (
string memory name,
string memory description,
string memory model,
string memory userPromptURI,
string memory systemPromptURI,
bool promptsEncrypted
);
event AgentUpdated(uint256 indexed tokenId);
}Values returned by getAgentData
nameAgent name.descriptionAgent description.- model Identifier of the model being used (for example, a string such as gpt-4-0125-preview).
- userPromptURI URL where the user prompt is stored.
- systemPromptURI URL where the system prompt is stored.
- promptsEncrypted Flag indicating whether the prompts are encrypted.
A user prompt is a prompt provided as user input, such as a particular request or objective. A system prompt consists of foundational instructions, such as the AI agent's general policy and constraints.
Mapping token IDs to agent information
ERC-7662 requires a mapping associating an NFT's token ID (tokenId) with the information about its corresponding agent.
A mapping is a data structure that retrieves a value using a key, such as mapping(tokenId => AgentStruct) in Solidity.
Standardizing this association allows marketplaces and management tools to use a common method for retrieving the AI agent information associated with a given tokenId.
Public mappings and encryption of URIs are recommended
ERC-7662 recommends making the mapping from token IDs to agent information public. However, it recommends encrypting the user prompt URI and system prompt URI so that parties other than the owner cannot read them.
The design intent is clear: it favors encrypting the URIs and the data they reference rather than hiding the mapping.
Recommended privacy design
- Keep the mapping public so that anyone can verify basic agent information (
name/description/model). - Encrypt the URIs that provide access to the underlying prompts so that only the NFT owner can decrypt them.
The encryption approach uses contract-specific parameters configured during encryption to ensure that decryption is authorized only for the holder of that NFT.
The standard also recommends exposing information about the encryption method or platform as an NFT data property. This allows consumers, such as marketplaces and agent execution platforms, to implement predictable decryption flows for each method.
Why making the mapping private is not recommended
ERC-7662 also describes an alternative implementation in which the mapping itself is private and custom functions allow only the NFT holder to access it.
However, this approach has a problem.
Even if the mapping is private, the prompts still exist at a URL somewhere. If that URL is exposed, the referenced data may be retrieved.
The recommended approach is therefore:
- Keep the mapping public.
- Encrypt the URIs and their referenced data.
This approach also allows third parties to verify the following public information.
- The agent's
name/description/model. - The existence of user prompt and system prompt URIs in encrypted form.
Requirements for minting new agent tokens
A contract conforming to ERC-7662 must implement a function to mint new agent tokens.
The mint function should exhibit the following behavior.
| Requirement | Description |
|---|---|
| Accept agent properties | Accept arguments such as name, description, model, userPromptURI, and systemPromptURI. |
mint to a specified recipient |
Allow the mint destination address to be specified as an argument. |
Associate agent properties with tokenId |
Store agent information for the tokenId produced by mint. |
| Emit a creation event | Emit an event indicating that a new agent has been created. |
Recommended prompt encryption functionality
ERC-7662 recommends including functionality for encrypting user prompts and system prompts in the contract.
This functionality should exhibit the following behavior.
| Requirement | Description |
|---|---|
| Only the token owner can encrypt | Prevent anyone other than the owner from encrypting or replacing the prompts without authorization. |
Update userPromptURI / systemPromptURI to their encrypted versions |
Replace plaintext URIs with encrypted URIs or encrypted reference information. |
| Set the encryption flag | Update the state, for example to promptsEncrypted = true. |
An encrypted URI may literally be an encrypted URL string or an identifier containing information needed for decryption. The point made by ERC-7662 is that the value stored as a URI is encrypted.
Recommended AgentCreated event
ERC-7662 recommends implementing the following event.
event AgentCreated(string name, string description, string model, address recipient, uint256 tokenId)This event should be emitted when a new agent token is minted using mint.
It contains key information about the newly created agent, making it easier for external services to build listings and marketplaces to ingest the data.
Rules for injecting dynamic variables into user prompts
ERC-7662 also envisages a design in which external systems can insert dynamic variables before a user prompt is executed. These variables must be enclosed in the following format.
{dynamicVariableName}
For example, writing {userName} allows web forms and automation systems to recognize a replaceable variable.
Dynamic variable injection means replacing placeholders in a prompt template with values at runtime.
Recommended ERC-721 extension data for marketplace display
ERC-7662 recommends including additional data alongside the ERC721 standard so that NFT marketplaces can display AI agent NFTs more easily.
The Model field is particularly important. Knowing the model can indicate which platform's model the agent uses.
The following examples are given.
gpt-4-0125-previewindicates OpenAI.claude-3-opus-20240229indicates Anthropic.
The agent name and description can also be displayed using the standard ERC721 name / description metadata fields.
Additional details
A standard for consistently handling AI agent NFTs
ERC-7662 provides common rules for creating and interpreting AI agents as NFTs. The important point is that both creators and consumers can work with the same assumptions.
Conformance to ERC-7662 is intended to ensure the following.
- The information included in an AI agent NFT is clearly defined.
- There is a common function for retrieving agent information.
- Marketplaces and tools do not need to develop their own interpretations.
This enables interoperability across the ecosystem of products that handle AI agent NFTs.
Defining the required AI agent NFT parameters
ERC-7662 clearly defines the information needed to create and use AI agent NFTs.
The required agent information is as follows.
| Field | Meaning |
|---|---|
| Name | Name of the AI agent |
| Description | Description of what the agent does |
| Model | Identifier of the AI model being used |
| User Prompt | Prompt provided by the user at runtime |
| System Prompt | Prompt defining the agent's general policy |
An important feature of ERC-7662 is that it explicitly defines these fields in an Agent struct rather than placing them arbitrarily in metadata.
Why prompts are not stored in existing ERC721 metadata
In ordinary ERC721 implementations, additional information is included in token metadata, the JSON document referenced by tokenURI. However, storing AI agent prompts there is impractical.
The reasons are clear.
- Token metadata is accessible to anyone.
- People can read the prompts without owning the NFT.
- The prompts themselves are valuable intellectual assets of the AI agent.
ERC-7662 addresses this problem through the Agent struct and access control.
Why making the struct private alone is insufficient
At first glance, it may seem reasonable to make the Agent struct private and retrieve it through a function callable only by the NFT holder.
However, this approach has a fundamental problem.
- The struct contains the prompt URIs.
- If a URI is exposed anywhere, anyone can retrieve its referenced data.
- As a result, the prompt contents are not protected.
ERC-7662 therefore recommends encryption rather than relying on access control alone.
Recommended solution: encryption with ownership-based decryption
ERC-7662 recommends the following approach.
- Store prompts in encrypted form.
- Store the encrypted data URL in the Agent struct.
- Associate the decryption condition with
ownerOf(tokenId).
An on-chain-aware encryption service in this context is a mechanism that uses EVM contract parameters to determine whether decryption is authorized.
This approach is intended to achieve the following.
- People without the NFT cannot decrypt the data.
- After an NFT transfer, the new owner can decrypt the data.
- The value of the prompts is tied to ownership of the NFT.
Compatibility
Extension designed for ERC721 compatibility
ERC-7662 does not replace ERC721. It is designed as an extension standard that adds functionality to ERC721.
The design therefore preserves the following properties.
- Existing ERC721 functions are not modified.
- Function signatures and behavior remain unchanged.
- Wallets and services that support ERC721 can continue to handle the NFTs.
Why existing ERC721 functionality remains available
NFTs conforming to ERC-7662 continue to support functions such as the following.
| Function | Description |
|---|---|
transferFrom |
Transfer an NFT |
approve |
Set an approval |
balanceOf |
Retrieve the number of tokens held |
ERC-7662 adds only agent-related information and functions. It leaves the core ERC721 logic unchanged, avoiding disruption to existing infrastructure.
Wallet and service support
Even wallets and services that do not support ERC-7662 can continue to handle:
- Display as an NFT
- Transfers and sales
- Ownership management
Features specific to ERC-7662, such as displaying and executing agent information, can be used by marketplaces and DApps that implement the extension.
Reference implementation
Implementation in actual products
The original article describes ERC-7662 implementation work in DApps for creating, managing, and using AI agents on-chain.
The implementation combines the following.
- A DApp for creating and managing AI agent NFTs
- An encryption platform for protecting prompts
- A decentralized storage network for storing encrypted data
Prompt encryption workflow
The implementation encrypts prompts using custom EVMContractParameters.
These parameters allow smart contract conditions to specify when decryption is authorized.
NFT ownership is used as the condition.
ownerOf(tokenId)determines the decryption condition.- Only the address holding the NFT is authorized to decrypt the data.
Why encryption takes place after minting
In the reference implementation, encrypted prompts are added after the NFT is minted. The reason is straightforward.
- The
tokenIdis not determined until minting is complete. - The
tokenIdis needed in the encryption and decryption conditions.
The workflow is therefore:
- Mint the agent NFT.
- Determine the tokenId.
- Encrypt the prompts with the tokenId included in the conditions.
- Set the encrypted URIs in the Agent struct.
Role of the addEncryptedPrompts function
The reference implementation adds an addEncryptedPrompts function to support this workflow.
The function has the following responsibilities.
- It is intended to be called after minting.
- Set the encrypted
userPromptURI/systemPromptURI. - Update additional parameters of the Agent struct at the same time.
This enables the DApp to perform a workflow of minting, encryption, and registration securely.
Reference smart contract
The reference smart contract for ERC-7662 is provided in the assets directory.
The contract is presented as a practical implementation example rather than merely a conceptual implementation.
- It operates as an ERC721 contract.
- It implements the ERC-7662 Agent interface.
- It is designed for actual DApp usage.
Citation
Greg Marlin (@marleymarl), "ERC-7662: AI Agent NFTs [DRAFT]," Ethereum Improvement Proposals, no. 7662, March 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7662.
Conclusion
This article covered ERC-7662, which proposes a mechanism for creating, managing, and trading AI agents as NFTs. I hope this explanation was helpful.
If you have questions, feel free to reach out via direct message on Twitter.
I also publish content on other platforms, which you can find below.



