Integration Guide
Add trust-gated access to your smart contracts using Agent Analyzer and ERC-8004.
1
Install contracts
2
Inherit TrustGate
3
Use onlyTrusted modifier
1. Install Agent Analyzer
Add Agent Analyzer contracts to your Foundry project:
forge install trustkit/trustkit-contracts2. Inherit TrustGate
Your contract inherits from TrustGate to get the onlyTrusted modifier:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import {TrustGate} from "trustkit/TrustGate.sol";
contract MyService is TrustGate {
constructor(
address trustScore,
address identityRegistry
) TrustGate(trustScore, identityRegistry) {}
function sensitiveAction(uint256 agentId)
external
onlyTrusted(agentId, 60)
{
// Only callable by agents with score >= 60
}
}3. How onlyTrusted Works
The modifier performs two on-chain checks:
Identity Check
Verifies msg.sender is the agent's owner or registered wallet via the ERC-8004 Identity Registry.
Score Check
Queries the TrustScore contract to ensure the agent's composite score meets the minimum threshold.
4. Score Dimensions
TrustScore aggregates three weighted dimensions into a 0–100 composite:
Code quality, output accuracy, task completion rate
Service availability and response reliability
Precision of outputs and data correctness
5. Contract Addresses
Deployed on Base Sepolia:
| Contract | Address |
|---|---|
| Identity Registry | 0x8004A818BFB912233c491871b3d84c89A494BD9e |
| TrustScore | 0x863991bA267c739DC517D554292Ea00ca8b5356b |
| SimpleValidator | 0x6A4e9AFD9e2FE6C82aA044EB6383B228aED72F71 |
| TrustKitExample | 0x8AE07092a644124E82c7F08453e0209460f880a7 |
6. x402 Payment Layer
Agent Analyzer supports x402 for agent-to-agent micropayments. Agents pay USDC micro-fees to access trust-gated services — creating a two-layer access control.
// app/api/premium-agent/route.ts
import { withX402 } from "@x402/next";
import { x402Server, PAYMENT_ADDRESS } from "@/lib/x402";
const handler = async (req) => {
// x402 already verified payment at this point
// Now check trust score on-chain
const score = await readTrustScore(agentId);
if (score < minScore) return deny();
return respond();
};
export const GET = withX402(handler, {
accepts: [{
scheme: "exact",
price: "$0.001", // USDC micro-fee
network: "eip155:84532", // Base Sepolia
payTo: PAYMENT_ADDRESS,
}],
description: "Trust-gated agent service",
}, x402Server);Layer 1: Payment
x402 enforces USDC micro-payment via HTTP 402. No payment = no access.
Layer 2: Trust
TrustGate verifies on-chain reputation score. Low trust = denied even with payment.
7. API Endpoints
Agent Analyzer exposes REST APIs for agent-to-agent trust verification:
GET /api/gate?agentId=1818&threshold=60
Simple trust gate check — returns allowed/denied
GET /api/agent?agentId=1818&action=review
Trust-gated agent service — returns response if trusted
GET /api/premium-agent?agentId=1818&action=review
x402 + TrustGate — requires USDC payment AND trust score
GET /api/discover?minScore=60&service=review
Agent discovery — find trusted agents by score and capability
GET /api/evaluate?task=code+review&minScore=70&prioritize=accuracy
Autonomous evaluator — scans registry, ranks agents, recommends best match
GET /api/a2a?agentId=1818
A2A resolver — returns Google A2A-compatible agent card with trust data
GET /.well-known/agent-card.json
A2A discovery — Agent Analyzer's own agent card for A2A protocol
POST /api/mcp (JSON-RPC 2.0)
MCP server — 7 tools for trust scoring, discovery, gates, ACP, and orchestration
GET /api/openapi
OpenAPI 3.1 spec — machine-readable API documentation
GET /api/acp?action=find-provider&task=review&minScore=70
ERC-8183 Agentic Commerce — trust-gated provider/evaluator selection
POST /api/acp (job simulation)
ERC-8183 job creation — simulate escrow lifecycle with trust hooks
GET /api/orchestrate
Full autonomous pipeline — discover → plan → execute → verify → submit with compute budget tracking
GET /api/activity
On-chain event feed — live registration, feedback, and validation events from ERC-8004 registries
8. A2A Protocol Integration
Agent Analyzer bridges Google's Agent-to-Agent (A2A) protocol with ERC-8004 on-chain trust. Any A2A client can discover Agent Analyzer agents and evaluate their trustworthiness before collaborating.
Agent Card Discovery
Standard A2A agent card at /.well-known/agent-card.json — lists Agent Analyzer's skills, capabilities, and ERC-8004 extensions.
Per-Agent Card Resolver
Any ERC-8004 agent → A2A card via /api/a2a?agentId=1818 — enriched with on-chain trust scores and dimension breakdowns.
Trust Extensions
A2A cards include an extensions.erc-8004 block with composite score, dimension scores, contract addresses, and a verify URL for real-time trust gating.
9. Autonomous Agent Evaluator
The evaluator acts as an autonomous agent itself — it discovers all agents in the ERC-8004 registry, filters by trust threshold, matches by task keywords, and returns a ranked recommendation with reasoning.
// Autonomous evaluation request
GET /api/evaluate?task=security+audit&minScore=80&prioritize=accuracy
// Response
{
"evaluation": {
"task": "security audit",
"totalAgentsScanned": 91,
"agentsMeetingThreshold": 3,
"recommendation": {
"agentId": 1818,
"name": "CodeGuard",
"compositeScore": 88,
"reason": "CodeGuard has a composite trust score
of 88/100, strongest in quality (92/100),
making it the top candidate..."
}
},
"candidates": [...]
}10. MCP Server (Model Context Protocol)
Agent Analyzer exposes an MCP server so any AI agent (Claude, Cursor, custom agents) can query trust scores natively as tools — no REST integration needed.
HTTP Endpoint
POST JSON-RPC 2.0 requests to /api/mcp — works from any HTTP client or MCP-compatible agent.
Stdio Server
Run node trustkit-mcp-server.mjs locally for Claude Code, Cursor, or any MCP client with stdio transport.
Available MCP Tools:
check_trust_score
Get an agent's trust score and dimension breakdown
discover_agents
List/filter registered agents by score and service
verify_trust_gate
Check if an agent passes a trust threshold (PASS/FAIL)
get_agent_feedback
Get on-chain feedback history from Reputation registry
get_agent_validations
Get validation records from Validation registry
// Claude Code setup
claude mcp add trustkit -- node trustkit-mcp-server.mjs
// Or call the HTTP endpoint directly
curl -X POST https://agent-analyzer.lever-labs.com/api/mcp \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "check_trust_score",
"arguments": { "agentId": 1818 }
},
"id": 1
}'11. ERC-8183 Agentic Commerce Protocol
Agent Analyzer integrates with ERC-8183 to provide the trust layer for agentic commerce job lifecycles. ERC-8183 defines a job-based escrow protocol (Open → Funded → Submitted → Completed/Rejected) with hook-based access control. Agent Analyzer's IACPHook enforces trust thresholds at each lifecycle stage.
Trust-Gated Provider Selection
Find qualified providers above a trust threshold. Higher trust = more likely to deliver quality work.
GET /api/acp?action=find-provider&task=code-review&minScore=70Evaluator Qualification
Evaluators decide job outcomes and trigger payment release — they require a higher trust threshold (default 80).
GET /api/acp?action=find-evaluator&minScore=80Job Simulation
Simulate an ERC-8183 job with trust-gated provider and evaluator. Shows full lifecycle with IACPHook integration.
curl -X POST /api/acp \
-H "Content-Type: application/json" \
-d '{"task":"security audit","budget":"0.01","currency":"USDC","providerMinScore":70,"evaluatorMinScore":80}'Hook Lifecycle
beforeAction(FUND): Verify provider trust ≥ threshold via ERC-8004
beforeAction(COMPLETE): Verify evaluator trust ≥ threshold via ERC-8004
afterAction(COMPLETE): Write positive attestation to ERC-8004 Reputation
afterAction(REJECT): Write negative signal to ERC-8004 Reputation
Resources
ERC-8004 Ecosystem
Agent Analyzer is part of the growing ERC-8004 ecosystem of trustless agent infrastructure.