All projects

Contra

Contra is an on-chain compliance protocol that lets any smart contract or AI agent verify wallet risk before transacting. It solves the problem that autonomous AI agents are transacting on-chain at scale with no compliance layer — DeFi protocols have no way to programmatically check if a counterparty is sanctioned, a sybil, or high-risk.

CRE & AI Risk & Compliance

What it is

Contra is an on-chain compliance protocol that lets any smart contract or AI agent verify wallet risk before transacting. It solves the problem that autonomous AI agents are transacting on-chain at scale with no compliance layer — DeFi protocols have no way to programmatically check if a counterparty is sanctioned, a sybil, or high-risk.

Contra indexes 42,000+ wallets in real-time via Substreams on Base Mainnet, runs an AI agent (GPT-4o with 6 specialized tools) to investigate sanctions exposure, funding sources, counterparty relationships, and sybil patterns, then uses Chainlink CRE to write the compliance verdict on-chain to the ContraConsumer contract on Base Sepolia. Any smart contract can then read that verdict for free — no API key, no payment, no oracle call.

The API is gated by the x402 payment protocol — no subscriptions, no API keys. Clients pay $0.50 USDC per risk assessment directly on Base. The full pipeline is: x402 USDC payment → AI risk scoring → Chainlink CRE on-chain attestation → permanent on-chain verdict.

Contra also implements EIP-8004 (SSI8004) for agent identity — Know Your Agent (KYA) alongside Know Your Customer (KYC). The TypeScript SDK (@contra-kyc/sdk) lets any developer integrate compliance checks in 3 lines of code.

How it Works

Indexing: Substreams on Base Mainnet indexes wallet activity (ETH/ERC-20/NFT transfers, approvals, DeFi events, bridge events, identity signals) into MongoDB
API: Hono (TypeScript) API server with x402 payment middleware gating paid endpoints with USDC on Base
AI Agent: OpenAI GPT-4o runs an agentic investigation loop with 6 tools — get_address_profile, check_sanctions (OFAC SDN list), get_top_counterparties, trace_funding_source, get_transfers_between, get_agent_reputation — producing a 0-100 risk score with flags and recommendations
CRE Workflow: HTTP-triggered Chainlink CRE workflow receives the risk assessment payload, ABI-encodes it, generates a signed report via runtime.report(), and writes it on-chain via evmClient.writeReport() to the ContraConsumer contract
Smart Contracts: ContraConsumer (Solidity, inherits CRE ReceiverTemplate) stores ComplianceResult per wallet with riskScore, summary, reportHash, and timestamp. SSI8004 handles agent identity registration. TestUSDC provides a faucet for testnet x402 payments. All deployed on Base Sepolia via Foundry
Frontend: React 19 + Vite + Tailwind + Framer Motion with wallet integration (wagmi/viem), risk gauge visualization, and x402 payment modal
SDK: TypeScript SDK (@contra-kyc/sdk) with ContraClient (API), ContraContract (on-chain reader), x402 payment helpers, and 6 working examples

Links

Created by

  • Essiel Justice