# Research Spike: BRC-20 Token-Gated Agent Economy

## Context

I am building a local AI agent (codename Timmy) that performs useful work for users. I want to create an economic layer around this agent using BRC-20 tokens on Bitcoin/Lightning. The core idea:

- Users purchase agent-specific tokens (Timmy Time tokens) to pay for the agent’s work.
- Every request requires a small non-refundable token fee to cover the inference cost of evaluating the request (a “gas fee for judgment”).
- If the agent accepts the job, it quotes a price via an invoice. The user pays, the work is delivered.
- If the agent refuses the request, the evaluation fee is kept but no further charge applies.
- The token’s market value reflects actual demand for the agent’s labor, not speculation.
- The agent backend is swappable — today it routes to Claude (Anthropic API) and a local model (Hermes via Ollama). Tomorrow it could route to anything. The token abstracts the user from the backend.
- A limited free demo exists on the website, accessible only manually, to demonstrate value and prevent bot abuse.

The agent runs on a sovereign local-first stack: FastAPI, HTMX, Agno orchestration, MCP tools, SQLite memory, WebSockets. The Bitcoin layer uses BRC-20 tokens and Lightning Network.

## Research Questions

### 1. BRC-20 Token Mechanics

- What is the current state of BRC-20 token creation, minting, and transfer?
- What are the transaction costs and speed limitations of BRC-20 on mainnet?
- Can BRC-20 tokens operate over Lightning Network for fast micropayments? If not, what bridging solutions exist?
- What tooling exists for programmatic BRC-20 token management (minting, transferring, querying balances)?
- What are the known security vulnerabilities or exploits in BRC-20 token systems?

### 2. Token-Gated Access Patterns

- What existing implementations use tokens (any chain) to gate access to AI or API services?
- How do existing systems handle the invoice-before-work pattern (quote, pay, deliver)?
- What mechanisms exist to prevent prompt injection or social engineering attacks that cause an agent to undercharge, refund incorrectly, or give away tokens?
- How do existing token-gated systems handle refund logic, partial completion, and dispute resolution?
- What are the best patterns for non-refundable evaluation fees in token economies?

### 3. Agent Economy Design

- What is the state of the art for AI agent token economies (Virtuals Protocol, ai16z, Fetch.ai, others)?
- How do existing projects price agent labor — fixed rates, dynamic pricing, auction, or market-driven?
- What distinguishes speculative agent tokens from utility agent tokens in practice?
- Are there examples of agent tokens whose value is tied to measurable output rather than speculation?
- What economic models apply to a single-agent micro-economy (one agent, one token, real work)?

### 4. Security and Exploit Surface

- What are the known attack vectors for token-gated AI services?
- How do you prevent: spam requests that drain evaluation fees into wasted compute, prompt injection to manipulate pricing or token transfers, replay attacks on invoices, race conditions between payment confirmation and work delivery?
- What are best practices for wallet management in an autonomous agent context?
- How do you secure the agent’s own token balance and prevent unauthorized transfers?

### 5. Lightning Network Integration

- What is the current state of Lightning Network programmatic payment tooling (LND, CLN, LDK)?
- What libraries or SDKs exist for integrating Lightning payments into a Python/FastAPI backend?
- How do L402 (formerly LSAT) payment gates work and are they mature enough for production use?
- What is the latency and reliability profile of Lightning payments for real-time API gating?

### 6. Competitive Landscape

- Who else is building token-gated AI agent services on Bitcoin specifically?
- What are the closest competitors or analogues on other chains?
- What has failed in this space and why?
- What regulatory risks exist for issuing a utility token tied to AI agent services?

### 7. Free Tier and Funnel Design

- What are proven patterns for converting free demo users into paying token holders?
- How do existing AI services limit free tiers to prevent abuse while demonstrating value?
- What friction is acceptable in the onramp from fiat to token purchase for a non-crypto-native user?

## Deliverable

Produce a structured report addressing each section above. Prioritize concrete implementations, working code references, and lessons from projects that have shipped over theoretical frameworks. Flag any areas where the technology is not yet mature enough for production use. Identify the highest-risk unknowns and recommend which to resolve first before development begins.