EIPs Explained

ERC-7662 · Draft · ERC · 2024-03-26

ERC-7662: AI Agent NFTs

A draft ERC-721 extension for NFTs that represent AI agents, storing the agent's name, description, model and links to its (ideally encrypted) user and system prompts so marketplaces and tools can read them the same way.

What problem does it solve?

People who build AI agents (a model plus carefully written prompts) may want to sell or transfer them, and an NFT is a natural wrapper for that. But a plain ERC-721 only offers a public metadata URI. Putting the prompts there would let anyone copy the agent without owning it, and storing long prompts directly on-chain is expensive.

ERC-7662 defines a common shape for "agent NFTs" so marketplaces, agent-management apps and no-code tools can create, display and use them without guessing each project's format.

How it works

The contract is a normal ERC-721 plus one view function and one event:

function getAgentData(uint256 tokenId) external view returns (
    string memory name,
    string memory description,
    string memory model,            // e.g. a provider's model ID
    string memory userPromptURI,
    string memory systemPromptURI,
    bool promptsEncrypted
);
event AgentUpdated(uint256 indexed tokenId);
  • Prompts live off-chain, in decentralised storage, referenced by URI.
  • Privacy is recommended through encryption. The agent data mapping stays public, so anyone can see name, description and model and confirm that prompts exist, but the prompt files are encrypted with an access condition tied to the current holder (for example ownerOf(tokenId)). The spec prefers this over hiding the URIs behind an owner-only getter, because hidden URIs would still leak through storage and calldata. How the data is encrypted should be readable from the NFT so platforms know how to decrypt it.
  • Minting. The contract must provide a mint function that takes all agent fields and should emit AgentCreated(name, description, model, recipient, tokenId). An owner-only way to swap in encrypted prompt URIs after minting is recommended.
  • Template variables. Placeholders inside a user prompt must be written as ${variableName} so tools can fill them in.

Sample code

Reading an agent NFT and filling its prompt variables (ethers v6). Decryption depends on the platform named by the NFT and is left out.

import { Contract, JsonRpcProvider } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);
const agents = new Contract(process.env.AGENT_NFT!, [
  "function getAgentData(uint256) view returns (string,string,string,string,string,bool)",
  "function ownerOf(uint256) view returns (address)",
], provider);

const [name, description, model, userURI, systemURI, encrypted] =
  await agents.getAgentData(7n);
console.log({ name, model, owner: await agents.ownerOf(7n), encrypted });

// After fetching (and, if encrypted, decrypting) the user prompt:
function fill(template: string, vars: Record<string, string>) {
  return template.replace(/\$\{(\w+)\}/g, (_, k) => vars[k] ?? `\${${k}}`);
}
fill("Summarise ${topic} for a ${audience}.", { topic: "EIP-4844", audience: "developer" });
// "Summarise EIP-4844 for a developer."

Things to know

  • Status: Draft. The security section is still empty, and parts of the text use the placeholder "ERC-XXXX".
  • Encryption tied to ownership is a recommendation, not a requirement. Check promptsEncrypted and how access is enforced before treating an agent's prompts as private.
  • Once a holder has decrypted the prompts, nothing on-chain stops them from keeping a copy after they sell the NFT.
  • The model string names an external AI service; the NFT does not guarantee that model will stay available.
  • A later standard with a different design for agent NFTs with private metadata is ERC-7857; for agent identity and reputation see ERC-8004.

#nft #ai #agents #erc721 #metadata

Details

Authors
Greg Marlin (@marleymarl)
Status
Draft
Type
Standards Track / ERC
Created
2024-03-26
Requires

Machine-readable: Markdown · JSON