Monetize Your APIs with Blockchain Payments
HTTP 402 Payment Required middleware for Mantle Network. Turn your APIs into revenue streams with on-chain payments.
Everything You Need to Monetize APIs
A complete toolkit for adding blockchain-based payments to your APIs. Simple integration, powerful features.
Blockchain-Secured
Payments are verified directly on Mantle Network. No intermediaries, no chargebacks, no fraud.
Lightning Fast
Mantle's low gas fees and fast finality make micropayments practical and affordable.
Express.js Middleware
Drop-in middleware that integrates seamlessly with your existing Express.js application.
TypeScript Native
Full TypeScript support with complete type definitions for a superior developer experience.
Flexible Pricing
Set your own prices per endpoint. Charge per-request, per-tier, or any custom model.
Event Hooks
React to payment events with hooks. Log, notify, or trigger actions on payment success.
How It Works
A simple 4-step flow that turns any API endpoint into a paid service. Secure, transparent, and fully on-chain.
User Requests API
Client makes a request to your protected endpoint without payment proof.
curl https://api.example.com/premium402 Payment Required
Middleware returns HTTP 402 with payment details: amount, recipient, and challenge.
HTTP/1.1 402 Payment Required
X-Payment: {"amount": "0.01", "recipient": "0x..."}User Pays on Mantle
User sends MNT payment to the specified address on Mantle Network.
wallet.sendTransaction({ to: recipient, value: amount })Access Granted
User retries with TX hash. Middleware verifies on-chain and grants access.
curl -H "X-Payment: {txHash: '0x...'}" /premium
✓ 200 OK - Access GrantedSimple to Integrate
Just a few lines of code to add blockchain payments to your API. Works with any Express.js application.
1import express from 'express';2import { mantle402 } from 'mantle-402';34const app = express();56// Free endpoint - no payment required7app.get('/api/free', (req, res) => {8 res.json({ message: 'This is free!' });9});1011// Paid endpoint - requires 0.01 MNT12app.use('/api/premium', mantle402({13 recipient: 'YOUR_WALLET_ADDRESS',14 amount: '0.01',15 network: 'mainnet',16 description: 'Premium API Access'17}));1819app.get('/api/premium', (req, res) => {20 res.json({ 21 message: 'Payment verified!',22 data: 'Your premium content here' 23 });24});2526app.listen(3000);Get Started in 3 Steps
From zero to earning in under 5 minutes. It's that simple.
Install the package
npm install mantle-402Add to your Express app
import { mantle402 } from 'mantle-402';
app.use('/api/paid', mantle402({
recipient: 'YOUR_WALLET',
amount: '0.01',
network: 'mainnet'
}));Start earning
npm run start