First Agent Registration
This page starts with a copy-paste one-shot script that registers an agent end-to-end with minimal code.
If you need to publish an adapter or endpoint declaration to the HCS-21 adapter registry instead of creating a UAID, use Register Endpoints (HCS-21).
PrerequisitesDirect link to Prerequisites
- Completed the Installation & Setup guide.
- A running agent endpoint that supports A2A, ERC-8004, or another supported protocol.
- Credits on your Registry Broker account (required for additional registries, updates, many chat flows, and registrations outside the complimentary evaluation allowance) or Hedera credentials for auto top-up.
Endpoint field quick referenceDirect link to Endpoint field quick reference
- A2A and other HTTP-native protocols usually set the top-level
endpointfield to the public URL the broker should route to. - MCP registrations can omit the top-level
endpointwhenprofile.mcpServer.connectionInfo.urlalready contains the canonical endpoint URL. - XMTP registrations still use the same top-level
endpointfield, but the value should be an XMTP address such asxmtp://0xabc....
One-Shot Registration (Minimal Code)Direct link to One-Shot Registration (Minimal Code)
If you only need one working registration flow, use this script as-is and replace the environment variables.
import { config } from 'dotenv';
import {
AIAgentCapability,
AIAgentType,
HCS11Profile,
ProfileType,
RegistryBrokerClient,
isPendingRegisterAgentResponse,
isSuccessRegisterAgentResponse,
type AgentRegistrationRequest,
} from '@hashgraphonline/standards-sdk';
config();
async function main(): Promise<void> {
const apiKey = process.env.REGISTRY_BROKER_API_KEY;
const endpoint = process.env.AGENT_ENDPOINT;
const displayName = process.env.AGENT_DISPLAY_NAME ?? 'One Shot Agent';
if (!apiKey) {
throw new Error('REGISTRY_BROKER_API_KEY is required');
}
if (!endpoint) {
throw new Error('AGENT_ENDPOINT is required');
}
const client = new RegistryBrokerClient({
apiKey,
});
const profile: HCS11Profile = {
version: '1.0.0',
type: ProfileType.AI_AGENT,
display_name: displayName,
bio: 'Minimal one-shot registration example.',
aiAgent: {
type: AIAgentType.MANUAL,
model: 'gpt-4o-mini',
capabilities: [AIAgentCapability.DATA_ANALYSIS],
},
};
const payload: AgentRegistrationRequest = {
profile,
registry: 'hashgraph-online',
communicationProtocol: 'a2a',
endpoint,
};
const quote = await client.getRegistrationQuote(payload);
console.log('Required credits:', quote.requiredCredits);
console.log('Shortfall:', quote.shortfallCredits ?? 0);
if ((quote.shortfallCredits ?? 0) > 0) {
throw new Error(`Insufficient credits. Shortfall: ${quote.shortfallCredits}`);
}
const registration = await client.registerAgent(payload);
if (isSuccessRegisterAgentResponse(registration)) {
console.log('UAID:', registration.uaid);
return;
}
if (!isPendingRegisterAgentResponse(registration) || !registration.attemptId) {
throw new Error(`Unexpected registration status: ${registration.status}`);
}
const final = await client.waitForRegistrationCompletion(registration.attemptId, {
intervalMs: 2000,
timeoutMs: 5 * 60 * 1000,
});
if (final.status !== 'completed' || !final.uaid) {
throw new Error(`Registration ended with status: ${final.status}`);
}
const resolved = await client.resolveUaid(final.uaid);
console.log('UAID:', final.uaid);
console.log('Resolved name:', resolved.agent.profile.display_name);
}
main().catch(error => {
console.error(error);
process.exitCode = 1;
});
Run the ScriptDirect link to Run the Script
- Save the code as
register-agent.ts. - Add this to your
.env:
REGISTRY_BROKER_API_KEY=your-api-key
AGENT_ENDPOINT=https://your-agent.example.com/a2a
AGENT_DISPLAY_NAME=One Shot Agent
- Install and run:
pnpm add @hashgraphonline/standards-sdk dotenv
pnpm add -D tsx typescript @types/node
pnpm tsx register-agent.ts
If this script prints a UAID, your registration flow is complete. The rest of this page is optional detail.
Free ERC-8004 Registration on SKALEDirect link to Free ERC-8004 Registration on SKALE
Registry Broker publishes every new agent to SKALE Base Mainnet ERC-8004 at zero additional credits. When you omit additionalRegistries, the broker automatically includes erc-8004:skale-base-mainnet in the same registration attempt.
What is freeDirect link to What is free
- SKALE ERC-8004 on-chain registration costs
0additional credits. The broker covers gas for the SKALE identity-registry transaction. - Default behavior: omit
additionalRegistriesand SKALE is included automatically at no extra charge. - Explicit SKALE selection: set
additionalRegistries: ['erc-8004:skale-base-mainnet']to target SKALE directly.
What may still require creditsDirect link to What may still require credits
- The primary HCS UAID inscription (
registry: 'hashgraph-online') may still quote base credits unless your account is inside the complimentary evaluation allowance. - Other ERC-8004 networks (for example Ethereum Sepolia, Base, or Polygon) still charge additional credits when included alongside SKALE.
Quote and register with SKALEDirect link to Quote and register with SKALE
Discover the enabled SKALE network from the catalog, then confirm the quote shows zero additional credits before registering:
const catalog = await client.getAdditionalRegistries();
const skaleKey =
catalog.registries
.flatMap((registry) => registry.networks ?? [])
.find((network) => network.key === 'erc-8004:skale-base-mainnet')?.key ??
'erc-8004:skale-base-mainnet';
const skalePayload: AgentRegistrationRequest = {
profile,
registry: 'hashgraph-online',
communicationProtocol: 'a2a',
endpoint: 'https://your-agent.example.com/a2a',
additionalRegistries: [skaleKey],
};
const quote = await client.getRegistrationQuote(skalePayload);
console.log('Base credits:', quote.baseCredits);
console.log('Additional credits (SKALE):', quote.additionalCredits ?? 0);
if ((quote.additionalCredits ?? 0) !== 0) {
throw new Error(`Expected SKALE additional credits to be 0, received ${quote.additionalCredits}`);
}
const registration = await client.registerAgent(skalePayload);
To rely on the broker default instead of passing additionalRegistries, use the same payload shape as the one-shot example above. The registration response includes additionalRegistries with the resolved SKALE network and credits.additional: 0.
After waitForRegistrationCompletion, inspect final.additional (or the progress payload) and confirm the SKALE entry reports status: "completed" with an on-chain agentId.
Standards SDK demoDirect link to Standards SDK demo
The standards-sdk ships a focused SKALE walkthrough at demo/registry-broker/register-agent-erc8004-skale.ts. It resolves the SKALE catalog entry, asserts additionalCredits === 0, and prints the resulting UAID plus on-chain registration metadata.
Advanced Registration Flow (Optional)Direct link to Advanced Registration Flow (Optional)
Step 1 — Prepare the Agent ProfileDirect link to Step 1 — Prepare the Agent Profile
The registry expects an HCS-11 profile. Use the builders or construct a profile manually.
import {
AIAgentCapability,
AIAgentType,
HCS11Profile,
ProfileType,
} from '@hashgraphonline/standards-sdk';
const profile: HCS11Profile = {
version: '1.0.0',
type: ProfileType.AI_AGENT,
display_name: 'Ledger Guard',
bio: 'Automated treasury monitoring assistant.',
aiAgent: {
type: AIAgentType.MANUAL,
model: 'gpt-4o-mini',
capabilities: [
AIAgentCapability.SECURITY_MONITORING,
AIAgentCapability.COMPLIANCE_ANALYSIS,
],
},
socials: [
{ platform: 'github', handle: 'ledger-labs' },
],
};