Skip to content

# ๐Ÿ’ณ Payless - Serverless x402 Payment Platform > Accept crypto payments without accounts, subscriptions, or complexity. Built with x402 protocol.

License

Notifications You must be signed in to change notification settings

Payless2025/PayLess

Repository files navigation

๐Ÿ’ฐ Payless

Accept Crypto Payments Without Accounts

The simplest way to monetize your APIs using the x402 protocol on Solana. Zero fees, instant settlements, one line of code.

GitHub License Solana x402

Contract Address (CA): FDgSegoxrdpsct21YVeAbC9dWeTwTxA8Cceeh8BPpump


๐ŸŽฏ What is Payless?

Payless is a serverless payment platform built on the x402 protocol. It lets developers monetize any API with crypto payments in minutesโ€”no accounts, no subscriptions, no complexity.

๐ŸŒ Multi-Chain Support: Solana, BSC (Binance Smart Chain), Ethereum, with Polygon coming soon!

Perfect for:

  • ๐Ÿค– AI Agent APIs - Let agents pay for your services autonomously
  • ๐Ÿ’ฐ Micropayments - Accept payments as low as $0.01
  • โšก Instant Settlement - Money in your wallet in 2 seconds
  • ๐Ÿš€ Serverless APIs - Deploy anywhere (Vercel, AWS, Netlify)
  • ๐ŸŒ Multi-Chain - Users choose their preferred blockchain

๐ŸŒŸ Features

  • ๐Ÿ’ฐ Zero Protocol Fees - Keep 100% of your revenue
  • โšก Instant Settlement - Money in your wallet in 2 seconds
  • ๐Ÿ” Privacy First - No accounts, emails, or OAuth required
  • ๐ŸŒ Multi-Chain Support - Solana + BSC + Ethereum (Polygon coming soon!)
  • ๐Ÿš€ Serverless Ready - Deploy to Vercel, Netlify, or AWS Lambda
  • ๐Ÿค– Perfect for AI Agents - Autonomous payments without human intervention
  • ๐Ÿ“Š Built-in Analytics - Track payments, revenue, and API usage
  • ๐Ÿ”” Webhook Support - Real-time payment notifications

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ installed
  • Wallet addresses for supported chains:
    • Solana: Phantom, Solflare, etc.
    • BSC: MetaMask, Trust Wallet, Binance Wallet
    • Ethereum: MetaMask, Coinbase Wallet, etc.
  • (Optional) x402 facilitator endpoint

Installation

  1. Clone the repository
git clone https://github.com/Payless2025/PayLess.git
cd payless
  1. Install dependencies
npm install
  1. Configure environment variables
cp .env.example .env

Edit .env and add your Solana wallet address:

# Solana wallet address (base58 format)
WALLET_ADDRESS=YourSolanaWalletAddressHere1111111111111111
FACILITATOR_URL=https://facilitator.x402.org
NETWORK=mainnet-beta
RPC_URL=https://api.mainnet-beta.solana.com
USDC_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v

# Enable demo payments (set to 'true' for playground/testing)
ENABLE_DEMO_PAYMENTS=true
  1. Run development server
npm run dev
  1. Open your browser
http://localhost:3000

๐Ÿ“– Usage

Adding Payment to Your API Endpoint

It's as simple as wrapping your handler with withX402Payment:

import { NextRequest, NextResponse } from 'next/server';
import { withX402Payment } from '@/lib/x402/middleware';

async function handler(req: NextRequest) {
  // Your API logic here
  const result = await yourBusinessLogic(req);
  return NextResponse.json({ result });
}

// Add payment requirement - that's it!
export const POST = withX402Payment(handler, "0.01");

Configure Endpoint Pricing

Edit lib/x402/config.ts:

export const ENDPOINT_PRICING: EndpointConfig = {
  '/api/ai/chat': '0.05',        // $0.05 per request
  '/api/ai/image': '0.10',       // $0.10 per request
  '/api/data/weather': '0.01',   // $0.01 per request
  '/api/your-endpoint': '0.25',  // Add your custom pricing
};

Making Payment Requests (Client-Side)

import { makePaymentRequest } from '@/lib/x402/client';

// The SDK handles payment automatically
const response = await makePaymentRequest(
  '/api/ai/chat',
  {
    method: 'POST',
    body: JSON.stringify({ message: 'Hello!' })
  },
  walletAddress,      // Your wallet
  recipientAddress,   // Merchant wallet
  '0.05'             // Payment amount
);

const data = await response.json();
console.log(data);

๐Ÿ—๏ธ Project Structure

payless/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ api/                  # API endpoints with x402 payment
โ”‚   โ”‚   โ”œโ”€โ”€ ai/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ chat/        # AI chat endpoint ($0.05)
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ image/       # AI image generation ($0.10)
โ”‚   โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ weather/     # Weather data ($0.01)
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ stock/       # Stock data ($0.02)
โ”‚   โ”‚   โ”œโ”€โ”€ premium/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ content/     # Premium content ($1.00)
โ”‚   โ”‚   โ”œโ”€โ”€ health/          # Health check (free)
โ”‚   โ”‚   โ””โ”€โ”€ info/            # API info (free)
โ”‚   โ”œโ”€โ”€ playground/          # Interactive API playground
โ”‚   โ”œโ”€โ”€ globals.css          # Global styles
โ”‚   โ”œโ”€โ”€ layout.tsx           # Root layout
โ”‚   โ””โ”€โ”€ page.tsx             # Landing page
โ”œโ”€โ”€ components/              # React components
โ”‚   โ”œโ”€โ”€ Hero.tsx            # Hero section
โ”‚   โ”œโ”€โ”€ Features.tsx        # Features grid
โ”‚   โ”œโ”€โ”€ CodeExample.tsx     # Code examples
โ”‚   โ”œโ”€โ”€ UseCases.tsx        # Use case cards
โ”‚   โ””โ”€โ”€ Footer.tsx          # Footer
โ”œโ”€โ”€ lib/
โ”‚   โ””โ”€โ”€ x402/               # x402 protocol implementation
โ”‚       โ”œโ”€โ”€ types.ts        # TypeScript types
โ”‚       โ”œโ”€โ”€ config.ts       # Configuration
โ”‚       โ”œโ”€โ”€ middleware.ts   # Payment middleware
โ”‚       โ””โ”€โ”€ client.ts       # Client utilities
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ tailwind.config.js
โ””โ”€โ”€ next.config.js

๐Ÿ”ง API Endpoints

Free Endpoints

Endpoint Method Description
/api/health GET Health check
/api/info GET API information and pricing

Paid Endpoints

Endpoint Method Price Description
/api/ai/chat POST $0.05 AI chat completion
/api/ai/image POST $0.10 AI image generation
/api/data/weather GET $0.01 Weather data
/api/data/stock GET $0.02 Stock market data
/api/premium/content GET $1.00 Premium content access

๐ŸŽฎ Try the Playground

Visit /playground to test all endpoints interactively:

npm run dev
# Open http://localhost:3000/playground

The playground allows you to:

  • Test all API endpoints
  • See payment flow in action (demo mode)
  • Inspect request/response payloads
  • Understand x402 protocol behavior

๐Ÿšข Deployment

Deploy to Vercel (Recommended)

  1. Push to GitHub
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/yourusername/payless.git
git push -u origin main
  1. Deploy to Vercel
npm install -g vercel
vercel
  1. Set environment variables in Vercel Dashboard
    • WALLET_ADDRESS - Your Solana wallet address
    • FACILITATOR_URL - Facilitator endpoint
    • NETWORK - Solana network (mainnet-beta, devnet)
    • RPC_URL - Solana RPC endpoint
    • USDC_MINT - USDC SPL token mint address

Deploy to Netlify

npm install -g netlify-cli
netlify deploy --prod

Deploy to AWS Lambda

Use Serverless Framework or AWS SAM.

๐Ÿ” Security Considerations

Production Checklist

  • Enable real facilitator verification (not demo mode)
  • Set up proper RPC endpoints for your network
  • Implement rate limiting
  • Add request validation
  • Set up monitoring and logging
  • Use HTTPS only
  • Implement webhook verification for payment confirmations
  • Add CORS restrictions
  • Enable API key authentication for sensitive endpoints (optional)

Environment Variables

Never commit these to version control:

  • WALLET_ADDRESS - Keep private
  • RPC_URL - Use secure providers
  • Private keys should NEVER be in your code

๐Ÿ“š Learn More

Documentation

x402 Protocol

Next.js

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ’ฌ Support

๐Ÿ™ Acknowledgments


๐Ÿ’ช Why Developers Choose Payless

Feature What You Get
โšก Lightning Setup One line of code, < 5 minutes to production
๐Ÿ’ฏ Keep 100% Zero protocol fees. Every dollar is yours
๐Ÿš€ True Serverless Deploy anywhere - Vercel, AWS, Netlify
๐Ÿ”“ Fully Open Source MIT license. Fork, modify, own it
๐ŸŽฏ Any Use Case Monetize any API or service, no restrictions
๐Ÿ› Built-in Playground Test all endpoints without writing code
๐Ÿ” Privacy First No accounts, emails, or OAuth required
๐Ÿค– AI Agent Ready Perfect for autonomous payments
๐Ÿ’ต True Micropayments Accept payments as low as $0.01 USDC
โšก Instant Settlement Money in your wallet in 2 seconds

The simplest, most developer-friendly way to monetize APIs with crypto. Zero fees, zero complexity, zero compromises.


Built with โค๏ธ by the Payless Team

๐ŸŒŸ GitHub | ๐Ÿฆ X/Twitter | ๐Ÿ“š Documentation

โญ Star this repo if you find it useful!

About

# ๐Ÿ’ณ Payless - Serverless x402 Payment Platform > Accept crypto payments without accounts, subscriptions, or complexity. Built with x402 protocol.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published