Pay-per-access protected routes on Solana, using
wallet-standardand the x402 protocol. No middleware – full control.
/api/premium) with HTTP 402 Payment Required wallet-standard) api/premium/+server.ts)price: "$1", treasury address, network 402 + PAYMENT-REQUIRED header if no payment PAYMENT-RESPONSE headerx402.ts)fetch $lib/wallet/standard – standard wallet adapter @solana/wallet-account-signer – turns wallet account into a signer for SVM| Package | Purpose |
|---|---|
@x402/core, @x402/fetch, @x402/svm |
x402 client/server logic |
@wallet-standard/* |
Wallet connection & UI |
@solana/wallet-account-signer |
Signer for SVM scheme |
# Install everything
bun i @wallet-standard/base @wallet-standard/app @wallet-standard/features @wallet-standard/ui-registry @wallet-standard/ui @solana/wallet-account-signer
bun i @x402/core @x402/fetch @x402/svm
Made with ☕ and a bit of frustration (but it works).
#svelte #solana #wallet-standard #x402