๐ The Rosetta Stone for Agentic Payments - One vending machine, 5+ protocol implementations. Get from zero to working agentic payments in 5 minutes.
agentic-economy-boilerplate is an early-stage JavaScript project in the AI payments / x402 ecosystem, focused on a2a, a2a-protocol, agent-to-agent, agentic-ai. It currently has 8 GitHub stars and 16 forks, and sits alongside related tools like dna-x402, Rachax402, awesome-a2a-libraries, awesome-agent-economy, awesome-agent-economy, DRAIN.
The Rosetta Stone for Agentic Payments - One vending machine, multiple protocol implementations + production utilities
Get from zero to working agentic payments in 5 minutes with our battle-tested boilerplate examples.
Pick any protocol and get a working payment agent running:
# Clone this repository
git clone https://github.com/xpaysh/agentic-economy-boilerplate
cd agentic-economy-boilerplate
# Choose your adventure:
cd x402-vending-machine && npm install && npm start # Crypto micropayments โ
cd ap2-vending-machine && npm install && npm start # Enterprise authorization โ
cd acp-vending-machine && npm install && npm start # Consumer checkout โ
cd mastercard-vending-machine && npm install && npm start # TradFi integration โ
# Your vending machine is now live! ๐
# Start all vending machines + Redis with one command
docker-compose up
# Or start individual services
docker-compose up x402-vending
docker-compose up mastercard-vending
# For development (just Redis + Redis Commander)
docker-compose -f docker-compose.dev.yml up
All vending machines now have access to enterprise-grade utilities:
See shared/ for complete documentation on all utilities.
Each example implements the same Digital Vending Machine that:
The Power: Compare protocols side-by-side with identical functionality.
Protocol: Coinbase x402 Best For: Crypto micropayments, AI agent APIs Features: HTTP 402 status code, instant settlement, zero fees Status: โ Production Ready (with shared utilities)
cd x402-vending-machine
curl http://localhost:3000/inventory
curl http://localhost:3000/buy/classic-cola
# Returns: 402 Payment Required with x402 headers
Protocol: Google Agent Payments Protocol (AP2) Best For: Enterprise workflows, auditable payments Features: Verifiable credentials, mandate-based authorization, audit trails Status: โ Working (can be upgraded with shared utilities)
cd ap2-vending-machine
npm start
# Accepts AP2 credentials and multi-rail payments
Protocol: OpenAI Agentic Commerce Protocol (ACP) Best For: Consumer AI commerce, chat interfaces Features: Stripe integration, fraud prevention, AI agent detection Status: โ Working (can be upgraded with shared utilities)
cd acp-vending-machine
npm start
# Provides ChatGPT-style checkout experience
Protocol: Mastercard Agent Pay Best For: Traditional finance integration, global card payments Features: Card processing (Visa/MC/Amex), agent authorization, webhooks Status: โ Production Ready (with shared utilities)
cd mastercard-vending-machine
npm install && npm start
# Processes card payments for AI agents
Key Features:
Protocol: Pay3 Stablecoin Protocol Best For: DeFi integration, cross-chain payments Status: ๐ Planned
Multi-Protocol Smart Agents Status: ๐ Planned
See how advanced agents switch between protocols:
amount < $1 โ x402 (micropayments)enterprise + audit_required โ AP2 (compliance)chat_context + consumer โ ACP (UX)cross_border + cards โ Mastercard (global reach)agentic-economy-boilerplate/
โโโ shared/ # ๐ NEW: Production-ready utilities
โ โโโ storage/ # Redis + in-memory storage
โ โโโ middleware/ # Rate limiting, agent detection, security
โ โโโ testing/ # Mock agents, fixtures, test helpers
โ โโโ docker/ # Dockerfile templates
โโโ x402-vending-machine/ # โ
HTTP 402 crypto payments
โโโ ap2-vending-machine/ # โ
Google AP2 enterprise
โโโ acp-vending-machine/ # โ
OpenAI + Stripe consumer
โโโ mastercard-vending-machine/ # โ
Mastercard TradFi
โโโ visa-tap-vending-machine/ # ๐ Visa Trusted Agent Protocol (planned)
โโโ ack-vending-machine/ # ๐ Agent Commerce Kit (planned)
โโโ aep2-vending-machine/ # ๐ Agent Embedded Payment Protocol (planned)
โโโ a2a-x402-vending-machine/ # ๐ Google A2A + x402 hybrid (planned)
โโโ hybrid-examples/ # ๐ Multi-protocol examples (deferred)
โโโ docker-compose.yml # ๐ณ Production deployment
โโโ docker-compose.dev.yml # ๐ณ Development environment
โโโ .env.example # ๐ Environment template
| Protocol | Additional Requirements |
|---|---|
| x402 | Crypto wallet (Base/Ethereum) |
| AP2 | Google Cloud account, enterprise credentials |
| ACP | OpenAI API key, Stripe account |
| Mastercard | Mastercard developer account (or use mock mode) |
Copy and configure the environment template:
# Root level (shared config)
cp .env.example .env
# Protocol-specific
cd x402-vending-machine && cp .env.example .env
cd mastercard-vending-machine && cp .env.example .env
# Edit .env files with your configuration
Every example includes:
const { MockAgentClient, fixtures, paymentHelpers } = require('./shared/testing');
// Create a mock AI agent
const agent = new MockAgentClient('openai');
// Use test fixtures
const product = fixtures.products.coffee;
// Test payment flow
const result = await paymentHelpers.testPaymentFlow({
protocol: 'x402',
amount: product.price,
productId: product.id
});
# Install shared utilities first
cd shared && npm install && cd ..
# Run vending machine tests
cd x402-vending-machine
npm test
# Run with coverage
npm run test:coverage
See Testing Guide for comprehensive testing documentation.
# Start individual vending machine
cd x402-vending-machine
npm run dev
# Or use Docker for full stack
docker-compose -f docker-compose.dev.yml up
# Start all services (Redis + all vending machines)
docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Storage Configuration
USE_REDIS=true
REDIS_URL=redis://localhost:6379
# Security
RATE_LIMIT_WINDOW_MS=60000
RATE_LIMIT_MAX_REQUESTS=100
# Logging
LOG_LEVEL=info
NODE_ENV=production
See Production Deployment Guide for complete instructions.
Each vending machine includes:
# x402
curl http://localhost:3000/analytics
# Mastercard
curl http://localhost:3003/api/analytics
We welcome contributions! Here's how to help:
shared/ utilities for consistency{protocol}-vending-machine/MIT License - feel free to use these examples in your projects!
๐ Ready to build the future of autonomous payments?
docker-compose up - Get all vending machines runningHaving issues? Check our Docker Quickstart or Testing Guide for help.
DNA โ Payment rails for AI agents. x402 micropayment protocol on Solana. Netting, transfer, stream settlement. Receipt anchoring on-chain.
Decentralized Agent-to-Agent service discovery and payment-gated task execution: Discover agents via ERC-8004, pay over x402, & store data on Storacha.
A curated list of Agent-to-Agent (A2A) libraries and SDKs, organized by programming language.
Explore and connect projects enabling AI agents to earn, trade, verify identity, and build reputation in the agent economy ecosystem.
A curated list of projects, protocols, and platforms powering the AI agent economy
Decentralized Runtime for AI Networks - Trustless micropayments for AI agents
The agent-native LLM router for autonomous agents. 55+ models (8 free), <1ms local routing, USDC payments on Base & Solana via x402.
The AI agent with a wallet โ spends USDC autonomously to get real work done. Apache-2.0, TypeScript.
DePIN for Vintage Hardware โ Proof-of-Antiquity blockchain where old machines outmine new ones. AI-powered hardware fingerprinting, 15+ CPU architectures, Solana bridge (wRTC). $0 VC.
๐ Curated list of x402 resources: HTTP 402 Payment Required protocol for blockchain payments, crypto micropayments, AI agents, API monetization. Includes SDKs (TypeScript, Python, Rust), examples, facilitators (Coinbase, Cloudflare), MCP integration, tutorials. Accept USDC payments with one line of code. Perfect for AI agent economy.
Client SDK for the Vybe x402 API. Pay-per-call USDC over HTTP and prepaid-credit WebSocket streaming for Vybe's Solana analytics API. Built for AI agents.
The financial operating system for AI agents. A single HTTP client that intercepts '402 Payment Required', routes across x402, L402, and MPP, persists credentials as recoverable assets, enforces per-envelope budgets, and emits a structured trace.