x402
x402 copied to clipboard
feat: Extract paywall; refactor for v2 spec
Extracts the paywall from the monolithic legacy package into a standalone @x402/paywall package with modular architecture, builder pattern API, and tree-shakeable network-specific imports.
New Package: @x402/paywall
Location: typescript/packages/http/paywall/
Key Features:
- Standalone paywall package with EVM and Solana support
- Builder pattern for flexible configuration
- Subpath exports for tree shaking:
/evmand/svm - Backwards compatible with legacy
x402/paywallAPI
Bundle Sizes:
- Full paywall: 3.5 MB (both networks)
- EVM only: 3.4 MB (probably due to OnchainKit... we should figure out a way to reduce this)
- Solana only: 1.0 MB
Core Integration
@x402/core:
- Added
PaywallProviderinterface - Added
setPaywallProvider()method tox402HTTPResourceService - Auto-detects and uses
@x402/paywallif installed, otherwise falls back to basic HTML
@x402/express:
- Added optional
PaywallProviderparameter topaymentMiddleware()
Architecture
@x402/paywall (main)
├── index.ts - Legacy getPaywallHtml() + builder exports
├── builder.ts - PaywallBuilder with withNetwork() and withConfig()
├── types.ts - PaywallProvider, PaywallNetworkHandler interfaces
├── evm/
│ ├── index.ts - evmPaywall handler
│ ├── EvmPaywall.tsx
│ └── build.ts - Separate build for EVM-only bundle
└── svm/
├── index.ts - svmPaywall handler
├── SolanaPaywall.tsx
└── build.ts - Separate build for Solana-only bundle
API
Builder Pattern
import { createPaywall } from '@x402/paywall';
import { evmPaywall } from '@x402/paywall/evm';
const paywall = createPaywall()
.withNetwork(evmPaywall)
.withConfig({ appName: 'My App', testnet: true })
.build();
app.use(paymentMiddleware(routes, facs, schemes, undefined, paywall));
Network-Specific Imports
// EVM only - no Solana dependencies
import { evmPaywall } from '@x402/paywall/evm';
// Solana only - no EVM dependencies
import { svmPaywall } from '@x402/paywall/svm';
Checklist
- [x] I have formatted and linted my code
- [ ] All new and existing tests pass
- [x] My commits are signed (required for merge) -- you may need to rebase if you initially pushed unsigned commits
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| x402 | Preview | Comment | Nov 12, 2025 0:26am |