pay 21 test sats for an api call
this is a real HTTP 402 paywall with fake money. one click mints 21 test sats from testnut, sends them in an X-Cashu header, and shows every request on the way. no wallet, no signup, nothing to install.
waiting for a click
now do it for real
the sandbox stops at test sats. this is the same flow with money you would actually miss if it went wrong.
- 1get a wallet
software that holds Cashu ecash, on your phone or in your terminal.
cashu.me · Minibits · Numo (repo) · bitchat
- 2pick a mint you trust
the mint holds the bitcoin behind your ecash, so you are trusting the operator. read the custody notes before you deposit anything.
the mints we checked, with custody notes. small amounts only.
- 3add NUT-24 to your own API
put a 402 in front of a route and accept an X-Cashu token. these are libraries, not hosted services.
testnut is for testing only, never send real sats to it.
// sketch, not tested here. see the libraries above for their real APIs.
app.get('/paid', async (req, res) => {
const token = req.header('X-Cashu')
if (!token) return res.status(402).set('X-Cashu', paymentRequest).json({ error: 'payment_required' })
if (!await redeemAtYourMint(token)) return res.status(400).json({ error: 'bad_token' })
res.json({ ok: true })
})