Skip to content

Documentation

Registering an agent

Mint an ERC-8004 identity in the official registry with a registration file stored onchain, and read the real agent id from the confirmed transaction.

What happens when you register

  1. Build — your input is validated and sanitized into an ERC-8004 registration-v1 file with an AgentID extension block.
  2. Predict — register(agentURI) is simulated from your address; the return value is the id the registry would assign. The file's registrations[] points at it.
  3. Encode — the file becomes a data:application/json;base64,… URI (at most 64 KB), so the metadata lives onchain with the identity.
  4. Send — your wallet signs register(agentURI). AgentID never holds your keys.
  5. Confirm — after the receipt, the agent id is read from the Registered event, not from the prediction.
register.ts
import { AgentID } from "@agentid/sdk";

const agentid = new AgentID({ chainId: 46630 });

// walletClient: a viem WalletClient on chain 46630 — from wagmi's useWalletClient() in a browser,
// or createWalletClient({ account, chain: robinhoodTestnet, transport: http() }) in Node.
const result = await agentid.registerAgent({
  walletClient,
  input: {
    name: "Atlas",
    description: "Research agent that summarises public filings.",
    handle: "atlas",
    category: "research",
    capabilities: ["Web research", "data-analysis"], // labels are slugified: "web-research"
    services: [{ name: "MCP", endpoint: "https://atlas.example/mcp" }],
    links: { website: "https://atlas.example" },
  },
  onStatus: (s) => console.log(s.stage),
});

result.agentId;                      // bigint, read from the Registered event of the confirmed tx
result.txHash;                       // explorer: /tx/<hash>
result.registrationReferenceMatches; // false only if someone registered between simulation and inclusion

The app's registration wizard runs the same flow with your browser wallet. Agent ids in the official registry start at 0 and increase by one per registration.

Previewing cost and id

prepareRegistration runs steps 1–3 without sending anything — useful for a review screen.

prepare.ts
const prepared = await agentid.prepareRegistration({ account: "0xYourOwnerAddress", input });

prepared.predictedAgentId; // the id register() would return right now (simulated)
prepared.agentURI;         // data:application/json;base64,…
prepared.uriBytes;         // bytes stored onchain
prepared.estimatedFeeWei;  // gas × gasPrice

If another registration lands first, your agent receives a different id than predicted. The registration still succeeds and registrationReferenceMatches is false; fix the file with updateRegistration:

update.ts
// Repoint registrations[] (or change any field): setAgentURI with a freshly encoded data: URI
await agentid.updateRegistration({ walletClient, agentId: result.agentId, input });

The registration file

Keys are written in a fixed order: type, name, description, image, services, x402Support, active, registrations, supportedTrust, agentid. The agentid block is AgentID's namespaced extension; other ERC-8004 tooling can ignore it.

registration file (decoded)
{
  "type": "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
  "name": "Atlas",
  "description": "Research agent that summarises public filings.",
  "services": [{ "name": "MCP", "endpoint": "https://atlas.example/mcp" }],
  "x402Support": false,
  "active": true,
  "registrations": [
    { "agentId": 42, "agentRegistry": "eip155:46630:0x8004A818BFB912233c491871b3d84c89A494BD9e" }
  ],
  "agentid": {
    "schema": 1,
    "handle": "atlas",
    "category": "research",
    "capabilities": ["web-research", "data-analysis"],
    "links": { "website": "https://atlas.example" }
  }
}
Capabilities are self-declared
Capabilities are self-declared by the agent owner and have not been independently verified.

Input limits#

FieldRule
namerequired, ≤ 64 characters
description≤ 500 characters
imagehttps://, ipfs://, an AgentID asset URL or data:image/(png|jpeg|webp|gif);base64
capabilities≤ 12, each ≤ 48 characters, normalized to slugs
services≤ 8 entries of { name, endpoint, version? }; endpoint ≤ 512 characters; dangerous schemes rejected
linkswebsite / github / docs — https:// only
categoryresearch, finance, productivity, development, data, infrastructure, creative, security, general
file size≤ 65536 bytes encoded

Text is sanitized before encoding: control characters, bidirectional overrides and invisible characters are removed and lengths are capped. Invalid input throws AgentIDError with code INVALID_METADATA before any transaction is sent.

Handles#

A handle (@atlas) is an application-level display name, not an onchain identifier: 3–32 characters of lowercase letters, digits and inner hyphens, excluding reserved words. The AgentID index awards a handle to the earliest-registered agent on a chain whose current file requests it; later requests are marked as conflicts. Check availability with GET /api/v1/handles/{handle}.

What the transaction does onchain

In the official registry, one register(agentURI) call:

  • mints the ERC-721 identity to your address (Transfer(0x0, owner, agentId));
  • emits Registered(agentId, agentURI, owner);
  • sets the reserved agentWallet metadata to your address (MetadataSet). Transfers clear it.

Owners, approved addresses and operators can later call setAgentURI and setMetadata. Every change is an event the AgentID indexer records.

Errors

CodeWhen
WRONG_NETWORKThe wallet is not on the client's chain
USER_REJECTEDThe request was rejected in the wallet
INSUFFICIENT_FUNDSNot enough ETH for gas — use the testnet faucet
INVALID_METADATAInput failed validation (nothing was sent)
TX_REVERTEDThe transaction was mined but reverted
RPC_ERROR / TIMEOUTThe RPC failed or did not answer in time

Making it discoverable

The indexer polls the chain every few seconds. To index a confirmed registration immediately, submit its hash; AgentID reads the receipt from the RPC itself and only processes logs from its configured contracts — it never trusts the client.

terminal
curl -X POST https://agentid-beryl.vercel.app/api/v1/index/tx \
  -H 'content-type: application/json' \
  -d '{"chainId":46630,"txHash":"0x…"}'
# → { "data": { "processed": true, "agents": [{ "chainId": 46630, "registry": "0x8004…", "agentId": "42" }], … } }

The public passport is then at /agent/46630/<registry>/<agentId> — see Resolving an identity.