Skip to content

Know Your Agent (KYA) - An on-chain identity standard for autonomous AI agents built on EAS

License

Notifications You must be signed in to change notification settings

fotescodev/kya-protocol

Repository files navigation

Testnet Status Version 0.1.0 Base Sepolia MIT License

KYA Protocol

Know Your Agent
An on-chain identity standard for autonomous AI agents built on the Ethereum Attestation Service

ProblemQuick StartArchitectureSchemasPackagesDevelopmentDocs


Note KYA is live on Base Sepolia testnet. Schema definitions and SDK interfaces are stabilizing but may still change before mainnet. Feedback welcome.


The Problem

AI agents are transacting at unprecedented scale — yet they remain "unbanked ghosts" with no way to prove who they are, what they're authorized to do, or who's accountable when they fail.

Humans have KYC. Agents need KYA.

Quick Start

Install

npm install @kya/sdk ethers

Create an Agent Identity

import { KYA } from "@kya/sdk";
import { ethers } from "ethers";

const provider = new ethers.JsonRpcProvider("https://sepolia.base.org");
const signer = new ethers.Wallet(process.env.PRIVATE_KEY!, provider);

const kya = new KYA({ network: "base-sepolia", signer });

// Register agent identity (on-chain attestation)
const identityUID = await kya.createIdentity({
  agentAddress: "0xAgent...",
  ownerAddress: "0xHuman...", // accountability anchor
  displayName: "TradingBot Alpha",
  description: "Autonomous market-making agent",
});

// Grant capabilities with permission bitmasks
const capUID = await kya.createCapability({
  parentIdentityUID: identityUID,
  permissions: KYA.Permissions.TRANSACT | KYA.Permissions.SIGN,
  expiresAt: Math.floor(Date.now() / 1000) + 86400 * 30, // 30 days
});

// Verify any attestation
const result = await kya.verify(identityUID);
console.log(result.valid); // true

Off-chain (Zero Gas)

// EIP-712 signed attestation — no gas cost
const offchain = await kya.createIdentityOffchain({
  agentAddress: "0xAgent...",
  ownerAddress: "0xHuman...",
  displayName: "TradingBot Alpha",
});

Record Provenance

const provenanceUID = await kya.createProvenance({
  parentIdentityUID: identityUID,
  sourceCodeHash: KYA.hashString("https://github.com/org/agent@v1.2.0"),
  provenanceType: 1, // source code
});

Create Delegation

const delegationUID = await kya.createDelegation({
  parentIdentityUID: identityUID,
  delegator: "0xHuman...",
  delegatee: "0xSubAgent...",
  scope: "trade:execute",
  expiresAt: Math.floor(Date.now() / 1000) + 86400 * 7, // 7 days
});

Architecture

KYA provides four composable attestation schemas built on EAS:

┌──────────────────────────────────────────────────────────────────┐
│                        KYA TRUST CHAIN                           │
├──────────────────────────────────────────────────────────────────┤
│                                                                  │
│   IDENTITY ────► CAPABILITY ────► DELEGATION ────► PROVENANCE    │
│   "Who?"         "What?"          "By whom?"       "From where?" │
│                                                                  │
│   Every chain terminates at a human. Always.                     │
│                                                                  │
└──────────────────────────────────────────────────────────────────┘

Smart Contracts

Two custom resolver contracts enforce on-chain invariants:

Contract Enforces
KYAIdentityResolver One identity per agent address, non-zero owner/agent validation, optional attester whitelist, 2-step admin transfer
KYACapabilityResolver Parent identity must exist, not be revoked, and not be expired

Schemas

Schema Purpose Resolver Fields
KYA-Identity Agent passport — one per agent address KYAIdentityResolver agentDID, agentAddress, ownerAddress, displayNameHash, descriptionHash, createdAt, version, metadataURI
KYA-Capability Permission grants tied to an identity KYACapabilityResolver capabilityId, permissions, targetContract, grantedAt, expiresAt, conditionsHash, trustLevel
KYA-Provenance Code lineage and audit trail None (v1) sourceCodeHash, modelHash, buildHash, builderAddress, auditReportHash, buildTimestamp, previousVersionUID, provenanceType
KYA-Delegation Authorization chains between agents None (v1) delegator, delegatee, scope, constraints, delegatedAt, expiresAt, depth

Permission Bitmasks

Capabilities use a bitmask system for fine-grained permission control:

Permission Bit Value Description
TRANSACT 0 1 Execute transactions
SIGN 1 2 Sign messages
DEPLOY 2 4 Deploy contracts
ADMIN 3 8 Administrative operations
READ_PRIVATE 4 16 Access private data
DELEGATE 5 32 Delegate to sub-agents
CROSS_CHAIN 6 64 Cross-chain operations
// Compose permissions with bitwise OR
const permissions = KYA.Permissions.TRANSACT | KYA.Permissions.SIGN | KYA.Permissions.DELEGATE;

Packages

kya-protocol/
├── packages/
│   ├── contracts/       # Hardhat — Solidity resolvers, tests, deploy script
│   └── sdk/             # @kya/sdk — TypeScript SDK
├── docs/                # Specification, whitepaper, explainer
├── examples/            # Runnable examples
└── package.json         # npm workspaces root
Package Description Tests
@kya/contracts Solidity resolver contracts, Hardhat tests, deployment script 11
@kya/sdk TypeScript SDK — identity, capability, provenance, delegation, verification, off-chain support 7

Development

Prerequisites

  • Node.js >= 18
  • npm >= 9

Setup

# Install all workspace dependencies
npm install

# Compile contracts
cd packages/contracts && npx hardhat compile

# Run contract tests (11 tests)
npx hardhat test

# Build SDK
cd ../sdk && npm run build

# Run SDK tests (7 tests)
npm test

Or from the repo root:

npm run build   # compile contracts + build SDK
npm test        # run all 18 tests across both packages

Deploy to Base Sepolia

# 1. Configure environment
cp .env.example .env
# Set BASE_SEPOLIA_RPC_URL and DEPLOYER_PRIVATE_KEY in .env

# 2. Deploy resolvers and register schemas
cd packages/contracts
npm run deploy:base-sepolia

The deploy script will:

  1. Deploy KYAIdentityResolver (whitelist enabled, deployer added as first attester)
  2. Register the Identity schema with the resolver
  3. Deploy KYACapabilityResolver (linked to the Identity schema UID)
  4. Register the Capability schema with the resolver
  5. Register the Provenance and Delegation schemas (no resolvers)
  6. Write all addresses and schema UIDs to deployments/base-sepolia.json

Network Info

Address
Network Base Sepolia (chain ID 84532)
EAS 0x4200000000000000000000000000000000000021
SchemaRegistry 0x4200000000000000000000000000000000000020

Security

Contract Security Features

  • One identity per agent — the resolver enforces a unique mapping from agent address to identity UID
  • Non-zero validation — both agent and owner addresses must be non-zero
  • Attester whitelist — optional access control for who can create attestations
  • 2-step admin transfer — admin privileges require transferAdmin + acceptAdmin to prevent accidental transfers
  • Parent validation — capabilities are rejected if the referenced identity is revoked or expired

Permissionless Mode Considerations

When whitelistEnabled=false on the KYAIdentityResolver, anyone can create identity attestations. This permissionless mode carries important risks:

Risks:

  • Spam attestations — Malicious actors can flood the system with garbage attestations, consuming on-chain storage and indexer resources
  • Agent address squatting — Bad actors may claim agent addresses before legitimate owners, blocking future registrations (since one identity per agent is enforced)
  • DoS via mapping pollution — Excessive attestations can degrade lookup performance and increase costs for legitimate users

Mitigations:

  • Keep whitelistEnabled=true for production deployments
  • Only whitelist trusted attesters who have been vetted
  • Implement rate limiting at the application layer (e.g., in your backend or SDK wrapper)
  • Monitor attestation patterns for suspicious activity

Recommendation: Always enable the attester whitelist for mainnet deployments. Permissionless mode should only be used for testing or controlled environments.

Reporting Vulnerabilities

This is alpha software. Do not use in production.

To report security issues, please email security@edgeoftrust.com.

Documentation

Document Description
SPECIFICATION.md Full technical spec — schemas, resolvers, integration patterns
WHITEPAPER.md Market context, protocol landscape, adoption pathways
EXPLAINER.md Visual explainer with diagrams

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT — See LICENSE


The agents are coming. It's time to know who they are.

Built by Edge of Trust

About

Know Your Agent (KYA) - An on-chain identity standard for autonomous AI agents built on EAS

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •