Skip to content

Documentation

SDK reference

@agentid/sdk: the AgentID client class, standalone helpers, constants and errors. Browser and Node; viem is a peer dependency.

Installation

Not published to npm
The package is not on the npm registry yet. Inside the monorepo, depend on "@agentid/sdk": "workspace:*" (TypeScript sources); elsewhere, build and pack it.
terminal
# 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#

MethodReturnsNotes
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#

MethodReturnsNotes
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#

MethodReturnsNotes
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#

MethodReturnsNotes
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).

AreaExports
VerificationverifyIdentityReport, verifyActivityReport, IDENTITY_CHECKS, ACTIVITY_CHECKS, computeOverall
KeyssignKeyAuthorization, buildKeyAuthorization, authorizeSigningKey, revokeSigningKey, rotateSigningKey, revokeAllSigningKeys, syncKeyOwner, getKeyState, getKeyRecord, isAuthorizedSigner
ActivitysignActivityRecord, parseSignedActivityRecord, signedActivityRecordSchema, activityRecordId
PayloadshashPayload, canonicalJson, generateNonce, EMPTY_PAYLOAD_HASH
RegistrationbuildRegistrationFile, encodeRegistrationDataURI, prepareRegistration, registerAgent, updateRegistration
MetadataresolveMetadata, parseRegistrationFile, parseRegistrationJson, registrationFileSchema, decodeDataURI, sanitizeText, validateHandle, slugifyCapability, normalizeImageUrl, safeExternalUrl, isImageReference, ipfsToGatewayUrl
HistorygetAuthorizationHistory, fetchAuthorizationEvents, buildAuthorizationIntervals, evaluateAuthorizationAt, getLogsChunked
AnchorsanchorActivity, anchorActivityBatch, getAnchor
APIlistAgentsFromApi, publishActivityRecord
DeploymentsresolveDeployment, parseDeploymentJson, KNOWN_DEPLOYMENTS

Chains, ABIs and constants

AreaExports
ChainsrobinhoodTestnet, robinhoodMainnet, localDevnet, ROBINHOOD_TESTNET_ID, ROBINHOOD_MAINNET_ID, LOCAL_DEVNET_ID, getChain, isSupportedChainId
RegistryOFFICIAL_ERC8004_IDENTITY (addresses, implementation, code hash, slots), agentRegistryId, parseAgentRegistryId
ExplorerexplorerTxUrl, explorerAddressUrl, explorerBlockUrl, explorerTokenUrl
ABIsidentityRegistryAbi, keyRegistryAbi, activityAnchorAbi, erc1271Abi
EIP-712activityTypedData, hashActivityRecord, activityDomain, keyAuthorizationTypedData, hashKeyAuthorization, expectedAuthorizationEpoch
ConstantsACTIVITY_TYPES, AGENT_CATEGORIES, CATEGORY_LABELS, SUGGESTED_CAPABILITIES, LIMITS, HANDLE_PATTERN, NONCE_PATTERN, RESERVED_HANDLES
DisclaimersSIGNATURE_DISCLAIMER, CAPABILITY_DISCLAIMER
TypesAgentRef, 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.

errors.ts
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
  }
}