Cloudflare Workers + KV Demo

Agentic Commerce Registry

A decentralized identity registry enabling trusted commerce between shoppers, merchants, and AI agents. Register identities, delegate purchasing authority, and facilitate verified transactions including loans and leases.

Try the Interactive Demo

Three Participants

The registry connects three types of participants to enable agent-mediated commerce.

👤

Shopper

Registers their identity and financial profile (credit score, limits). Delegates purchasing authority to trusted AI agents with configurable scope, spending limits, and allowed transaction types.

🏪

Merchant

Registers their business and the transaction types they support (loans, leases, direct purchases). Verifies agent tokens through the registry before fulfilling orders.

🤖

AI Agent

Registers as a purchasing agent. Receives delegated tokens from shoppers and uses them to negotiate and complete purchases with merchants on the shopper's behalf.


Architecture

How identities, tokens, and transactions flow through the system.

CLOUDFLARE EDGE Registry API Cloudflare Worker (Hono) /api/register | /api/delegate | /api/verify KV Store shopper: | merchant: | agent: | token: read/write 👤 Shopper (Alice) 🏪 Merchant (FurnitureCo) 🤖 AI Agent (ShopBot) 1. Register 2. Register 3. Delegate 4. Present token 5. Verified purchase LEGEND Register identity Delegate / Transact Token / KV storage Verify / API call

Example: Agent-Mediated Furniture Lease

Alice wants to lease a $2,000 couch from FurnitureCo. She delegates her AI agent ShopBot to handle the purchase on her behalf.

1

Alice Registers

Alice registers with the commerce registry, providing her identity and financial profile (credit score: 750, credit limit: $10,000).

2

FurnitureCo Registers

FurnitureCo registers as a merchant that accepts both loans and leases for furniture purchases.

3

ShopBot Registers

ShopBot AI registers as a purchasing agent with capabilities for negotiation and purchase execution.

4

Alice Delegates to ShopBot

Alice delegates purchasing authority to ShopBot: up to $5,000, allowed for loans and leases. A cryptographic delegation token is generated and stored.

5

ShopBot Initiates Purchase

ShopBot finds a couch at FurnitureCo for $2,000 and initiates a 12-month lease. The registry verifies the token, checks delegation scope, confirms credit eligibility, and creates the transaction.

6

FurnitureCo Verifies

FurnitureCo independently verifies ShopBot's token against the registry, confirming Alice's identity and credit eligibility before approving the lease.

7

Transaction Completes

The lease agreement is finalized: $2,000 over 12 months at $166.67/month. All parties have a verified record in the registry.


Interactive Demo

Walk through the full scenario with live API calls. Watch the request lifecycle traced across Cloudflare services in real time.

session: Each session uses unique KV keys to guarantee cold reads on first run.
API Steps
Request Lifecycle Trace Waiting...
Run a step to see the request lifecycle traced across
Edge → Worker → KV Store

Implementation Details

Built on Cloudflare Workers with KV for globally distributed identity storage.

KV Schema

Key PatternPurpose
shopper:{id}Identity + credit profile
merchant:{id}Business + capabilities
agent:{id}Agent identity
delegation:{a}:{s}Delegation record
token:{hash}Token fast-lookup
transaction:{id}Transaction state

API Endpoints

EndpointPurpose
POST /api/register/shopperRegister shopper
POST /api/register/merchantRegister merchant
POST /api/register/agentRegister agent
POST /api/delegateDelegate authority
POST /api/verifyVerify token
POST /api/transaction/*Manage transactions

Technology Stack

ComponentTechnology
RuntimeCloudflare Workers
FrameworkHono
StorageWorkers KV
Auth TokensWeb Crypto API (SHA-256)
ConfigWrangler (jsonc)
ObservabilityWorkers Observability

Security Model

FeatureDescription
Token GenerationSHA-256 hashed UUIDs
Scope ControlPer-delegation limits
Expiry24h token TTL (KV native)
Amount LimitsConfigurable per delegation
Type Restrictionsloan, lease, purchase
Credit CheckAgainst shopper profile