Accept autonomous micropayments in USDC on Base L2 directly to your wallet in 5 minutes. No Stripe onboarding, no foreign bank fees, and zero counterparty risk.
Payments confirm and disburse in < 2 seconds on Base L2 via EIP-3009 receiveWithAuthorization.
Devin, Cursor, and autonomous AI agents pay automatically using standard HTTP 402 wire headers without human intervention.
Every response returns a tamper-evident receipt signed with secp256k1, verifiable offline for compliance and accounting.
// npm install @code402/proxy viem
import express from 'express';
import { x402Middleware } from '@code402/proxy';
const app = express();
// Protect any GPU inference or API endpoint with autonomous x402 settlement
app.post('/v1/chat/completions', x402Middleware({
recipient: '0xYourBaseL2WalletAddress...',
priceUsdc: '0.005', // $0.005 per request
network: 'base',
facilitatorUrl: 'https://code402-edge-v2.akrivis.workers.dev/settle',
}), async (req, res) => {
// Access granted: payment cryptographically verified and settled on Base L2!
// req.payment contains { payer, txHash, amount, xdr1Receipt }
const completion = await runLocalInference(req.body);
res.json({ output: completion, receipt: req.payment.xdr1Receipt });
});
app.listen(8080);
# pip install fastapi uvicorn code402-proxy
from fastapi import FastAPI, Depends, Request
from code402 import x402_guard, PaymentContext
app = FastAPI()
# 1-line decorator for autonomous AI agent settlement
@app.post("/v1/gpu/rent-epoch")
async def rent_gpu_epoch(
request: Request,
payment: PaymentContext = Depends(x402_guard(
recipient="0xYourBaseL2WalletAddress...",
price_usdc="2.85", # $2.85 per GPU hour
facilitator="https://code402-edge-v2.akrivis.workers.dev/settle"
))
):
# Autonomous agent has paid $2.85 USDC on Base L2
cluster_token = allocate_h100_slice(request.json(), duration_sec=3600)
return {
"status": "ALLOCATED",
"cluster_token": cluster_token,
"settlement_tx": payment.transaction_hash,
"xdr1_receipt": payment.signed_receipt
}
// go get github.com/code402/proxy-go
package main
import (
"net/http"
"github.com/code402/proxy-go/x402"
)
func main() {
guard := x402.NewGuard(x402.Config{
Recipient: "0xYourBaseL2WalletAddress...",
PriceMicros: 5000, // 0.005 USDC
FacilitatorURL: "https://code402-edge-v2.akrivis.workers.dev/settle",
})
http.Handle("/v1/models/generate", guard.Protect(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Payment verified via EIP-3009 atomic splitter on Base L2
w.Header().Set("Content-Type", "application/json")
w.Write([]byte(`{"status":"success","generated_tokens":1024}`))
})))
http.ListenAndServe(":8080", nil)
}