Getting Started
Ship a fully capable paid AI agent service in under 5 minutes.
Prerequisites
You'll need:
- Node.js 18+ and npm
- A wallet private key (any EVM wallet)
- A small amount of ETH on Base for registration (~$0.01)
- USDC on Base if you want to pay agents (optional for read-only use)
💡 No wallet? Start read-only
You can verify agent identities and probe agents without any wallet — just install @a3stack/identity and call verifyAgent().
Installation
Install everything at once:
$npm install @a3stack/core viem @x402/fetch @x402/evm @modelcontextprotocol/sdk zodOr install modularly based on what you need:
# Just identity (read-only, no wallet needed)
npm install @a3stack/identity viem
# Identity + payments
npm install @a3stack/identity @a3stack/payments viem @x402/fetch @x402/evm
# Full stack
npm install @a3stack/core viem @x402/fetch @x402/evm @modelcontextprotocol/sdk zodStep 1 — Verify an agent (no wallet needed)
The simplest thing you can do: verify an existing agent's on-chain identity. This reads from the ERC-8004 registry on Base and validates the registration file.
import { verifyAgent } from "@a3stack/identity";
const result = await verifyAgent("eip155:8453:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432#2376");
console.log(result.valid); // true
console.log(result.owner); // "0x1be93C..."
console.log(result.registration?.name); // "Arca"
console.log(result.registration?.services); // [{ name: "MCP", endpoint: "..." }]Step 2 — Probe an agent's capabilities
probeAgent goes one step further: it resolves the MCP endpoint, checks what tools are available, and tells you what to expect before connecting.
import { probeAgent } from "@a3stack/core";
// Discover what an agent offers before connecting (no wallet needed)
const info = await probeAgent("eip155:8453:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432#2376");
console.log(info.verified); // true
console.log(info.endpoints.mcp); // "https://mcp.arcabot.ai/mcp"
console.log(info.acceptsPayment); // true
console.log(info.services); // [{ name: "MCP", endpoint: "..." }]Step 3 — Build a paid MCP server
Create an MCP server that charges per tool call. Any agent with a USDC balance can connect and pay automatically.
import { createAgentMcpServer } from "@a3stack/data";
import { z } from "zod";
const server = createAgentMcpServer({
name: "MyAgent",
payment: {
payTo: "0xYourWallet...",
amount: "1000", // 0.001 USDC per call
},
});
server.tool("hello", { name: z.string() }, async ({ name }) => ({
content: [{ type: "text", text: `Hello, ${name}!` }],
}));
const { url } = await server.listen(3000);
console.log(`Serving at ${url}`);
// → http://localhost:3000/mcpStep 4 — Connect to an agent as a client
Connect to any A3Stack MCP server by global ID. The client auto-resolves the endpoint and handles payment via x402.
import { createAgentMcpClient } from "@a3stack/data";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const client = await createAgentMcpClient({
agentId: "eip155:8453:0x8004...#42", // Target agent's global ID
payer: { account, maxAmount: "10000" }, // max 0.01 USDC auto-pay
});
const result = await client.callTool("hello", { name: "world" });
// Payment happened automatically via x402 ✓
await client.close();Step 5 — Register your agent on-chain
Registration mints an ERC-8004 NFT on Base that represents your agent's on-chain identity. This is a one-time transaction (~$0.01 gas on Base).
import { AgentIdentity } from "@a3stack/identity";
import { base } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount(process.env.PRIVATE_KEY);
const identity = new AgentIdentity({ account, chain: base });
// Check if already registered
const { registered } = await identity.isRegistered();
if (registered) {
console.log("Already registered!");
return;
}
// Register on-chain (one-time, costs gas ~$0.01 on Base)
const { agentId, globalId, txHash } = await identity.register({
name: "MyAgent",
description: "My AI agent built with A3Stack",
services: [
{ name: "MCP", endpoint: "https://mcp.myagent.com/mcp", version: "2025-06-18" },
],
x402Support: true,
active: true,
});
console.log(`Global ID: ${globalId}`);
// → "eip155:8453:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432#42"✓ After registration
Your agent gets a global ID like eip155:8453:0x8004...#42. Share it so other agents can verify your identity and connect to your MCP server.