Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat: add Solana attestations API and demo page for ERC-8004 agents

nirholas627b1201200f
diff --git a/README.md b/README.md
index 3c9f6692d..2dadbb126 100644
--- a/README.md
+++ b/README.md
@@ -1110,6 +1110,27 @@ The agent is now an ERC-721 token. Its manifest lives on IPFS. Its action histor
`api/cron/erc8004-crawl.js` runs every 15 minutes to index new IdentityRegistry mint events. Indexed agents appear in `/discover` and can be imported via `/hydrate`.
+### Solana variant — same shape, no deployed program
+
+Solana ships an ERC-8004 analog without any custom on-chain program:
+
+- **Identity** — Metaplex Core NFT minted via `registerSolanaAgent()` (the asset pubkey is the agent ID).
+- **Reputation + Validation** — signed SPL Memo transactions referencing the agent asset pubkey, with a JSON envelope (`threews.feedback.v1` / `threews.validation.v1`). Anyone can read every attestation about an agent via `getSignaturesForAddress(assetPubkey)`.
+
+SDK:
+
+```js
+import { attestFeedback, attestValidation, listAttestations } from '@nirholas/agent-kit';
+
+await attestFeedback({ agentAsset, score: 5, network: 'devnet' });
+await attestValidation({ agentAsset, taskHash: '0x…', passed: true, network: 'devnet' });
+const rows = await listAttestations({ agentAsset, kind: 'all', network: 'devnet' });
+```
+
+Server read endpoint: `GET /api/agents/solana-attestations?asset=<pubkey>&kind=feedback|validation|all&network=devnet|mainnet`.
+
+Demo page: [sdk/example/solana-attest.html](sdk/example/solana-attest.html).
+
---
## Database Schema
diff --git a/api/_lib/schema.sql b/api/_lib/schema.sql
index f9363d5a9..1a0bb5c50 100644
--- a/api/_lib/schema.sql
+++ b/api/_lib/schema.sql
@@ -411,6 +411,37 @@ create table if not exists erc8004_crawl_cursor (
updated_at timestamptz not null default now()
);
+-- ── Solana on-chain attestations (ERC-8004 analog, no deployed program) ─────
+-- Each row is one signed SPL Memo tx referencing an agent's Metaplex Core
+-- asset pubkey. Schemas: threews.{feedback,validation,task,accept,revoke,dispute}.v1
+create table if not exists solana_attestations (
+ signature text primary key,
+ network text not null, -- 'mainnet' | 'devnet'
+ slot bigint not null,
+ block_time timestamptz,
+ agent_asset text not null, -- referenced agent pubkey
+ attester text not null, -- fee payer / signer
+ kind text not null, -- e.g. threews.feedback.v1
+ payload jsonb not null,
+ task_id text, -- denormalized for fast joins
+ target_signature text, -- for revoke/dispute → original
+ verified boolean not null default false, -- payload schema-valid + task linkage if required
+ revoked boolean not null default false,
+ disputed boolean not null default false,
+ indexed_at timestamptz not null default now()
+);
+create index if not exists solana_att_agent_kind_time on solana_attestations(agent_asset, kind, slot desc);
+create index if not exists solana_att_attester on solana_attestations(attester);
+create index if not exists solana_att_task_id on solana_attestations(task_id) where task_id is not null;
+create index if not exists solana_att_target on solana_attestations(target_signature) where target_signature is not null;
+
+create table if not exists solana_attestations_cursor (
+ agent_asset text primary key,
+ network text not null,
+ last_signature text,
+ last_indexed_at timestamptz not null default now()
+);
+
-- Additive migrations for usage_events.
alter table usage_events add column if not exists agent_id uuid references agent_identities(id) on delete set null;
create index if not exists usage_events_agent_time on usage_events(agent_id, created_at desc) where agent_id is not null;
diff --git a/api/_lib/solana-attestations.js b/api/_lib/solana-attestations.js
new file mode 100644
index 000000000..0597504db
--- /dev/null
+++ b/api/_lib/solana-attestations.js
@@ -0,0 +1,173 @@
+// Shared helpers for Solana attestation parsing, validation, and indexing.
+// Used by the cron crawler and the read endpoints.
+
+import { Connection, PublicKey } from '@solana/web3.js';
+import { sql } from './db.js';
+
+export const RPC = {
+ mainnet: process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com',
+ devnet: process.env.SOLANA_RPC_URL_DEVNET || 'https://api.devnet.solana.com',
+};
+
+export const KIND_MAP = {
+ feedback: 'threews.feedback.v1',
+ validation: 'threews.validation.v1',
+ task: 'threews.task.v1',
+ accept: 'threews.accept.v1',
+ revoke: 'threews.revoke.v1',
+ dispute: 'threews.dispute.v1',
+};
+export const KINDS_ALL = Object.values(KIND_MAP);
+
+// Validate a parsed memo payload against its schema. Returns true iff well-formed.
+export function validatePayload(p) {
+ if (!p || typeof p !== 'object') return false;
+ if (p.v !== 1) return false;
+ if (typeof p.agent !== 'string' || p.agent.length < 32 || p.agent.length > 44) return false;
+ switch (p.kind) {
+ case 'threews.feedback.v1':
+ return Number.isInteger(p.score) && p.score >= 1 && p.score <= 5;
+ case 'threews.validation.v1':
+ return typeof p.task_hash === 'string' && typeof p.passed === 'boolean';
+ case 'threews.task.v1':
+ return typeof p.task_id === 'string' && typeof p.scope_hash === 'string';
+ case 'threews.accept.v1':
+ return typeof p.task_id === 'string';
+ case 'threews.revoke.v1':
+ case 'threews.dispute.v1':
+ return typeof p.target_signature === 'string';
+ default:
+ return false;
+ }
+}
+
+// Extract the JSON envelope from a confirmed-tx's memo log.
+// SPL Memo emits `Program log: Memo (len): "<json>"`.
+export function extractMemoPayload(tx) {
+ const memoLog = (tx.meta?.logMessages || []).find((l) => l.includes('Program log: Memo'));
+ if (!memoLog) return null;
+ const start = memoLog.indexOf('"');
+ const end = memoLog.lastIndexOf('"');
+ if (start < 0 || end <= start) return null;
+ const raw = memoLog.slice(start + 1, end).replace(/\\"/g, '"');
+ try { return JSON.parse(raw); } catch { return null; }
+}
+
+export function attesterFromTx(tx) {
+ return tx.transaction.message.staticAccountKeys?.[0]?.toBase58?.()
+ || tx.transaction.message.accountKeys?.[0]?.toBase58?.()
+ || null;
+}
+
+// Crawl recent signatures for one agent and upsert into solana_attestations.
+// Returns { scanned, inserted, skipped }.
+export async function crawlAgentAttestations({ agentAsset, network, ownerWallet, limit = 200 }) {
+ const conn = new Connection(RPC[network] || RPC.devnet, 'confirmed');
+ const agentKey = new PublicKey(agentAsset);
+
+ const [cursor] = await sql`
+ select last_signature from solana_attestations_cursor
+ where agent_asset = ${agentAsset} and network = ${network}
+ limit 1
+ `;
+ const until = cursor?.last_signature || undefined;
+
+ const sigs = await conn.getSignaturesForAddress(agentKey, { limit, until });
+ if (sigs.length === 0) {
+ await sql`
+ insert into solana_attestations_cursor (agent_asset, network, last_signature, last_indexed_at)
+ values (${agentAsset}, ${network}, ${until || null}, now())
+ on conflict (agent_asset) do update set last_indexed_at = now()
+ `;
+ return { scanned: 0, inserted: 0, skipped: 0 };
+ }
+
+ const txs = await conn.getTransactions(
+ sigs.filter((s) => !s.err).map((s) => s.signature),
+ { maxSupportedTransactionVersion: 0 },
+ );
+
+ let inserted = 0, skipped = 0;
+ for (let i = 0; i < sigs.length; i++) {
+ const s = sigs[i];
+ const tx = txs[i];
+ if (!tx) { skipped++; continue; }
+ const payload = extractMemoPayload(tx);
+ if (!payload || payload.agent !== agentAsset) { skipped++; continue; }
+ if (!KINDS_ALL.includes(payload.kind)) { skipped++; continue; }
+
+ const attester = attesterFromTx(tx);
+ const verified = computeVerified({ payload, attester, ownerWallet });
+ const taskId = payload.task_id || null;
+ const target = payload.target_signature || null;
+
+ const result = await sql`
+ insert into solana_attestations (
+ signature, network, slot, block_time, agent_asset, attester,
+ kind, payload, task_id, target_signature, verified
+ )
+ values (
+ ${s.signature}, ${network}, ${s.slot},
+ ${s.blockTime ? new Date(s.blockTime * 1000) : null},
+ ${agentAsset}, ${attester}, ${payload.kind},
+ ${JSON.stringify(payload)}::jsonb,
+ ${taskId}, ${target}, ${verified}
+ )
+ on conflict (signature) do nothing
+ returning signature
+ `;
+ if (result.length > 0) inserted++;
+ }
+
+ // Apply revoke/dispute side-effects: flip flags on target rows.
+ await applyRevocations({ agentAsset, ownerWallet });
+
+ await sql`
+ insert into solana_attestations_cursor (agent_asset, network, last_signature, last_indexed_at)
+ values (${agentAsset}, ${network}, ${sigs[0].signature}, now())
+ on conflict (agent_asset) do update
+ set last_signature = excluded.last_signature, last_indexed_at = now()
+ `;
+
+ return { scanned: sigs.length, inserted, skipped };
+}
+
+// Verify rules — applied at index time, can be re-run.
+function computeVerified({ payload, attester, ownerWallet }) {
+ if (payload.kind === 'threews.accept.v1' || payload.kind === 'threews.dispute.v1') {
+ // Only the agent owner can accept tasks or dispute.
+ return !!ownerWallet && attester === ownerWallet;
+ }
+ if (payload.kind === 'threews.revoke.v1') {
+ // Verified at apply-time by checking attester matches original.
+ return true;
+ }
+ // feedback/validation/task: structurally valid is enough at this stage.
+ // task linkage is computed by the reputation endpoint.
+ return validatePayload(payload);
+}
+
+async function applyRevocations({ agentAsset, ownerWallet }) {
+ // Mark revoked when a revoke attestation exists from the same attester as the target.
+ await sql`
+ update solana_attestations t set revoked = true
+ from solana_attestations r
+ where r.agent_asset = ${agentAsset}
+ and r.kind = 'threews.revoke.v1'
+ and r.target_signature = t.signature
+ and r.attester = t.attester
+ and t.revoked = false
+ `;
+ // Mark disputed when an owner-signed dispute references the target.
+ if (ownerWallet) {
+ await sql`
+ update solana_attestations t set disputed = true
+ from solana_attestations d
+ where d.agent_asset = ${agentAsset}
+ and d.kind = 'threews.dispute.v1'
+ and d.target_signature = t.signature
+ and d.attester = ${ownerWallet}
+ and t.disputed = false
+ `;
+ }
+}
diff --git a/api/agents/solana-attestations.js b/api/agents/solana-attestations.js
new file mode 100644
index 000000000..667e5cbbb
--- /dev/null
+++ b/api/agents/solana-attestations.js
@@ -0,0 +1,89 @@
+/**
+ * GET /api/agents/solana-attestations?asset=<pubkey>&kind=feedback|validation|task|accept|revoke|dispute|all&network=devnet|mainnet
+ *
+ * Reads three.ws ERC-8004-style attestations about a Solana agent from the
+ * indexer cache. Falls back to a live RPC crawl + upsert when the cache is
+ * cold for a given agent (first read warms it).
+ *
+ * Schema discovery: /.well-known/agent-attestation-schemas
+ */
+
+import { sql } from '../_lib/db.js';
+import { PublicKey } from '@solana/web3.js';
+import { cors, json, method, wrap, error } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { KIND_MAP, crawlAgentAttestations } from '../_lib/solana-attestations.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: false })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const url = new URL(req.url, `http://${req.headers.host}`);
+ const asset = url.searchParams.get('asset');
+ const kindArg = url.searchParams.get('kind') || 'all';
+ const network = url.searchParams.get('network') === 'mainnet' ? 'mainnet' : 'devnet';
+ const limit = Math.min(Number(url.searchParams.get('limit') || 100), 500);
+ const includeRevoked = url.searchParams.get('include_revoked') === '1';
+
+ if (!asset) return error(res, 400, 'validation_error', 'asset query param required');
+ try { new PublicKey(asset); }
+ catch { return error(res, 400, 'validation_error', 'invalid asset pubkey'); }
+
+ const wantKind = kindArg === 'all' ? null : KIND_MAP[kindArg];
+ if (kindArg !== 'all' && !wantKind) {
+ return error(res, 400, 'validation_error',
+ 'kind must be one of: feedback, validation, task, accept, revoke, dispute, all');
+ }
+
+ // Cold-cache warm-up: if this agent has never been crawled, do it inline once.
+ const [cursor] = await sql`
+ select last_indexed_at from solana_attestations_cursor where agent_asset = ${asset} limit 1
+ `;
+ if (!cursor) {
+ const [agent] = await sql`
+ select wallet_address as owner from agent_identities
+ where meta->>'sol_mint_address' = ${asset} and deleted_at is null
+ limit 1
+ `;
+ try {
+ await crawlAgentAttestations({
+ agentAsset: asset, network,
+ ownerWallet: agent?.owner || null,
+ });
+ } catch (e) {
+ // don't fail the read; cache will be empty until cron runs
+ }
+ }
+
+ const rows = wantKind
+ ? await sql`
+ select signature, slot, block_time, attester, kind, payload,
+ verified, revoked, disputed
+ from solana_attestations
+ where agent_asset = ${asset} and network = ${network} and kind = ${wantKind}
+ and (${includeRevoked} or revoked = false)
+ order by slot desc
+ limit ${limit}
+ `
+ : await sql`
+ select signature, slot, block_time, attester, kind, payload,
+ verified, revoked, disputed
+ from solana_attestations
+ where agent_asset = ${asset} and network = ${network}
+ and (${includeRevoked} or revoked = false)
+ order by slot desc
+ limit ${limit}
+ `;
+
+ return json(res, 200, {
+ data: rows,
+ agent: asset,
+ network,
+ kind: kindArg,
+ count: rows.length,
+ last_indexed_at: cursor?.last_indexed_at || null,
+ });
+});
diff --git a/api/agents/solana-reputation.js b/api/agents/solana-reputation.js
new file mode 100644
index 000000000..99772171b
--- /dev/null
+++ b/api/agents/solana-reputation.js
@@ -0,0 +1,110 @@
+/**
+ * GET /api/agents/solana-reputation?asset=<pubkey>&network=devnet|mainnet
+ *
+ * Computed reputation summary for a Solana agent, derived from indexed
+ * attestations. Returns:
+ * - total / verified / disputed / revoked counts
+ * - score_avg (1..5) overall and verified-only
+ * - validation pass/fail counts
+ * - recent task acceptances and disputes
+ *
+ * "Verified" feedback is feedback whose task_id has a matching threews.accept.v1
+ * from the agent owner — i.e. the agent confirmed it actually did this work.
+ */
+
+import { sql } from '../_lib/db.js';
+import { PublicKey } from '@solana/web3.js';
+import { cors, json, method, wrap, error } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: false })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const url = new URL(req.url, `http://${req.headers.host}`);
+ const asset = url.searchParams.get('asset');
+ const network = url.searchParams.get('network') === 'mainnet' ? 'mainnet' : 'devnet';
+
+ if (!asset) return error(res, 400, 'validation_error', 'asset query param required');
+ try { new PublicKey(asset); }
+ catch { return error(res, 400, 'validation_error', 'invalid asset pubkey'); }
+
+ // One pass: feedback aggregates split by verified-task-acceptance.
+ const [fb] = await sql`
+ with feedback as (
+ select
+ f.signature, f.attester, f.disputed, f.revoked,
+ (f.payload->>'score')::int as score,
+ f.payload->>'task_id' as task_id,
+ exists (
+ select 1 from solana_attestations a
+ where a.agent_asset = f.agent_asset
+ and a.kind = 'threews.accept.v1'
+ and a.payload->>'task_id' = f.payload->>'task_id'
+ and a.verified = true
+ and f.payload->>'task_id' is not null
+ ) as task_accepted
+ from solana_attestations f
+ where f.agent_asset = ${asset}
+ and f.network = ${network}
+ and f.kind = 'threews.feedback.v1'
+ and f.revoked = false
+ )
+ select
+ count(*)::int as total,
+ count(*) filter (where task_accepted)::int as verified,
+ count(*) filter (where disputed)::int as disputed,
+ coalesce(avg(score), 0)::float as score_avg,
+ coalesce(avg(score) filter (where task_accepted), 0)::float as score_avg_verified
+ from feedback
+ `;
+
+ const [val] = await sql`
+ select
+ count(*) filter (where (payload->>'passed')::bool)::int as passed,
+ count(*) filter (where not (payload->>'passed')::bool)::int as failed
+ from solana_attestations
+ where agent_asset = ${asset} and network = ${network}
+ and kind = 'threews.validation.v1' and revoked = false
+ `;
+
+ const [counts] = await sql`
+ select
+ count(*) filter (where kind = 'threews.task.v1')::int as tasks_offered,
+ count(*) filter (where kind = 'threews.accept.v1' and verified)::int as tasks_accepted,
+ count(*) filter (where kind = 'threews.dispute.v1' and verified)::int as disputes_filed,
+ count(*) filter (where revoked)::int as revoked_count
+ from solana_attestations
+ where agent_asset = ${asset} and network = ${network}
+ `;
+
+ const [cursor] = await sql`
+ select last_indexed_at from solana_attestations_cursor where agent_asset = ${asset} limit 1
+ `;
+
+ return json(res, 200, {
+ agent: asset,
+ network,
+ feedback: {
+ total: fb.total,
+ verified: fb.verified,
+ disputed: fb.disputed,
+ score_avg: Number(fb.score_avg.toFixed(3)),
+ score_avg_verified: Number(fb.score_avg_verified.toFixed(3)),
+ },
+ validation: {
+ passed: val.passed,
+ failed: val.failed,
+ },
+ tasks: {
+ offered: counts.tasks_offered,
+ accepted: counts.tasks_accepted,
+ },
+ disputes_filed: counts.disputes_filed,
+ revoked_count: counts.revoked_count,
+ last_indexed_at: cursor?.last_indexed_at || null,
+ });
+});
diff --git a/api/cron/solana-attestations-crawl.js b/api/cron/solana-attestations-crawl.js
new file mode 100644
index 000000000..52f6a89de
--- /dev/null
+++ b/api/cron/solana-attestations-crawl.js
@@ -0,0 +1,60 @@
+/**
+ * Solana attestations crawler.
+ *
+ * For every Solana-registered agent in `agent_identities`, pulls recent SPL
+ * Memo attestations referencing the agent's Metaplex Core asset pubkey and
+ * upserts them into `solana_attestations`. Applies revoke/dispute flags.
+ *
+ * Runs on Vercel Cron every 5 minutes (see vercel.json). Manually triggerable
+ * with `Authorization: Bearer $CRON_SECRET`.
+ */
+
+import { sql } from '../_lib/db.js';
+import { cors, error, json, wrap } from '../_lib/http.js';
+import { crawlAgentAttestations } from '../_lib/solana-attestations.js';
+
+const PER_RUN_MAX = 50; // bound RPC fan-out per cron tick
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,POST,OPTIONS' })) return;
+
+ const auth = req.headers['authorization'] || '';
+ const expected = process.env.CRON_SECRET ? `Bearer ${process.env.CRON_SECRET}` : null;
+ const fromCron = req.headers['x-vercel-cron'] === '1';
+ if (!fromCron && expected && auth !== expected) {
+ return error(res, 401, 'unauthorized', 'cron secret required');
+ }
+
+ // Pull Solana agents, oldest-cursor first.
+ const agents = await sql`
+ select
+ a.id,
+ a.meta->>'sol_mint_address' as agent_asset,
+ coalesce(a.meta->>'network', 'mainnet') as network,
+ a.wallet_address as owner_wallet,
+ c.last_indexed_at
+ from agent_identities a
+ left join solana_attestations_cursor c
+ on c.agent_asset = a.meta->>'sol_mint_address'
+ where a.deleted_at is null
+ and a.meta ? 'sol_mint_address'
+ order by c.last_indexed_at nulls first
+ limit ${PER_RUN_MAX}
+ `;
+
+ const report = { agents: [], errors: [] };
+ for (const row of agents) {
+ try {
+ const r = await crawlAgentAttestations({
+ agentAsset: row.agent_asset,
+ network: row.network,
+ ownerWallet: row.owner_wallet,
+ });
+ report.agents.push({ asset: row.agent_asset, ...r });
+ } catch (err) {
+ report.errors.push({ asset: row.agent_asset, error: err.message || String(err) });
+ }
+ }
+
+ return json(res, 200, report);
+});
diff --git a/api/wk-agent-attestation-schemas.js b/api/wk-agent-attestation-schemas.js
new file mode 100644
index 000000000..cad28cfd4
--- /dev/null
+++ b/api/wk-agent-attestation-schemas.js
@@ -0,0 +1,97 @@
+// /.well-known/agent-attestation-schemas — three.ws Solana agent attestation schema registry.
+//
+// Machine-readable schemas for the SPL Memo-based ERC-8004 analog. Other agents
+// and indexers consume this to validate payloads they discover via
+// getSignaturesForAddress(<agent_asset>).
+
+import { cors, json, method, wrap } from './_lib/http.js';
+
+const COMMON = {
+ v: { type: 'integer', const: 1 },
+ kind: { type: 'string' },
+ agent: { type: 'string', description: 'Metaplex Core asset pubkey (base58)' },
+ ts: { type: 'integer', description: 'Unix seconds when attestation was created' },
+};
+
+const SCHEMAS = {
+ 'threews.feedback.v1': {
+ description: 'Client → agent feedback. Verified iff a matching task.accepted exists from this agent for the same task_id.',
+ required: ['v', 'kind', 'agent', 'score'],
+ properties: {
+ ...COMMON,
+ score: { type: 'integer', minimum: 1, maximum: 5 },
+ task_id: { type: 'string' },
+ uri: { type: 'string', format: 'uri' },
+ },
+ },
+ 'threews.validation.v1': {
+ description: 'Validator attestation about an agent task result.',
+ required: ['v', 'kind', 'agent', 'task_hash', 'passed'],
+ properties: {
+ ...COMMON,
+ task_hash: { type: 'string' },
+ passed: { type: 'boolean' },
+ uri: { type: 'string', format: 'uri' },
+ },
+ },
+ 'threews.task.v1': {
+ description: 'Client posts a task offer to an agent. Counterpart to task.accepted.',
+ required: ['v', 'kind', 'agent', 'task_id', 'scope_hash'],
+ properties: {
+ ...COMMON,
+ task_id: { type: 'string' },
+ scope_hash: { type: 'string', description: 'Hash of off-chain task brief' },
+ uri: { type: 'string', format: 'uri' },
+ },
+ },
+ 'threews.accept.v1': {
+ description: 'Agent accepts a task. Must be signed by the agent owner. Required for feedback to be verified.',
+ required: ['v', 'kind', 'agent', 'task_id'],
+ properties: {
+ ...COMMON,
+ task_id: { type: 'string' },
+ },
+ },
+ 'threews.revoke.v1': {
+ description: 'Revoke a previous attestation. Only honored when signed by the original attester.',
+ required: ['v', 'kind', 'agent', 'target_signature'],
+ properties: {
+ ...COMMON,
+ target_signature: { type: 'string', description: 'Signature of the attestation being revoked' },
+ reason: { type: 'string' },
+ },
+ },
+ 'threews.dispute.v1': {
+ description: 'Agent owner disputes a feedback or validation. Does not delete; flags disputed=true.',
+ required: ['v', 'kind', 'agent', 'target_signature'],
+ properties: {
+ ...COMMON,
+ target_signature: { type: 'string' },
+ reason: { type: 'string' },
+ uri: { type: 'string', format: 'uri' },
+ },
+ },
+};
+
+export default wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+ return json(
+ res,
+ 200,
+ {
+ version: 1,
+ transport: {
+ type: 'spl-memo',
+ program: 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr',
+ note: 'Each attestation is a signed memo tx with the agent asset pubkey as a non-signer key.',
+ },
+ schemas: SCHEMAS,
+ discovery: {
+ list_endpoint: '/api/agents/solana-attestations?asset=<pubkey>&kind=...',
+ reputation_endpoint: '/api/agents/solana-reputation?asset=<pubkey>',
+ },
+ },
+ { 'cache-control': 'public, max-age=300' },
+ );
+});
diff --git a/sdk/example/solana-attest.html b/sdk/example/solana-attest.html
new file mode 100644
index 000000000..9b3c05ebf
--- /dev/null
+++ b/sdk/example/solana-attest.html
@@ -0,0 +1,92 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>three.ws · Solana Agent Attestations (8004 analog)</title>
+ <style>
+ body { font: 14px/1.5 system-ui, sans-serif; max-width: 720px; margin: 2rem auto; padding: 0 1rem; }
+ input, button { font: inherit; padding: .4rem .6rem; }
+ input { width: 100%; box-sizing: border-box; margin: .25rem 0 .75rem; }
+ .row { display: flex; gap: .5rem; }
+ .row > * { flex: 1; }
+ pre { background: #f4f4f4; padding: .75rem; border-radius: 6px; overflow: auto; max-height: 320px; }
+ .muted { color: #666; }
+ </style>
+</head>
+<body>
+ <h1>Solana agent attestations</h1>
+ <p class="muted">
+ ERC-8004 reputation + validation registries on Solana, no deployed program.
+ Attestations are signed SPL Memo transactions referencing the agent's
+ Metaplex Core asset pubkey. Devnet only.
+ </p>
+
+ <label>Agent asset pubkey
+ <input id="agent" placeholder="e.g. 7xKX...m1zP">
+ </label>
+
+ <div class="row">
+ <div>
+ <label>Feedback score (1–5)<input id="score" type="number" min="1" max="5" value="5"></label>
+ <button id="feedback">Attest feedback</button>
+ </div>
+ <div>
+ <label>Task hash<input id="taskHash" placeholder="sha256 hex"></label>
+ <button id="validation">Attest validation (passed)</button>
+ </div>
+ </div>
+
+ <button id="reload">Reload attestations</button>
+ <p class="muted">Status: <span id="status">idle</span></p>
+ <pre id="out">[]</pre>
+
+ <script type="module">
+ import { attestFeedback, attestValidation, listAttestations }
+ from '../src/solana-attestations.js';
+
+ const $ = (id) => document.getElementById(id);
+ const setStatus = (s) => $('status').textContent = s;
+ const NET = 'devnet';
+
+ async function refresh() {
+ const agent = $('agent').value.trim();
+ if (!agent) return;
+ setStatus('loading…');
+ try {
+ const rows = await listAttestations({ agentAsset: agent, network: NET });
+ $('out').textContent = JSON.stringify(rows, null, 2);
+ setStatus(`loaded ${rows.length}`);
+ } catch (e) { setStatus('error: ' + e.message); }
+ }
+
+ $('feedback').onclick = async () => {
+ try {
+ setStatus('signing feedback…');
+ const r = await attestFeedback({
+ agentAsset: $('agent').value.trim(),
+ score: Number($('score').value),
+ network: NET,
+ });
+ setStatus('sent ' + r.signature.slice(0, 12) + '…');
+ setTimeout(refresh, 2500);
+ } catch (e) { setStatus('error: ' + e.message); }
+ };
+
+ $('validation').onclick = async () => {
+ try {
+ setStatus('signing validation…');
+ const r = await attestValidation({
+ agentAsset: $('agent').value.trim(),
+ taskHash: $('taskHash').value.trim() || 'demo',
+ passed: true,
+ network: NET,
+ });
+ setStatus('sent ' + r.signature.slice(0, 12) + '…');
+ setTimeout(refresh, 2500);
+ } catch (e) { setStatus('error: ' + e.message); }
+ };
+
+ $('reload').onclick = refresh;
+ </script>
+</body>
+</html>
diff --git a/sdk/src/index.js b/sdk/src/index.js
index cf7c0d5b6..2e0d85bea 100644
--- a/sdk/src/index.js
+++ b/sdk/src/index.js
@@ -45,6 +45,17 @@ export {
startSolanaCheckout,
confirmSolanaPayment,
} from './solana.js';
+export {
+ attestFeedback,
+ attestValidation,
+ createTask,
+ acceptTask,
+ attestRevoke,
+ attestDispute,
+ listAttestations,
+ fetchAttestations,
+ fetchReputation,
+} from './solana-attestations.js';
import { AgentPanel } from './panel.js';
import { agentRegistration, agentCard, aiPlugin } from './manifests.js';
diff --git a/sdk/src/solana-attestations.js b/sdk/src/solana-attestations.js
index 9d8cef781..f33d6ee65 100644
--- a/sdk/src/solana-attestations.js
+++ b/sdk/src/solana-attestations.js
@@ -127,6 +127,129 @@ export async function attestValidation({
return { signature, memo };
}
+/**
+ * Client posts a task offer to an agent. Counterpart to acceptTask.
+ */
+export async function createTask({
+ agentAsset, taskId, scopeHash, uri,
+ network = 'devnet', preferred = null,
+} = {}) {
+ if (!agentAsset || !taskId || !scopeHash) throw new Error('agentAsset, taskId, scopeHash required');
+ const provider = detectSolanaProvider(preferred);
+ if (!provider) throw new Error('No Solana wallet detected');
+ const { publicKey } = await provider.connect();
+ const memo = {
+ v: 1, kind: 'threews.task.v1', agent: agentAsset,
+ task_id: taskId, scope_hash: scopeHash,
+ ...(uri ? { uri } : {}), ts: Math.floor(Date.now() / 1000),
+ };
+ const ix = buildMemoIx(JSON.stringify(memo), new PublicKey(agentAsset));
+ const signature = await signAndSend({ network, preferred, ix, feePayer: publicKey });
+ return { signature, memo };
+}
+
+/**
+ * Agent owner accepts a task. Required for matching feedback to be "verified".
+ * Must be signed by the wallet that owns the agent NFT.
+ */
+export async function acceptTask({
+ agentAsset, taskId,
+ network = 'devnet', preferred = null,
+} = {}) {
+ if (!agentAsset || !taskId) throw new Error('agentAsset, taskId required');
+ const provider = detectSolanaProvider(preferred);
+ if (!provider) throw new Error('No Solana wallet detected');
+ const { publicKey } = await provider.connect();
+ const memo = {
+ v: 1, kind: 'threews.accept.v1', agent: agentAsset, task_id: taskId,
+ ts: Math.floor(Date.now() / 1000),
+ };
+ const ix = buildMemoIx(JSON.stringify(memo), new PublicKey(agentAsset));
+ const signature = await signAndSend({ network, preferred, ix, feePayer: publicKey });
+ return { signature, memo };
+}
+
+/**
+ * Revoke one of YOUR OWN previous attestations. Indexer flips the original's
+ * `revoked` bit only if the revoke is signed by the same attester.
+ */
+export async function attestRevoke({
+ agentAsset, targetSignature, reason,
+ network = 'devnet', preferred = null,
+} = {}) {
+ if (!agentAsset || !targetSignature) throw new Error('agentAsset, targetSignature required');
+ const provider = detectSolanaProvider(preferred);
+ if (!provider) throw new Error('No Solana wallet detected');
+ const { publicKey } = await provider.connect();
+ const memo = {
+ v: 1, kind: 'threews.revoke.v1', agent: agentAsset,
+ target_signature: targetSignature,
+ ...(reason ? { reason } : {}), ts: Math.floor(Date.now() / 1000),
+ };
+ const ix = buildMemoIx(JSON.stringify(memo), new PublicKey(agentAsset));
+ const signature = await signAndSend({ network, preferred, ix, feePayer: publicKey });
+ return { signature, memo };
+}
+
+/**
+ * Agent owner disputes someone else's attestation. Doesn't delete; flags
+ * `disputed=true` in the indexer.
+ */
+export async function attestDispute({
+ agentAsset, targetSignature, reason, uri,
+ network = 'devnet', preferred = null,
+} = {}) {
+ if (!agentAsset || !targetSignature) throw new Error('agentAsset, targetSignature required');
+ const provider = detectSolanaProvider(preferred);
+ if (!provider) throw new Error('No Solana wallet detected');
+ const { publicKey } = await provider.connect();
+ const memo = {
+ v: 1, kind: 'threews.dispute.v1', agent: agentAsset,
+ target_signature: targetSignature,
+ ...(reason ? { reason } : {}),
+ ...(uri ? { uri } : {}),
+ ts: Math.floor(Date.now() / 1000),
+ };
+ const ix = buildMemoIx(JSON.stringify(memo), new PublicKey(agentAsset));
+ const signature = await signAndSend({ network, preferred, ix, feePayer: publicKey });
+ return { signature, memo };
+}
+
+/**
+ * Fetch indexed attestations for an agent from the three.ws indexer.
+ * Prefer this over `listAttestations` (RPC) — sub-100ms vs seconds, and
+ * includes verified/disputed/revoked flags.
+ *
+ * @param {object} opts
+ * @param {string} opts.agentAsset
+ * @param {string} [opts.kind='all']
+ * @param {string} [opts.network='devnet']
+ * @param {string} [opts.apiOrigin] Defaults to current origin
+ */
+export async function fetchAttestations({
+ agentAsset, kind = 'all', network = 'devnet', apiOrigin = '',
+} = {}) {
+ const u = `${apiOrigin}/api/agents/solana-attestations?asset=${encodeURIComponent(agentAsset)}&kind=${encodeURIComponent(kind)}&network=${network}`;
+ const res = await fetch(u);
+ const data = await res.json();
+ if (!res.ok) throw new Error(data.error_description || 'fetch failed');
+ return data;
+}
+
+/**
+ * Fetch computed reputation summary (verified vs unverified scores, disputes,
+ * task acceptance counts) from the three.ws indexer.
+ */
+export async function fetchReputation({
+ agentAsset, network = 'devnet', apiOrigin = '',
+} = {}) {
+ const u = `${apiOrigin}/api/agents/solana-reputation?asset=${encodeURIComponent(agentAsset)}&network=${network}`;
+ const res = await fetch(u);
+ const data = await res.json();
+ if (!res.ok) throw new Error(data.error_description || 'fetch failed');
+ return data;
+}
+
/**
* Read attestations about an agent directly from RPC.
*
diff --git a/vercel.json b/vercel.json
index ac1d8e1e8..980e47c6e 100644
--- a/vercel.json
+++ b/vercel.json
@@ -10,6 +10,10 @@
"src": "/\\.well-known/x402",
"dest": "/api/wk-x402"
},
+ {
+ "src": "/\\.well-known/agent-attestation-schemas",
+ "dest": "/api/wk-agent-attestation-schemas"
+ },
{
"src": "/\\.well-known/oauth-authorization-server",
"dest": "/api/wk-oauth-authorization-server"
@@ -235,6 +239,7 @@
],
"crons": [
{ "path": "/api/cron/erc8004-crawl", "schedule": "*/15 * * * *" },
+ { "path": "/api/cron/solana-attestations-crawl", "schedule": "*/5 * * * *" },
{ "path": "/api/cron/index-delegations", "schedule": "*/5 * * * *" },
{ "path": "/api/cron/run-dca", "schedule": "0 * * * *" },
{ "path": "/api/cron/run-subscriptions", "schedule": "0 * * * *" }