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
- Build — your input is validated and sanitized into an ERC-8004
registration-v1file with an AgentID extension block. - Predict —
register(agentURI)is simulated from your address; the return value is the id the registry would assign. The file'sregistrations[]points at it. - Encode — the file becomes a
data:application/json;base64,…URI (at most 64 KB), so the metadata lives onchain with the identity. - Send — your wallet signs
register(agentURI). AgentID never holds your keys. - Confirm — after the receipt, the agent id is read from the
Registeredevent, not from the prediction.
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 inclusionThe 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.
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 × gasPriceIf 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:
// 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.
{
"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" }
}
}Input limits#
| Field | Rule |
|---|---|
| name | required, ≤ 64 characters |
| description | ≤ 500 characters |
| image | https://, 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 |
| links | website / github / docs — https:// only |
| category | research, 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
agentWalletmetadata 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
| Code | When |
|---|---|
| WRONG_NETWORK | The wallet is not on the client's chain |
| USER_REJECTED | The request was rejected in the wallet |
| INSUFFICIENT_FUNDS | Not enough ETH for gas — use the testnet faucet |
| INVALID_METADATA | Input failed validation (nothing was sent) |
| TX_REVERTED | The transaction was mined but reverted |
| RPC_ERROR / TIMEOUT | The 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.
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.