Built for Mantle Network

Monetize Your APIs with Blockchain Payments

HTTP 402 Payment Required middleware for Mantle Network. Turn your APIs into revenue streams with on-chain payments.

Learn More
100%
On-chain Verification
5 min
Integration Time
TypeScript
Full Support

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.

01
Request arrives

User Requests API

Client makes a request to your protected endpoint without payment proof.

terminal
curl https://api.example.com/premium
02
Challenge sent

402 Payment Required

Middleware returns HTTP 402 with payment details: amount, recipient, and challenge.

terminal
HTTP/1.1 402 Payment Required
X-Payment: {"amount": "0.01", "recipient": "0x..."}
03
On-chain payment

User Pays on Mantle

User sends MNT payment to the specified address on Mantle Network.

terminal
wallet.sendTransaction({ to: recipient, value: amount })
04
Verified & served

Access Granted

User retries with TX hash. Middleware verifies on-chain and grants access.

terminal
curl -H "X-Payment: {txHash: '0x...'}" /premium
✓ 200 OK - Access Granted

Simple to Integrate

Just a few lines of code to add blockchain payments to your API. Works with any Express.js application.

server.ts
1import express from 'express';
2import { mantle402 } from 'mantle-402';
3
4const app = express();
5
6// Free endpoint - no payment required
7app.get('/api/free', (req, res) => {
8 res.json({ message: 'This is free!' });
9});
10
11// Paid endpoint - requires 0.01 MNT
12app.use('/api/premium', mantle402({
13 recipient: 'YOUR_WALLET_ADDRESS',
14 amount: '0.01',
15 network: 'mainnet',
16 description: 'Premium API Access'
17}));
18
19app.get('/api/premium', (req, res) => {
20 res.json({
21 message: 'Payment verified!',
22 data: 'Your premium content here'
23 });
24});
25
26app.listen(3000);

Get Started in 3 Steps

From zero to earning in under 5 minutes. It's that simple.

1

Install the package

npm install mantle-402
2

Add to your Express app

import { mantle402 } from 'mantle-402';

app.use('/api/paid', mantle402({
  recipient: 'YOUR_WALLET',
  amount: '0.01',
  network: 'mainnet'
}));
3

Start earning

npm run start