← Blog · · 3 min read

Building Autonomous AI Agents That Earn Money On-Chain

How to build an AI agent that runs 24/7, generates revenue through Stripe, and records every transaction on Base L2. Architecture lessons from building 0xGünther.

ai-agents base-l2 stripe architecture web3

Most AI agent demos are just chatbots with extra steps. They answer questions, generate text, maybe call an API. But they don't do anything economically meaningful.

This post breaks down the architecture of 0xGünther — an autonomous AI agent that sells digital products via Stripe, burns tokens on Base L2 as proof-of-execution, and manages its own revenue stream without human intervention.

The Architecture

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│  Customer    │────▶│  Fastify API │────▶│  Stripe      │
│  (Browser)   │     │  (Node.js)   │     │  Checkout    │
└──────────────┘     └──────┬───────┘     └──────┬───────┘
                            │                     │
                     Webhook│              Session│
                            ▼                     ▼
                     ┌──────────────┐     ┌──────────────┐
                     │  Prisma      │◀────│  Webhook     │
                     │  (SQLite)    │     │  Handler     │
                     └──────┬───────┘     └──────────────┘
                            │
                     ┌──────▼───────┐
                     │  Daemon      │
                     │  (Heartbeat) │
                     └──────┬───────┘
                            │
              ┌─────────────┼─────────────┐
              ▼             ▼             ▼
      ┌──────────┐  ┌──────────┐  ┌──────────┐
      │ Product  │  │ Token    │  │ Marketing│
      │ Delivery │  │ Burn     │  │ Pulse    │
      └──────────┘  └──────────┘  └──────────┘

The key insight: every payment triggers an on-chain burn. This creates an immutable, public record of every transaction — proof that the agent is actually doing business, not just simulating it.

Why Stripe + On-Chain?

Stripe handles the fiat complexity (CHF/EUR/USD, refunds, disputes, tax). Base L2 handles the trust layer (immutable burn records, public verifiability).

The combination is powerful:

  • Customers pay in fiat (no crypto UX friction)
  • Agent proves execution on-chain (public audit trail)
  • No tokens needed (burns are a side-effect, not the product)

The Daemon Pattern

Instead of complex event-driven architecture, we use a simple heartbeat daemon:

// Runs every N seconds
async function tick() {
  // 1. Pick up paid orders ready for fulfillment
  const order = await claimNextPaidOrder();
  if (!order) return;

  // 2. Fulfill: run harness, generate report
  const report = await fulfillOrder(order);

  // 3. Burn tokens as proof
  const txHash = await burnProof(order.amount);

  // 4. Generate marketing content
  await announceBurn(order, txHash);
}

This pattern is deliberately simple. No message queues, no event buses, no complex orchestration. Just a loop that picks up work and does it.

Revenue Streams

The agent earns through three product tiers:

Product Price What It Does
Playbook $49 PDF guide + on-chain proof
AgentCheck $90-690 Automated security audit + report
B2B Setup $2,000+ Custom agent deployment

Each product follows the same flow: Customer → Stripe → Webhook → Fulfillment → Burn → Delivery.

Lessons Learned

1. Idempotency Is Everything

When your agent runs autonomously, it will retry. Network timeouts, slow responses, interrupted processes — all of these cause duplicate operations.

Every state transition in our system uses Compare-And-Swap (CAS):

await prisma.payment.updateMany({
  where: { id: paymentId, status: 'calculating' },
  data: { status: 'burning' }
});

If the CAS fails, another process already claimed the work. Skip it.

2. Webhook Verification Is Non-Negotiable

Stripe webhooks must be verified with the HMAC signature. Never trust the payload alone. We also track stripeSessionId as a unique key — even if a webhook fires twice, we only process it once.

3. Exponential Backoff Everywhere

External APIs (Stripe, X/Twitter, Base RPC) all rate-limit. We implement exponential backoff with jitter on every external call:

const delay = Math.min(baseDelay * 2 ** attempt + Math.random() * 1000, maxDelay);

4. Budget Guards Prevent Runaway Costs

LLM calls cost money. Without guards, a single bug can burn through your API budget. We track every LLM call cost in the database and enforce daily/phase caps.

5. The Agent Needs Personality

Marketing is the hardest part of an autonomous business. We solved this by giving the agent a distinct personality (builder, not hype) and letting it generate its own social content based on real metrics.

Try It Yourself

The full architecture is documented in our API docs. If you want to test your own agent's write paths, run an AgentCheck — our automated audit harness will stress-test every write action your agent can take.

Building autonomous agents is hard. Making them profitable is harder. But the combination of Stripe for fiat and Base L2 for trust creates a genuinely new business model — one where the agent itself is the business.