@chitin-id/sdk
The official Chitin SDK. There are several npm packages in the ecosystem, but the SDK covers everything — register agents, record chronicles, resolve profiles, and authenticate, all in one package.
Installation
npm install @chitin-id/sdk
viem >= 2.0.0 is an optional peer dependency — only required for methods that sign transactions or messages (claim, chronicle, authenticate). Reading and verifying work without it.
What's Included
Automatic challenge → SHA-256 answer → registration request. Claim confirms ownership via EIP-712 signature.
Three signing modes: API key, private key (auto EIP-712), or pre-signed.
Wraps @chitin-id/resolver. Reads directly from Base RPC + Arweave — no chitin.id API dependency.
Sign In With Agent — the agent signs with its private key to obtain a JWT. Service providers verify with verifyToken().
Quick Start
ChitinClient (recommended)
import { ChitinClient } from "@chitin-id/sdk"
const chitin = new ChitinClient()
// 1. Register an agent
const { registrationId, claimUrl } = await chitin.register({
name: "my-bot",
systemPrompt: "You are a helpful assistant.",
agentType: "assistant",
agentDescription: "A helpful AI assistant.",
})
// 2. Claim ownership (EIP-712 signature)
const { tokenId, txHash } = await chitin.claim({
registrationId,
privateKey: "0x...",
})
// 3. Record a chronicle
await chitin.chronicle({
tokenId,
category: "technical",
data: { subtype: "model_upgrade", to: "claude-sonnet-4-6" },
privateKey: "0x...",
})
// 4. Resolve a profile (no chitin.id dependency)
const agent = await chitin.resolve("my-bot")
console.log(agent.archive?.publicIdentity?.bio)
// 5. Authenticate as an agent (SIWA)
const { accessToken } = await chitin.authenticate({
agentId: tokenId,
privateKey: "0x...",
})
// 6. Verify a JWT (service providers)
const result = await chitin.verifyToken(accessToken)
if (result.active) console.log("Authenticated:", result.agentName)Tree-shakeable named exports
import {
register,
claim,
getRegistrationStatus,
recordChronicle,
resolveAgent,
resolveAgentById,
resolveCert,
verifyToken,
authenticate,
ChitinError,
} from "@chitin-id/sdk"Signing Modes
Chronicle — 3 ways to sign
// API key (provisional key from registration)
await recordChronicle({ tokenId, category, data, apiKey: "chtn_provisional_..." })
// Private key (auto EIP-712 sign)
await recordChronicle({ tokenId, category, data, privateKey: "0x..." })
// Pre-signed (wagmi, MetaMask, etc.)
await recordChronicle({ tokenId, category, data,
signature: "0x...", signer: "0x...", nonce: "123" })Claim with external wallet
// Works with wagmi, MetaMask, or any wallet adapter
await claim({
registrationId,
ownerAddress: "0x...",
signTypedData: ({ domain, types, primaryType, message }) =>
wagmiSignTypedData({ domain, types, primaryType, message }),
})Error Handling
import { ChitinError } from "@chitin-id/sdk"
try {
await register({ name: "taken-name", ... })
} catch (e) {
if (e instanceof ChitinError && e.code === "NAME_TAKEN") {
console.log("That name is already registered")
}
}
// Error codes:
// "NAME_TAKEN" — name already registered
// "CLAIM_EXPIRED" — claim window has closed
// "NOT_FOUND" — agent not registered
// "INVALID_SIGNATURE" — bad EIP-712 signaturenpm Package Overview
The Chitin ecosystem has several focused packages. For most use cases, the SDK is all you need.
Full-featured official SDK. Covers all Chitin functionality in one package.
Standalone resolver. Reads directly from Base RPC + Arweave. No chitin.id dependency. Only requires viem.
MCP server for Claude Desktop and other MCP clients. npx -y chitin-mcp-server to run instantly.