Documentation
SDK reference
@agentid/sdk: the AgentID client class, standalone helpers, constants and errors. Browser and Node; viem is a peer dependency.
Installation
"@agentid/sdk": "workspace:*" (TypeScript sources); elsewhere, build and pack it.# Not on npm yet. From the AgentID monorepo:
pnpm --filter @agentid/sdk build # tsup → dist/ (ESM, CJS, .d.ts), viem + zod external
cd packages/sdk && pnpm pack --pack-destination /tmp # → /tmp/agentid-sdk-0.1.0.tgz
npm install /tmp/agentid-sdk-0.1.0.tgz viem # in your project (viem ^2.30 is a peer dependency)The AgentID client
new AgentID(options) binds one chain and one registry; options are listed in Network configuration. Read-only properties: chainId, registry, keyRegistry, activityAnchor, deployment, publicClient, apiUrl. Agent ids accept bigint | number | string. Writes take a viem WalletClient, are checked to be on the client's chain, are simulated first and resolve after the receipt (TxResult = { txHash, blockNumber, gasUsed, status }).
Identity and reads#
| Method | Returns | Notes |
|---|---|---|
| getAgent(agentId, { resolveMetadata? }) | Promise<ResolvedAgent> | Owner, agentURI, agentWallet at one block + resolved file |
| getOwner(agentId) | Promise<Address> | ownerOf; AGENT_NOT_FOUND when missing |
| getAgentURI(agentId) | Promise<string> | Raw agentURI |
| resolveMetadata(agentURI) | Promise<ResolvedMetadata> | data: / https: / ipfs: resolution (no SSRF guard) |
| listAgents(params?) | Promise<{ agents, pagination, meta }> | Search the AgentID index (needs apiUrl) |
| verifyIdentity(agentId, { expectedOwner?, signer? }) | Promise<IdentityReport> | Identity report pinned to one block |
Registration#
| Method | Returns | Notes |
|---|---|---|
| prepareRegistration({ account, input }) | Promise<PreparedRegistration> | Simulate, build file, predict id, estimate fee |
| registerAgent({ walletClient, input, onStatus? }) | Promise<RegisterAgentResult> | register(agentURI); id read from Registered |
| updateRegistration({ walletClient, agentId, input | file }) | Promise<TxResult & { agentURI, file }> | setAgentURI with a new data: URI |
Signing keys#
| Method | Returns | Notes |
|---|---|---|
| buildKeyAuthorization({ agentId, key, deadline? }) | Promise<KeyAuthorizationTypedData> | Typed data for the key to sign (default deadline chain time + 30 min) |
| authorizeSigningKey({ walletClient, agentId, key, deadline, signature }) | Promise<TxResult> | authorizeKey with the key's proof |
| rotateSigningKey({ walletClient, agentId, oldKey, newKey, deadline, signature }) | Promise<TxResult> | Atomic revoke + authorize |
| revokeSigningKey({ walletClient, agentId, key }) | Promise<TxResult> | revokeKey |
| revokeAllSigningKeys({ walletClient, agentId }) | Promise<TxResult> | revokeAllKeys (epoch + 1) |
| syncKeyOwner({ walletClient, agentId }) | Promise<TxResult> | Permissionless sync (closes A→B→A) |
| isAuthorizedSigner(agentId, key) | Promise<boolean> | Live isAuthorized |
| getKeyRecord(agentId, key) | Promise<KeyRecord> | { epoch, authorizedAt, revokedAt, owner, exists } |
| getKeyState(agentId) | Promise<KeyState> | { epoch, boundOwner, currentOwner, expectedEpoch, blockNumber } |
| getAuthorizationHistory(agentId, key) | Promise<AuthorizationInterval[]> | Authorization windows from logs |
Activity#
| Method | Returns | Notes |
|---|---|---|
| signActivity({ signer, agentId, activityType, payload?, payloadHash?, timestamp?, nonce? }) | Promise<SignedActivityRecord> | Local EIP-712 signing, no RPC |
| verifyActivity(record, { payload?, now?, receivedAtBlock? }) | Promise<ActivityReport> | Activity report pinned to one block |
| publishActivity(record, { payload? }) | Promise<PublishActivityResult> | POST {apiUrl}/activity |
| anchorActivity({ walletClient, agentId, recordId }) | Promise<TxResult> | Anchor one record hash |
| anchorActivityBatch({ walletClient, agentId, recordIds }) | Promise<TxResult> | Up to 64 hashes, atomic |
| getAnchor(agentId, recordId) | Promise<AnchorInfo> | { anchored, timestamp?, blockNumber?, submitter?, txHash? } |
Standalone helpers
Everything the client uses is exported for servers and custom pipelines (for example with your own PublicClient).
| Area | Exports |
|---|---|
| Verification | verifyIdentityReport, verifyActivityReport, IDENTITY_CHECKS, ACTIVITY_CHECKS, computeOverall |
| Keys | signKeyAuthorization, buildKeyAuthorization, authorizeSigningKey, revokeSigningKey, rotateSigningKey, revokeAllSigningKeys, syncKeyOwner, getKeyState, getKeyRecord, isAuthorizedSigner |
| Activity | signActivityRecord, parseSignedActivityRecord, signedActivityRecordSchema, activityRecordId |
| Payloads | hashPayload, canonicalJson, generateNonce, EMPTY_PAYLOAD_HASH |
| Registration | buildRegistrationFile, encodeRegistrationDataURI, prepareRegistration, registerAgent, updateRegistration |
| Metadata | resolveMetadata, parseRegistrationFile, parseRegistrationJson, registrationFileSchema, decodeDataURI, sanitizeText, validateHandle, slugifyCapability, normalizeImageUrl, safeExternalUrl, isImageReference, ipfsToGatewayUrl |
| History | getAuthorizationHistory, fetchAuthorizationEvents, buildAuthorizationIntervals, evaluateAuthorizationAt, getLogsChunked |
| Anchors | anchorActivity, anchorActivityBatch, getAnchor |
| API | listAgentsFromApi, publishActivityRecord |
| Deployments | resolveDeployment, parseDeploymentJson, KNOWN_DEPLOYMENTS |
Chains, ABIs and constants
| Area | Exports |
|---|---|
| Chains | robinhoodTestnet, robinhoodMainnet, localDevnet, ROBINHOOD_TESTNET_ID, ROBINHOOD_MAINNET_ID, LOCAL_DEVNET_ID, getChain, isSupportedChainId |
| Registry | OFFICIAL_ERC8004_IDENTITY (addresses, implementation, code hash, slots), agentRegistryId, parseAgentRegistryId |
| Explorer | explorerTxUrl, explorerAddressUrl, explorerBlockUrl, explorerTokenUrl |
| ABIs | identityRegistryAbi, keyRegistryAbi, activityAnchorAbi, erc1271Abi |
| EIP-712 | activityTypedData, hashActivityRecord, activityDomain, keyAuthorizationTypedData, hashKeyAuthorization, expectedAuthorizationEpoch |
| Constants | ACTIVITY_TYPES, AGENT_CATEGORIES, CATEGORY_LABELS, SUGGESTED_CAPABILITIES, LIMITS, HANDLE_PATTERN, NONCE_PATTERN, RESERVED_HANDLES |
| Disclaimers | SIGNATURE_DISCLAIMER, CAPABILITY_DISCLAIMER |
| Types | AgentRef, AgentProfile, AgentSummary, RegistrationFile, SignedActivityRecord, IdentityReport, ActivityReport, VerificationCheck, NetworkStatus, ProtocolStats, ApiEnvelope, … |
Errors
Every error the SDK throws is an AgentIDError with a stable code: UNSUPPORTED_CHAIN, NOT_CONFIGURED, AGENT_NOT_FOUND, RPC_ERROR, INVALID_RECORD, INVALID_METADATA, TX_REVERTED, USER_REJECTED, WRONG_NETWORK, INSUFFICIENT_FUNDS, API_ERROR, TIMEOUT. viem rejections, insufficient-funds and chain-mismatch errors are mapped; contract reverts are decoded.
import { AgentIDError, isAgentIDError } from "@agentid/sdk";
try {
await agentid.getAgent("999999");
} catch (err) {
if (isAgentIDError(err)) {
err.code; // "AGENT_NOT_FOUND"
err.message; // "Agent #999999 does not exist in registry 0x8004…"
err.revert; // decoded custom error for contract reverts, when available
}
}