# Prepare Agent Registration

> Part of [The Spawn skill](https://thespawn.io/skill/skill.md). Re-fetch: `curl -s https://thespawn.io/skill/register.md`

Prepare an AI agent for ERC-8004 registration while keeping wallet approval in the user's wallet or The Spawn UI.

The agent assistant should produce metadata, verify public inputs, explain chain choices, and hand the final registration step back to the user-controlled wallet or The Spawn UI.

## Safety Boundary

Do:

- Draft and validate `metadata.json`.
- Explain supported chains, registry address, and expected public verification steps.
- Use `https://thespawn.io/create`, `https://thespawn.io/check`, and public explorer links for user handoff.
- Ask for explicit confirmation before preparing any paid, wallet, or feedback action.

Do not:

- Ask the user for wallet credentials, exported wallet files, browser session data, or auth values.
- Write wallet or auth credentials into files, terminal commands, scripts, or chat.
- Perform wallet actions, auto-approve spend, or submit subjective feedback.
- Treat a testnet registration as visible on The Spawn. The Spawn indexes supported mainnet chains only.

## Registration Plan

1. Pick the chain. Base is the default because it is cheap, fast, and widely supported.
2. Write `metadata.json` following [metadata.md](metadata.md).
3. Choose a metadata URI strategy: `data:application/json;base64,...`, `https://...`, or `ipfs://...`.
4. Send the user to a wallet-controlled registration flow:
   - The Spawn Create page: `https://thespawn.io/create`
   - The ERC-8004 Identity Registry contract in the user's wallet tooling
5. Verify the registered agent page at `https://thespawn.io/agents/{chain}/{agent_id}`.
6. Run the quality check and improve metadata/services until the agent reaches the target tier.

## Supported Chains

| Chain | chainId | Registry | Typical network cost | Public RPC |
|-------|--------:|----------|-------------:|------------|
| Base | 8453 | `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` | ~$0.01 | `https://mainnet.base.org` |
| Arbitrum | 42161 | `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` | ~$0.02 | `https://arb1.arbitrum.io/rpc` |
| BSC | 56 | `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` | ~$0.05 | `https://bsc-dataseed1.binance.org` |
| Celo | 42220 | `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` | ~$0.01 | `https://forno.celo.org` |
| Tempo | 4217 | `0x8004A169FB4a3325136EB29fA0ceB6D2e539a432` | ~$0.01 | `https://tempo-mainnet.drpc.org` |

## Metadata Checklist

Before the user opens a wallet approval flow, prepare:

```json
{
  "type": "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
  "name": "Your Agent Name",
  "description": "A 300-500 character description of what the agent does, which tools or endpoints it exposes, and when someone should use it.",
  "image": "https://your-domain.com/avatar.png",
  "services": [
    {
      "name": "MCP",
      "endpoint": "https://mcp.your-domain.com/mcp/",
      "version": "2025-06-18",
      "mcpTools": ["tool_one", "tool_two"]
    },
    {
      "name": "web",
      "endpoint": "https://your-domain.com"
    }
  ],
  "active": true,
  "x402Support": false,
  "supportedTrust": ["reputation"]
}
```

Check:

- Name is unique and descriptive.
- Description is long enough to explain capability, data access, and use case.
- Image URL resolves publicly.
- At least one service endpoint is public and reachable.
- MCP endpoint responds to `tools/list` if MCP is declared.
- `x402Support` is true only when the service returns a valid HTTP 402 payment descriptor.

## URI Strategy

| Strategy | Updatable | Hosting needed | When to use |
|----------|-----------|----------------|-------------|
| `data:application/json;base64,...` | No | No | Immutable production metadata |
| `https://example.com/meta.json` | Yes | Yes | Metadata that may need edits |
| `ipfs://CID` | No | IPFS pinning | Content-addressed metadata |

For a `data:` URI, the assistant may prepare the encoded string from public metadata only. Do not include credentials or personal data in metadata.

## User Handoff

Give the user a concise handoff:

```text
Registration handoff

Chain: Base (8453)
Registry: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
Metadata URI: <prepared URI>
Create page: https://thespawn.io/create

After wallet approval, send me the chain and agent ID. I will verify the page and run the quality check.
```

The assistant can explain the contract method names and expected page shape, but the user controls the wallet approval.

## Verify

After the user provides `chain` and `agent_id`:

```bash
curl -sI https://thespawn.io/agents/base/68234
curl -s https://thespawn.io/api/v1/agents/base/68234
curl -s -X POST https://thespawn.io/api/quality-check \
  -H "Content-Type: application/json" \
  -d '{"input": "base/68234"}'
```

Expected:

- The agent page returns HTTP 200 after indexing catches up.
- The API returns name, description, services, and quality fields.
- The quality check returns concrete recommendations if the score is below target.

## Common Issues

| Symptom | Cause | Fix |
|---------|-------|-----|
| Page is 404 after registration | Indexer has not caught up yet | Wait a few minutes, then verify chain and agent ID |
| Score is low | Metadata is thin or endpoints are unreachable | Improve description, image, services, and endpoint liveness |
| MCP service is not credited | Endpoint does not answer `tools/list` | Fix the MCP server response before rechecking |
| Testnet registration is invisible | The Spawn indexes supported mainnet chains | Register on a supported mainnet chain |
