Charge per message on a tab
Send notifications and messages at per-send cost, hard-capped so a loop can't blow your budget.
Charge per send at high volume. Each send meters into the tab and reserves on-chain — you can't be over-billed by a buyer or stiffed after delivery.
Seller: charge per send
Protect your send route with tabOrExactMiddleware. Set a flat perUnit price in human-units USDC per message. The middleware handles the 402 handshake; your delivery handler only runs after payment settles for each message. The buyer's tab caps cumulative spend across all sends.
import express from 'express';
import { Connection } from '@solana/web3.js';
import { tabOrExactMiddleware } from '@dexterai/x402/tab/seller';
const app = express();
const connection = new Connection(process.env.SOLANA_RPC_URL!);
// Each message costs perUnit USDC. The buyer's tab caps cumulative spend
// across all sends and reserves what's accrued on-chain — no runaway billing.
app.post('/send',
tabOrExactMiddleware({
connection,
sellerPubkey: process.env.SELLER_SOLANA_ADDRESS!,
network: 'solana:mainnet',
perUnit: '0.0004', // USDC per message
}),
async (req, res) => {
const receipt = await sendMessage(req.body);
res.json(receipt);
},
);Buyer: send within the cap
Call the send endpoint once per message with payAndFetch. Each send meters one unit into the tab. When the cap is reached,result.ok is false — the loop stops cleanly instead of overrunning your budget.
import { payAndFetch, createKeypairWallet } from '@dexterai/x402/client';
const solana = await createKeypairWallet(process.env.AGENT_KEY!);
// Send a batch — each call meters one message into the tab.
const messages = ['Hello, Alice', 'Hello, Bob', 'Hello, Carol'];
for (const text of messages) {
const result = await payAndFetch('https://push.example/send', {
method: 'POST',
body: JSON.stringify({ to: '+1555...', text }),
}, { solana });
if (!result.ok) break; // tab cap reached — stop cleanly
}Why tabs fit high-volume micro-spend
Push notifications and messages are the canonical high-volume tab use case. Each individual send is cheap — a fraction of a cent — but volume accumulates fast. A tab puts a hard ceiling on total spend before the first message is sent, so a runaway notification loop or an unbounded retry can't drain you.
From the seller's side, every delivery is guaranteed payment before the message goes out. No chargebacks, no net-30 invoices, no over-billing disputes. What's delivered is paid; what's paid is reserved on-chain.
Open a tab at dexter.cash/tabs with a per-campaign USDC cap. Hand the spending authorization to your notification service. Each send meters in real time — the cap enforces itself.