• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
stevekrouse

stevekrouse

x402-playground

Playing with internet-native payment protocols
Public
Like
x402-playground
Home
Code
4
lib
5
routes
3
README.md
H
buyer.tsx
Connections
Environment variables
2
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
…
Viewing readonly version of main branch: v57
View latest version
README.md

x402 Playground

A demo app showing how to use the x402 protocol (HTTP 402 payments) to pay for a Browserbase browser session and take website screenshots — all powered by automatic USDC micropayments on Base.

How it Works

Rendering mermaid diagram...
  1. The user enters a URL and submits the screenshot form
  2. The app calls x402.browserbase.com to create a paid browser session
  3. The @x402/fetch SDK transparently handles the HTTP 402 flow — it parses the payment requirements, signs a USDC transfer on Base (EIP-3009), and retries the request with a PAYMENT-SIGNATURE header
  4. Browserbase returns a WebSocket URL for a remote Chromium instance
  5. The app connects via Playwright, navigates to the target URL, and returns a PNG screenshot
  6. The transaction is recorded in SQLite for the history page

Project Structure

buyer.tsx              → HTTP entry point (Hono router)
routes/
  home.tsx             → Landing page with wallet info & navigation
  screenshot.tsx       → Screenshot form + POST handler
  transactions.tsx     → Transaction history table
lib/
  x402.ts              → x402 client setup (wallet signer + wrapFetchWithPayment)
  browserbase.ts       → Browserbase session creation via x402
  screenshot.ts        → Playwright CDP screenshot capture
  db.ts                → SQLite schema & queries for transaction log
  layout.tsx           → Shared HTML layout with Twind CSS

Environment Variables

KeyDescription
X402_PRIVATE_KEYPrivate key for a Base wallet holding USDC (used to sign x402 payments)

Pages

RouteDescription
/Home — shows wallet address, explains the flow, links to other pages
/screenshotForm to enter a URL and capture a screenshot ($0.01 USDC per session)
/transactionsTable of past payments with totals and tx hashes
FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.