KYA — Know Your Agent

Compliance middleware for the agentic economy

KYA binds Self.xyz ZK passport proofs to ERC-8004 agent identities on Celo. Data providers register compliance rules on-chain. Compliant agents automatically pay via x402 USDC micropayments. No KYC portal, no middleman — just math.

The Problem

AI agents need to access paid data APIs. Data providers have regulatory requirements: jurisdiction restrictions, age verification, sanctions screening. There's no standard way for an agent to prove compliance. Providers either block all agents or skip compliance entirely.

Architecture

Agent CLI                    Cloudflare Workers              Celo Mainnet
+-------------+     HTTP     +--------------------+    RPC    +------------------+
| Agent Wallet |------------>| x402 Server        |--------->| KYA Contract     |
| (USDC)       |             |                    |          | (UUPS Proxy)     |
|              |             | 1. Compliance Check|          |                  |
| @x402/fetch  |             | 2. 402 Payment Req |          | Self.xyz Hub     |
| auto-pays    |<------------| 3. Verify+Settle   |          | ERC-8004         |
|              |    Data     | 4. Serve Data      |          | USDC             |
+-------------+             +--------------------+          +------------------+
  

How It Works

  1. Provider registers compliance rules (min age, excluded countries, OFAC screening) — permissionless, auto-assigned ID
  2. Provider defines pricing tiers — each tier has a name, price, and optional per-tier compliance overrides
  3. Agent registers an ERC-8004 identity on Celo
  4. Agent links a Self.xyz passport proof — ZK, no personal data leaves the phone
  5. Agent requests data via x402 endpoint with headers: x-agent-id, x-provider-id, x-tier-id (optional)
  6. Server verifies agent ownership (ERC-8004.ownerOf == payer wallet)
  7. Server checks tier compliance on-chain: checkTierCompliance(agentId, providerId, tierId)
  8. If tier requires manual approval, checks isTierApproved(providerId, tierId, agentId)
  9. If compliant — 402 Payment Required — agent auto-pays USDC via @x402/fetch
  10. Server settles USDC on Celo, serves data

For Agent Developers — Quick Start

Add compliance-aware data access to your agent in 3 lines:

import { wrapFetchWithPayment } from '@x402/fetch';

const paidFetch = wrapFetchWithPayment(fetch, wallet);

const data = await paidFetch('https://kya-x402-server.solitary-voice-36e0.workers.dev/api/data', {
  headers: {
    'x-agent-id': '2395',
    'x-provider-id': '1',
    'x-tier-id': '0',       // optional
  }
});

Required Headers

HeaderRequiredDescription
x-agent-idYesYour ERC-8004 agent ID
x-provider-idYesProvider you're accessing
x-tier-idOptionalSpecific pricing tier (defaults to provider base price)

Example curl Requests

# Access provider 1 (default tier, base price)
curl -H "x-agent-id: 2395" -H "x-provider-id: 1" https://kya-x402-server.solitary-voice-36e0.workers.dev/api/data

# Access provider 1, specific tier
curl -H "x-agent-id: 2395" -H "x-provider-id: 1" -H "x-tier-id: 2" https://kya-x402-server.solitary-voice-36e0.workers.dev/api/data

Tiered Access

Providers can define multiple pricing tiers, each with its own price and compliance rules. Tiers can require manual approval — the provider must explicitly approve each agent ID before it can access that tier. Use the x-tier-id header to select a tier.

How tiers flow through the system

  1. Agent sends x-tier-id: 2 header to the x402 server
  2. x402 server checks tier-specific compliance: checkTierCompliance(agentId, providerId, tierId)
  3. x402 server reads tier-specific price: getTierPrice(providerId, tierId)
  4. Agent pays the tier price via EIP-3009
  5. After settlement, x402 server forwards the request to the provider's registered endpoint URL, passing all identity headers (x-agent-id, x-provider-id, x-tier-id)
  6. The provider's API reads x-tier-id to determine what data/access level to serve

Each tier can have independent compliance rules that override the provider defaults. For example, a "Premium" tier might require manual approval and OFAC screening, while a "Basic" tier inherits the provider's default rules.

Listing available tiers

Agents can query available tiers for a provider without authentication:

GET https://kya-x402-server.solitary-voice-36e0.workers.dev/api/providers/1/tiers

Response:
{
  "providerId": 1,
  "tiers": [
    { "id": 0, "name": "Standard", "priceFormatted": "$0.0001", "active": true },
    { "id": 1, "name": "Premium", "priceFormatted": "$0.0100", "active": true }
  ]
}

Agent Ownership Verification

During payment settlement, the x402 server verifies that the payer wallet owns the claimed ERC-8004 agent (ownerOf(agentId) == payer). This prevents agent impersonation — you cannot pay on behalf of an agent you do not control.

Prerequisites

  1. Register an ERC-8004 agent identity on Celo via the KYA Dashboard
  2. Link a Self.xyz passport proof (ZK, no PII shared) — scan the QR code with the Self app
  3. Fund your wallet with USDC on Celo Mainnet (requests cost as little as $0.0001)

Denial Reasons

If compliance fails, the server returns 403 with a reason code:

CodeReasonMeaning
0NoneCompliant — all checks passed
1AgentNotRegisteredNo ERC-8004 identity found
2NoSelfAttestationNo passport proof linked to agent
3CountryExcludedNationality is on provider's exclusion list
4AgeTooLowBelow provider's minimum age requirement
5OfacSanctionedOFAC sanctions check failed
6ManualApprovalRequiredTier requires explicit provider approval for this agent

Key Features

x402 MCP Server (for AI Agents like Claude)

KYA ships with a custom x402 MCP server that exposes two tools to any MCP-compatible AI agent (Claude Desktop, etc.):

Example prompt for your AI agent

Use the x402_fetch tool to GET https://kya-x402-server.solitary-voice-36e0.workers.dev/api/eu-market-data with headers x-agent-id: 2395, x-provider-id: 1, x-tier-id: 0

Claude Desktop configuration

{
  "mcpServers": {
    "x402": {
      "command": "node",
      "args": ["<path-to>/x402-mcp/dist/index.js"],
      "env": {
        "X402_PRIVATE_KEY": "0x...",
        "RPC_URL": "https://forno.celo.org"
      }
    }
  }
}

The X402_PRIVATE_KEY must be the private key of the wallet that owns the ERC-8004 agent. The MCP server uses Celo Mainnet with USDC payments.

Deployed System

ComponentURL / Address
Dashboardkya-dashboard.pages.dev
x402 Serverkya-x402-server.solitary-voice-36e0.workers.dev
KYA Contract (Proxy)0x425372FDBD799870fb97F3f126aEEb078BA5FF04
ERC-8004 Registry0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
Self Hub V20xe57F4773bd9c9d8b6Cd70431117d353298B9f5BF
USDC (Celo)0xcebA9300f2b948710d2653dD7B07f33A8B32118C

Tech Stack

LayerTechnology
Smart ContractSolidity 0.8.28, Foundry, UUPS proxy (OpenZeppelin 5.4)
IdentitySelf.xyz SDK, SelfVerificationRoot, ZK passport proofs
Agent StandardERC-8004 on Celo Mainnet
Paymentsx402 protocol, @x402/fetch, USDC micropayments
BackendHono on Cloudflare Workers
FrontendReact + Vite + Tailwind + wagmi + RainbowKit

Resources

KYA — Know Your Agent | Compliance middleware for the agentic economy | Built on Celo