# Mint an ERC-8004 Agent NFT on Mantle — Build Guide

> **What this is:** Step-by-step guide to giving your AI agent a real on-chain identity by minting an ERC-8004 NFT on Mantle Sepolia testnet. Includes the explainer for what ERC-8004 is, why it matters, and the full mint flow.
>
> **Build time:** ~15 minutes.
> **Cost:** $0 (testnet — free MNT from faucet).
> **Skill level:** comfortable with a terminal, copy-pasting commands, and editing a couple of files.

---

## Quick Facts

```
┌──────────────────────────────────────────────────────────────────────┐
│                                                                      │
│   Standard ............... ERC-8004 ("Trustless Agents")             │
│   Authored by ............ MetaMask · Ethereum Foundation ·          │
│                            Google · Coinbase                         │
│   Chain ................. Mantle Sepolia (testnet, free)             │
│   Mainnet status ........ Deployed Feb 16, 2026                      │
│   What you mint ......... An ERC-721 NFT representing your agent     │
│   Cost .................. ~0.0001 test MNT (free from faucet)        │
│   Where it shows up ..... 8004scan.io (mainnet) / mantlescan.xyz     │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘
```

---

# Part 1: The Big Picture

## The Problem

AI agents are everywhere — marketing agents, trading bots, customer-support bots, the lot. But they all live in silos. There's no standard way to answer:

- **Who is this agent?** (no identity)
- **Has it done good work before?** (no portable reputation)
- **Can I prove it actually did what it claims?** (no validation)
- **How do I find it / pay it / talk to it?** (no discovery)

The Mantle team calls this the **"visibility crisis."** Agents can call APIs, run code, hold money — but they're invisible to the broader financial system because they have no credentials.

## The Solution: ERC-8004

```
┌──────────────────────────────────────────────────────────────────────┐
│                                                                      │
│   THREE REGISTRIES                                                   │
│   ════════════════                                                   │
│                                                                      │
│   1. IDENTITY REGISTRY                                               │
│      Each agent gets a unique ERC-721 NFT.                           │
│      The NFT points to a JSON file with name, image, endpoints.      │
│      → This is what you'll mint today.                               │
│                                                                      │
│   2. REPUTATION REGISTRY                                             │
│      Anyone can leave on-chain feedback on your agent.               │
│      Your agent's track record is portable across platforms.         │
│                                                                      │
│   3. VALIDATION REGISTRY                                             │
│      Cryptographic proof of work completed.                          │
│      zkML, TEE attestations, stake-secured re-execution.             │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘
```

## Why Mantle

Mantle deployed all three registries on mainnet in February 2026 — they're positioning their L2 as the hub for the "Internet of Agents," especially for real-world assets and DeFi. They were one of the first major L2s to do this.

We'll mint on **Mantle Sepolia** (testnet) so it's free. The flow is identical for mainnet.

## How It Fits With Other Standards

```
                 Your AI Agent
                      │
       ┌──────────────┼──────────────┐
       │              │              │
   ERC-8004          MCP            x402
   (identity)      (tools)       (payments)
                      │
                     A2A
                (agent-to-agent
                 communication)
```

ERC-8004 gives your agent **identity + reputation**. Combine it with:
- **MCP** (Model Context Protocol) → agent uses tools
- **x402** → agent gets paid in stablecoins
- **A2A** → agent talks to other agents

Stack all four and your agent is a full citizen of the agent internet.

---

# Part 2: What You'll Have at the End

```
┌──────────────────────────────────────────────────────────────────────┐
│                                                                      │
│   ✓ AGENT NFT OWNERSHIP                                              │
│     An ERC-8004 NFT on Mantle Sepolia, owned by your wallet.         │
│                                                                      │
│   ✓ CUSTOM METADATA                                                  │
│     Your agent's name, description, and image — rendered in any      │
│     NFT viewer.                                                      │
│                                                                      │
│   ✓ SERVICE ENDPOINTS                                                │
│     One or more endpoints: web, A2A, MCP, email, ENS, DID.           │
│                                                                      │
│   ✓ WALLET BINDING                                                   │
│     Your wallet address bound as the verified agentWallet.           │
│                                                                      │
│   ✓ VERIFICATION & PROOF                                             │
│     Visible on Mantlescan with the transaction hash as proof.        │
│     (Mainnet mints show up on 8004scan.io.)                          │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘
```

---

# Part 3: The Plan in 5 Steps

```
   ┌───────────────────────────────────────────────────────────────┐
   │                                                               │
   │   STEP 1   Add Mantle Sepolia + claim test MNT                │
   │   STEP 2   Host the image + write agent.json                  │
   │   STEP 3   Host the agent.json (Pinata or Gist)               │
   │   STEP 4   Set up Hardhat + run mint script                   │
   │   STEP 5   Verify the agent on Mantlescan                     │
   │                                                               │
   │   Total: ~15 min. No contracts to deploy — registries are     │
   │   already live on Mantle.                                     │
   │                                                               │
   └───────────────────────────────────────────────────────────────┘
```

---

# Part 4: Mantle Sepolia Network Info

Add this network to your wallet (MetaMask, Rabby, etc.):

```
┌──────────────────────────────────────────────────────────────────────┐
│                                                                      │
│   NETWORK NAME ........... Mantle Sepolia                            │
│   CHAIN ID ............... 5003                                      │
│   RPC URL ................ https://rpc.sepolia.mantle.xyz            │
│   CURRENCY ............... MNT                                       │
│   EXPLORER ............... https://sepolia.mantlescan.xyz            │
│                                                                      │
│   ONE-CLICK ADD .......... https://chainlist.org/chain/5003          │
│                                                                      │
│   FAUCETS (any one works):                                           │
│     · https://sepolia-faucet.pk910.de                                │
│     · https://faucet.sepolia.mantle.xyz                              │
│     · https://app.mantle.xyz/bridge?network=sepolia                  │
│                                                                      │
│   REGISTRY ADDRESSES:                                                │
│     Identity   → 0x8004A818BFB912233c491871b3d84c89A494BD9e          │
│     Reputation → 0x8004B663056A597Dffe9eCcC1965A193B7388713          │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘
```

> **Pro tip:** Use the chainlist.org link above — it adds Mantle Sepolia in one click. Faster than typing the RPC manually.

---

# Part 5: Step 1 — Host the Agent Image

Your agent needs a face. Any image (PNG/JPG/SVG) on any public URL works.

**Two easy options:**

```
┌──────────────────────────────────────────────────────────────────────┐
│                                                                      │
│   OPTION A — PINATA (IPFS, recommended for mainnet)                  │
│   ─────────────────────────────────────────────────────              │
│   1. Sign up at pinata.cloud (free)                                  │
│   2. Files → Upload → drag your image                                │
│   3. Copy the IPFS CID                                               │
│   4. Use as: ipfs://<cid>  OR the gateway URL                        │
│                                                                      │
│   OPTION B — IMGUR (faster, for testing)                             │
│   ─────────────────────────────────────────────                       │
│   1. Go to imgur.com                                                 │
│   2. Drag your image in                                              │
│   3. Right-click the uploaded image → "Copy image address"           │
│   4. Make sure it ends in .png / .jpg / .gif                         │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘
```

**Save the URL** — you'll paste it into `agent.json` in the next step.

> **⚠ Gotcha:** If you use Imgur, make sure you get the *direct* image URL (ends in .png/.jpg/.gif), not the page URL (imgur.com/abc123). Right-click the image after upload → "Copy image address."

---

# Part 6: Step 2 — Hardhat Project Setup

Open a terminal and run this one-shot command to scaffold everything:

```bash
# macOS / Linux
mkdir ~/Desktop/mint-8004 && cd ~/Desktop/mint-8004 && \
npm init -y && npm pkg set type=module && \
npm install --save-dev hardhat ethers dotenv @nomicfoundation/hardhat-ethers && \
mkdir scripts && touch hardhat.config.js agent.json .env scripts/mint-agent.js && \
code .
```

```powershell
# Windows (PowerShell)
cd "$env:USERPROFILE\Desktop"; mkdir mint-8004; cd mint-8004; `
npm init -y; npm pkg set type=module; `
npm install --save-dev hardhat ethers dotenv @nomicfoundation/hardhat-ethers; `
mkdir scripts; ni hardhat.config.js, agent.json, .env, scripts\mint-agent.js; `
code .
```

You should now have a folder like this:

```
mint-8004/
├── hardhat.config.js
├── agent.json
├── .env
├── package.json
├── scripts/
│   └── mint-agent.js
└── node_modules/
```

## hardhat.config.js

```javascript
import "@nomicfoundation/hardhat-ethers";
import "dotenv/config";

export default {
  solidity: "0.8.24",
  networks: {
    mantleSepolia: {
      type: "http",
      url: process.env.RPC,
      chainId: 5003,
      accounts: process.env.PK ? [process.env.PK] : [],
    },
  },
};
```

## agent.json

This is your agent's identity card. Customize every field for your agent:

```json
{
  "type": "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
  "name": "Goldwing",
  "description": "A pixel-art rooster fighter and on-chain agent.",
  "image": "https://violet-kind-canidae-922.mypinata.cloud/ipfs/YOUR_CID_HERE",

  "services": [
    { "name": "web",   "endpoint": "https://yoursite.com" },
    { "name": "email", "endpoint": "you@yoursite.com" }
  ],

  "x402Support": false,
  "active": true,

  "registrations": [],
  "supportedTrust": ["reputation"]
}
```

**Field guide:**

| Field | What it is |
|-------|------------|
| `name` | Your agent's display name |
| `description` | One-line description (~200 chars) |
| `image` | URL from Step 1 |
| `services` | How others reach your agent (web, MCP, A2A, email, ENS, DID) |
| `x402Support` | Set `true` if your agent accepts x402 payments |
| `supportedTrust` | Which trust mechanism — `reputation`, `validation`, `tee` |

## .env

```bash
PK=0xYOUR_PRIVATE_KEY_HERE
RPC=https://rpc.sepolia.mantle.xyz
AGENT_URI=https://.../agent.json
```

> **⚠ NEVER commit `.env` to GitHub.** Add `.env` to your `.gitignore` immediately. Treat your private key like a password — if leaked, anyone can drain that wallet.

> **Use a burner wallet for testing.** Generate a fresh wallet in MetaMask, send it some test MNT, use that private key. Don't use your main wallet's key.

---

# Part 7: Step 3 — Host the JSON

Same idea as the image. The `agent.json` file needs to live at a public URL.

```
┌──────────────────────────────────────────────────────────────────────┐
│                                                                      │
│   OPTION A — PINATA IPFS                                             │
│   ────────────────────                                               │
│   pinata.cloud → Files → Upload your agent.json                      │
│   Copy the file URL → paste into .env as AGENT_URI                   │
│                                                                      │
│   OPTION B — GITHUB GIST                                             │
│   ───────────────────                                                │
│   1. gist.github.com → New gist                                      │
│   2. Filename: agent.json                                            │
│   3. Paste the JSON                                                  │
│   4. "Create secret gist"                                            │
│   5. Click "Raw" → copy the URL                                      │
│   6. Paste into .env as AGENT_URI                                    │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘
```

> **Note for production:** Use IPFS (Pinata) for mainnet — IPFS URLs are content-addressed and immutable. Gists are fine for testnet but the URL can change if you edit it.

---

# Part 8: Step 4 — Mint the Agent

Drop this into `scripts/mint-agent.js`:

```javascript
import { ethers } from "ethers";
import "dotenv/config";
import fs from "fs";

const REG = "0x8004A818BFB912233c491871b3d84c89A494BD9e";
const ABI = [
  "function register(string) external returns (uint256)",
  "event Registered(uint256 indexed agentId, string agentURI, address indexed owner)"
];

async function main() {
  // Read agent.json and inline it as base64 data URI
  const json = fs.readFileSync("./agent.json", "utf8");
  const agentURI =
    "data:application/json;base64," +
    Buffer.from(json).toString("base64");

  // Connect to Mantle Sepolia
  const provider = new ethers.JsonRpcProvider(process.env.RPC);
  const wallet = new ethers.Wallet(process.env.PK, provider);
  const contract = new ethers.Contract(REG, ABI, wallet);

  console.log("Minting agent NFT...");
  const tx = await contract.register(agentURI);
  console.log("Tx submitted:", tx.hash);

  const receipt = await tx.wait();
  const event = receipt.logs.find(
    (l) => l.topics[0] === ethers.id("Registered(uint256,string,address)")
  );

  console.log("✅ agentId:", BigInt(event.topics[1]).toString());
  console.log("🔗 https://sepolia.mantlescan.xyz/tx/" + tx.hash);
}

main().catch(console.error);
```

Run it:

```bash
npx hardhat run scripts/mint-agent.js --network mantleSepolia
```

You should see something like:

```
Minting agent NFT...
Tx submitted: 0xabc123...
✅ agentId: 42
🔗 https://sepolia.mantlescan.xyz/tx/0xabc123...
```

> **Two ways to embed the agent file in the NFT** — this script uses a **base64 data URI** (the JSON lives directly inside the NFT, no external hosting needed). The alternative is using your hosted `AGENT_URI` (the JSON lives at an external URL). Data URI is simpler for testing; hosted URI is better for production because it's editable later via `setAgentURI()`.

---

# Part 9: Step 5 — Verify Everything

## On Mantlescan

Click the transaction link from the script output. You should see:
- Status: **Success**
- A `Registered` event with your agentId
- Your wallet listed as the owner

## On-chain state checks

You can read the contract directly. In Hardhat console:

```bash
npx hardhat console --network mantleSepolia
```

```javascript
const reg = await ethers.getContractAt(
  ["function ownerOf(uint256) view returns (address)",
   "function tokenURI(uint256) view returns (string)"],
  "0x8004A818BFB912233c491871b3d84c89A494BD9e"
);

await reg.ownerOf(YOUR_AGENT_ID);   // → should be your wallet
await reg.tokenURI(YOUR_AGENT_ID);  // → should be your agentURI
```

## Metadata check

Open your `image` URL in a browser → confirms the image renders.
Open your `AGENT_URI` (if hosted) → confirms the JSON loads.

## On 8004scan.io (mainnet only)

Once you migrate to Mantle mainnet, your agent appears at:
`https://8004scan.io/agents/mantle/<agentId>`

Searchable by wallet address from the homepage.

---

# Part 10: Design Decisions & Gotchas

```
┌──────────────────────────────────────────────────────────────────────┐
│                                                                      │
│  WHY MANTLE SEPOLIA (NOT MAINNET)                                    │
│  ─────────────────────────────────                                   │
│  Mainnet costs real MNT and your agent shows up on 8004scan.io       │
│  immediately. For learning + iterating: testnet. For real            │
│  production agents: mainnet, same flow.                              │
│                                                                      │
│  WHY DATA URI INSTEAD OF HOSTED URL                                  │
│  ──────────────────────────────────                                  │
│  Inlining the JSON as base64 means your agent is fully self-         │
│  contained on-chain. No external hosting to maintain. Tradeoff:      │
│  you can't easily edit the agent file later. For production,         │
│  host on IPFS via Pinata and use the IPFS URL.                       │
│                                                                      │
│  WHY THREE REGISTRIES                                                │
│  ────────────────────                                                │
│  Identity is what you mint today — a unique ERC-721 NFT.             │
│  Reputation comes from interactions over time (others leave          │
│  feedback). Validation is for high-stakes work where reputation      │
│  alone isn't enough (zkML proofs, TEE attestations).                 │
│                                                                      │
│  WHY ERC-721 INSTEAD OF SOMETHING NEW                                │
│  ────────────────────────────────────                                │
│  Every wallet, marketplace, and indexer already supports ERC-721.    │
│  Making agent identities ERC-721 NFTs means they're immediately      │
│  discoverable across the entire NFT ecosystem. Smart design.         │
│                                                                      │
│  WHY THE supportedTrust FIELD                                        │
│  ───────────────────────────                                         │
│  Lets other agents filter for the trust level they need before       │
│  hiring you. A high-stakes financial agent might require             │
│  "validation"; a casual agent might accept "reputation."             │
│                                                                      │
└──────────────────────────────────────────────────────────────────────┘
```

## Gotchas

```
 ┌────────────────────────────────────────────────────────────────────┐
 │                                                                    │
 │  ✗ Forgot to add `.env` to `.gitignore`                            │
 │    → Your private key is now public if you push to GitHub.         │
 │    → Use a burner wallet. Never commit .env.                       │
 │                                                                    │
 │  ✗ Used the wrong Identity Registry address                        │
 │    → Mantle Sepolia uses 0x8004A818BFB9...                         │
 │    → Mainnet uses a different address. Don't mix them.             │
 │                                                                    │
 │  ✗ Image URL is the page URL, not the direct image URL             │
 │    → NFT viewers will show a broken image.                         │
 │    → Right-click → Copy image address. URL must end in .png/.jpg.  │
 │                                                                    │
 │  ✗ "Cannot read private key" error                                 │
 │    → Make sure PK in .env starts with `0x`                         │
 │    → Make sure there are no quotes around it                       │
 │                                                                    │
 │  ✗ "Insufficient funds" error                                      │
 │    → You need test MNT in your wallet. Use one of the faucets.     │
 │    → Wait 30 seconds after claiming for it to land.                │
 │                                                                    │
 │  ✗ Agent.json doesn't load when opened                             │
 │    → If using Gist, make sure you clicked "Raw" before copying     │
 │      the URL — the regular Gist URL returns HTML, not JSON.        │
 │                                                                    │
 │  ✗ "Cannot find module" when running the script                    │
 │    → Make sure package.json has "type": "module"                   │
 │    → Run `npm install` again from inside the project folder        │
 │                                                                    │
 │  ✗ Agent doesn't show up on 8004scan.io                            │
 │    → 8004scan.io is mainnet only. Testnet mints don't appear.      │
 │    → Verify on sepolia.mantlescan.xyz instead.                     │
 │                                                                    │
 └────────────────────────────────────────────────────────────────────┘
```

## .gitignore

Drop this into the project root:

```
node_modules/
.env
.netlify/
artifacts/
cache/
```

---

# Part 11: What This Unlocks Next

You now have an AI agent with a real on-chain identity. From here:

```
 ┌──────────────────────────────────────────────────────────────────────┐
 │                                                                      │
 │  ADD PAYMENTS (x402)                                                 │
 │  ────────────────────                                                │
 │  Set x402Support: true and add an x402 payment endpoint to your      │
 │  services. Now your agent can accept micropayments in USDC.          │
 │                                                                      │
 │  ADD TOOLS (MCP)                                                     │
 │  ─────────────────                                                   │
 │  Expose an MCP endpoint in your services so other agents can use     │
 │  your agent as a tool.                                               │
 │                                                                      │
 │  BUILD REPUTATION                                                    │
 │  ────────────────                                                    │
 │  Have clients call `giveFeedback(agentId, score, uri)` on the        │
 │  Reputation Registry after using your agent. Reputation accrues.     │
 │                                                                      │
 │  MOVE TO MAINNET                                                     │
 │  ─────────────────                                                   │
 │  Same script, mainnet Identity Registry address, real MNT for gas.   │
 │  Your agent shows up on 8004scan.io alongside 195,000+ others.       │
 │                                                                      │
 │  HIRE OTHER AGENTS                                                   │
 │  ────────────────                                                    │
 │  Browse 8004scan.io for agents with the capabilities you need.       │
 │  Pay them via x402, verify their work via the Validation Registry.   │
 │                                                                      │
 └──────────────────────────────────────────────────────────────────────┘
```

---

# Appendix A: All Resources

## Core specifications

- **ERC-8004 EIP:** https://eips.ethereum.org/EIPS/eip-8004
- **ERC-8004 Contracts (GitHub):** https://github.com/erc-8004/erc-8004-contracts
- **ERC-8004 Official site:** https://8004.org

## Network access

- **Add Mantle Sepolia (1-click):** https://chainlist.org/chain/5003
- **Mantle Sepolia faucet:** https://faucet.sepolia.mantle.xyz
- **Mantle bridge:** https://app.mantle.xyz/bridge?network=sepolia

## Explorers

- **Mantle Sepolia (testnet):** https://sepolia.mantlescan.xyz
- **Mantle mainnet:** https://mantlescan.xyz
- **8004scan (multi-chain mainnet agent explorer):** https://8004scan.io

## Hosting

- **Pinata (IPFS):** https://pinata.cloud
- **Imgur (quick image hosting):** https://imgur.com
- **GitHub Gist:** https://gist.github.com

## Mantle ecosystem

- **Mantle ERC-8004 Launch announcement (Feb 2026):** https://www.prnewswire.com/news-releases/mantle-unlocks-autonomous-economy-with-erc-8004-deployment-302688549.html
- **Mantle Network:** https://www.mantle.xyz

## Further reading

- **ERC-8004 deep-dive (QuickNode):** https://blog.quicknode.com/erc-8004-a-developers-guide-to-trustless-ai-agent-identity/
- **ERC-8004 explainer (BuildBear):** https://www.buildbear.io/blog/erc-8004

## AlphaStack resources

- **Channel:** https://youtube.com/@alphastack
- **All build guides:** https://alphastack.fun
- **Related video — Claude Routines marketing agent:** /claude-routine-marketing-agent
- **Related video — Polymarket Edge Trader:** /polymarket-edge-trader

---

# Appendix B: Registry Addresses (Reference)

```
MANTLE SEPOLIA (TESTNET)
────────────────────────
Identity Registry    0x8004A818BFB912233c491871b3d84c89A494BD9e
Reputation Registry  0x8004B663056A597Dffe9eCcC1965A193B7388713

MANTLE MAINNET
──────────────
Check 8004.org or the ERC-8004 contracts GitHub for current
mainnet addresses. They are typically the same pattern but
verify before deploying real funds.
```

---

**End of guide.** Drop this into Claude Code and tell it "build this" if you want help with any step. Otherwise just follow the 5 steps in order — 15 minutes start to finish.

If you got stuck, leave a comment on the video or hit me up at alphastack.fun.

---

*Built by AlphaStack · alphastack.fun · Last updated May 15, 2026*