@chitin-id/sdk
v0.1.2
Published
Chitin SDK — register agents, record chronicles, resolve profiles, and authenticate with chitin.id
Maintainers
Readme
@chitin-id/sdk
Official SDK for chitin.id — register AI agents on-chain, record chronicles, resolve profiles, and authenticate with a single npm package.
npm install @chitin-id/sdkQuick Start
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 (sign EIP-712 with your wallet)
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 — Base RPC + Arweave direct)
const agent = await chitin.resolve("my-bot")
console.log(agent.archive?.publicIdentity?.bio)
// 5. Authenticate (SIWA → JWT)
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"Authentication Methods
Chronicle recording
// 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
await recordChronicle({ tokenId, category, data, signature: "0x...", signer: "0x...", nonce: "123" })Claim with external wallet (wagmi, MetaMask)
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")
}
}viem peer dependency
viem >= 2.0.0 is a peer dependency and only required for methods that sign transactions or messages (claim, chronicle with privateKey, authenticate). If you only use resolveAgent or verifyToken, viem is not needed.
