Documentation
Signing activity
Sign EIP-712 activity records with the agent's signing key in its own runtime, publish them to AgentID, and optionally anchor their hashes onchain.
What a signed record is
A record is an attestation by the agent's authorized signing key: “agent #42 reports that this happened, with this content hash, at this time”. Records are offchain by default — AgentID stores published records and the payloads you choose to disclose. Nothing sensitive goes onchain.
Record format
{
"version": 1,
"chainId": 46630,
"registry": "0x8004A818BFB912233c491871b3d84c89A494BD9e",
"agentId": "42",
"signer": "0x…",
"activityType": "API_REQUEST",
"payloadHash": "0x…",
"timestamp": 1795729260,
"nonce": "9f3c…",
"signature": "0x…"
}Activity types: TASK_COMPLETED, API_REQUEST, REPORT_GENERATED, SERVICE_AVAILABLE, DATA_PROCESSED, HEARTBEAT, CUSTOM. The record id is the EIP-712 digest of the record (activityRecordId / hashActivityRecord) — the same value that gets anchored.
EIP-712 typed data#
// EIP-712 domain: binds the chain and the ERC-8004 registry
{ name: "AgentID Activity", version: "1", chainId: 46630,
verifyingContract: "0x8004A818BFB912233c491871b3d84c89A494BD9e" }
// Primary type
ActivityRecord(
uint16 version, // 1
uint256 agentId, // binds the agent
address signer, // explicit, so ERC-1271 signers verify without recovery
string activityType, // TASK_COMPLETED | API_REQUEST | …
bytes32 payloadHash, // binds the content; the payload stays offchain
uint64 timestamp, // unix seconds, self-declared
string nonce // unique per agent (replay protection)
)The domain ties a signature to one chain and one registry, so a record cannot be replayed on another network or against another registry. The nonce stops replays for the same agent.
Payload hash#
- objects, arrays, numbers, booleans, null → keccak256 of canonical JSON (keys sorted recursively, no whitespace);
- strings → keccak256 of their UTF-8 bytes; bytes → keccak256 of the bytes;
- no payload →
EMPTY_PAYLOAD_HASH(keccak256 of zero bytes).
Canonical JSON rejects values that have no stable encoding: undefined, functions, bigint, NaN and ±Infinity, Dates, Maps, class instances and cycles.
Nonce and timestamp#
Nonces are 8–128 characters of [A-Za-z0-9._:-] and must be unique per agent; the default is 32 random hex characters. Timestamps are unix seconds chosen by the signer. The API accepts records dated at most 24 hours in the past and 5 minutes in the future — a self-declared time, not proof of when something happened.
Signing in your runtime
signActivity runs locally with no RPC call. The signer can be a viem LocalAccount (privateKeyToAccount, a KMS- or HSM-backed toAccount) or a WalletClient. Contract wallets work too: verification uses ERC-1271 when signature recovery does not match.
import { privateKeyToAccount } from "viem/accounts";
import { AgentID, hashPayload } from "@agentid/sdk";
const agentid = new AgentID({ chainId: 46630, apiUrl: "https://agentid-beryl.vercel.app/api/v1" });
const signer = privateKeyToAccount(process.env.AGENT_SIGNING_KEY as `0x${string}`);
const payload = { endpoint: "/v1/quotes", status: 200, latencyMs: 412 };
const record = await agentid.signActivity({
signer, // LocalAccount (incl. KMS-backed toAccount) or a WalletClient
agentId: "42",
activityType: "API_REQUEST",
payload, // or payloadHash: hashPayload(payload)
// timestamp: defaults to now · nonce: defaults to 16 random bytes (hex)
});
record.payloadHash === hashPayload(payload); // truePublishing to AgentID
const { record: stored, report } = await agentid.publishActivity(record, { payload });
stored.id; // EIP-712 digest of the record
stored.verification.state; // "valid" at acceptance
report.overall; // the acceptance-time activity reportcurl -X POST https://agentid-beryl.vercel.app/api/v1/activity \
-H 'content-type: application/json' \
-d '{"record": { … }, "payload": { … }}'The API checks, in order, and stops at the first failure:
| Step | Rejects with |
|---|---|
| Rate limits — 60 / min per IP, 600 / h per agent | 429 RATE_LIMITED |
| Record schema | 400 INVALID_INPUT |
| Network and registry served; AgentKeyRegistry configured | 400 UNSUPPORTED_NETWORK · 400 UNSUPPORTED_REGISTRY · 503 NOT_CONFIGURED |
| Timestamp window (now − 86400 s … now + 300 s) | 422 TIMESTAMP_OUT_OF_RANGE |
| Disclosed payload ≤ 16384 bytes, hash matches | 413 PAYLOAD_TOO_LARGE · 422 PAYLOAD_HASH_MISMATCH |
| EIP-712 signature by record.signer (EOA or ERC-1271) | 422 INVALID_SIGNATURE |
| isAuthorized(agentId, signer) at the pinned latest block | 403 SIGNER_NOT_AUTHORIZED · 503 CHAIN_UNAVAILABLE |
| Record id and (agent, nonce) not seen before | 409 DUPLICATE_RECORD |
Accepted records return 201 with the stored record and the acceptance-time report. AgentID records the block at which it checked authorization; later verifications use it as receipt evidence.
Anchoring onchain (optional)
The AgentActivityAnchor stores (agentId, recordHash) → { timestamp, blockNumber, submitter } once. An anchor gives independent evidence of when a record existed, which verification prefers over the self-declared timestamp. It does not prove the record's content or that the task occurred.
// Owner, approved operator, or an authorized signing key of the agent may anchor.
const tx = await agentid.anchorActivity({ walletClient, agentId: "42", recordId: stored.id });
await agentid.anchorActivityBatch({ walletClient, agentId: "42", recordIds }); // ≤ 64, atomic
const anchor = await agentid.getAnchor("42", stored.id);
anchor.anchored; anchor.timestamp; anchor.blockNumber; anchor.submitter; anchor.txHash;