New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

402

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

402

402 payments

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
17
-50%
Maintainers
1
Weekly downloads
 
Created
Source

Introduction

Note: This repository contains experimental work from 2016 implementing HTTP 402 with Solid. We are now exploring modern HTTP 402 implementations and standards for R&D purposes.

For today's hackday I am going to try and start to build an access controlled "route" in solid-server, which grants access to a resource based on a credit system. If you have credits, it will show you the resource. If not you will get a 402. This builds a bit more functionality on the code written for the previous hack day. I'll try and incorporate the work from the web payments WG http://w3c.github.io/webpayments-http-api/.

Modern HTTP 402 Implementations (2025)

The HTTP 402 "Payment Required" status code, long dormant since HTTP/1.1, has seen significant adoption in 2025. Here are notable projects and standards:

x402 Protocol

  • Description: Open protocol by Coinbase that enables blockchain-based payments over HTTP
  • Partners: Cloudflare, Visa, Google, AWS, Anthropic, Circle, Vercel
  • Documentation: https://x402.gitbook.io/x402/core-concepts/client-server
  • Foundation: x402 Foundation (Coinbase + Cloudflare)
  • Use Cases: AI agent payments, API monetization, autonomous commerce
  • Stats: 1.38M+ transactions, $1.48M+ volume (as of Oct 2025)

Cloudflare Pay Per Crawl

  • Description: HTTP 402 implementation for AI crawler monetization
  • Documentation: https://developers.cloudflare.com/agents/x402/
  • Features: Per-request pricing for AI bots accessing web content
  • Scale: 1 billion+ HTTP 402 responses daily

L402 Protocol (Lightning Labs)

  • Aperture: L402 reverse HTTP proxy for paid APIs
  • @bus402/x402-sandbox: NPM package for local x402 testing
  • Visa TAP: Trusted Agent Protocol supporting x402
  • PING Token: First token experiment on x402 protocol (Base chain)

Resources

Components

The demo contains 4 components

  • /pay -- the resource that costs 25 credits to view
  • /balance -- shows your balance
  • /faucet -- a small app that will see your balance
  • /home -- navigation and instructions

Each was deployed as a custom route with its own handler.

Installation

Installation is via

git clone https://github.com/melvincarvalho/402.git

Then run

npm install
$ bin/server.js  --port 8443 --ssl-key path/to/ssl-key.pem --ssl-cert path/to/ssl-cert.pem
# server running on https://localhost:8443/
How do I get the --ssl-key and the --ssl-cert?

You need an SSL certificate you get this from your domain provider or for free from Let's Encrypt!.

If you don't have one yet, or you just want to test solid, generate a certificate

$ openssl genrsa 2048 > ../localhost.key
$ openssl req -new -x509 -nodes -sha256 -days 3650 -key ../localhost.key -subj '/CN=*.localhost' > ../localhost.cert

Faucet

Using webcredits it is possible to set up a faucet using

credit create

credit genesis

credit insert https://w3id.org/cc#coinbase 50000 '' https://w3id.org/cc#faucet

Demo

Demo

Keywords

402

FAQs

Package last updated on 27 Oct 2025

Related posts