| name | erc8004-agent-creation-guide |
| description | Step-by-step guide to creating and deploying ERC-8004 Trustless Agents. Covers the full lifecycle from generating an agent identity NFT, setting up metadata, registering on-chain across 12 chains, building reputation, and connecting to the agent marketplace. |
| license | MIT |
| metadata | {"category":"protocol","difficulty":"intermediate","author":"nich","tags":["protocol","erc8004-agent-creation-guide"]} |
ERC-8004 Agent Creation Guide
A step-by-step guide to creating and deploying ERC-8004 Trustless Agents — from generating an identity NFT to building on-chain reputation across 12 chains.
ERC-8004 Overview
ERC-8004 ("Trustless Agents") is an Ethereum standard for AI agent identity:
| Component | Description |
|---|
| Agent NFT | Each agent is an on-chain NFT (ERC-721) |
| Identity | Name, description, capabilities stored on-chain |
| Reputation | On-chain feedback and scoring system |
| Registry | Global registry of all agents |
| Validation | Trustless verification of agent capabilities |
The 7-Step Process
Step 1: Generate Agent Identity
import { AgentFactory } from '@erc8004/sdk';
const factory = new AgentFactory(provider);
const agentIdentity = {
name: "Sperax DeFi Advisor",
description: "Expert AI agent for Sperax protocol — USDs yield, SPA staking, and Demeter farming",
category: "defi",
capabilities: [
"portfolio-analysis",
"yield-optimization",
"risk-assessment",
"trade-execution"
],
model: "claude-3.5-sonnet",
version: "1.0.0"
};
Step 2: Create Agent Metadata
{
"name": "Sperax DeFi Advisor",
"description": "Expert for USDs, SPA, and Sperax Farms",
"image": "ipfs://Qm.../agent-avatar.png",
"external_url": "https://app.sperax.io/agents/defi-advisor",
"attributes": [
{ "trait_type": "Category", "value": "DeFi" },
{ "trait_type": "Chain", "value": "Arbitrum" },
{ "trait_type": "Model", "value": "Claude 3.5 Sonnet" },
{ "trait_type": "Tools", "value":
Step 3: Upload Metadata to IPFS
curl -X POST https://api.pinata.cloud/pinning/pinJSONToIPFS \
-H "Authorization: Bearer $PINATA_JWT" \
-d @agent-metadata.json
Step 4: Mint Agent NFT
const tx = await factory.createAgent({
metadataURI: "ipfs://QmAgentMetadataHash",
owner: "0xYourAddress",
chain: "arbitrum"
});
console.log(`Agent NFT minted: Token ID ${tx.tokenId}`);
console.log(`Transaction: ${tx.hash}`);
Step 5: Register in Global Registry
const registry = new AgentRegistry(provider);
await registry.register({
tokenId: tx.tokenId,
endpoint: "https://api.chat.sperax.io/agents/defi-advisor",
mcpEndpoint: "https://mcp.chat.sperax.io/defi-advisor",
publicKey: "0x...",
chains: [42161, 1]
});
Step 6: Deploy Across Chains
ERC-8004 supports 12 chains:
| Chain | Chain ID | Status |
|---|
| Ethereum | 1 | ✅ |
| Arbitrum | 42161 | ✅ |
| Base | 8453 | ✅ |
| Polygon | 137 | ✅ |
| Optimism | 10 | ✅ |
| BSC | 56 | ✅ |
| Avalanche | 43114 | ✅ |
| Fantom | 250 | ✅ |
| Gnosis | 100 | ✅ |
| zkSync | 324 | ✅ |
| Scroll | 534352 | ✅ |
| Linea | 59144 | ✅ |
await factory.deployMultichain({
tokenId: tx.tokenId,
chains: [1, 42161, 8453, 56]
});
Step 7: Build Reputation
await registry.submitFeedback({
agentTokenId: 42,
score: 5,
category: "accuracy",
comment: "Excellent yield optimization advice"
});
const rep = await registry.getReputation(42);
Agent Lifecycle
Create Identity → Upload Metadata → Mint NFT → Register
│ │
│ ┌──────────────────────────────────────────┘
│ │
▼ ▼
Deploy → Serve Users → Collect Feedback → Build Reputation
│ │
└──── Update Metadata ◄───────────────────┘
SperaxOS Integration
ERC-8004 agents created through SperaxOS automatically:
- Get SperaxOS marketplace listing
- Receive the Sperax agent badge
- Can access all builtin tools
- Are indexed for discovery
Links