Skip to content

Commit c57805c

Browse files
committed
feat: add fortune cookie blog post
1 parent 8fdedb8 commit c57805c

4 files changed

Lines changed: 129 additions & 0 deletions

File tree

.claude/skills/blog-post/SKILL.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ Write substantive, accurate content that matches the title. Use `bash` or `types
8383

8484
**Style:** Write in an agent-agnostic style — avoid referencing Claude, ChatGPT, or any specific AI by name. Use "agent", "AI agent", or "your agent" instead. When referencing the Alby Bitcoin Payments skill, use: `npx skills add getAlby/payments-skill`. Write "bitcoin" and "lightning" in lowercase, same as "the internet" — only capitalise at the start of a sentence or in a title.
8585

86+
**Testing:** If the post involves an API, endpoint, or service, **always make real HTTP requests** to verify the actual behaviour before writing about it. Never describe how something works based on documentation alone — test it and write from real results.
87+
88+
**Payments:** When the post involves HTTP 402 / L402 payments, **always use the Alby payments skill** (`npx -y @getalby/cli fetch -u <url>`) as the primary approach. Show the simple one-command path first. Manual payment flows (extract invoice, pay, retry with preimage) are secondary — include them only as "how it works under the hood" context, not as the recommended approach.
89+
8690
## Step 4: Generate the cover image
8791

8892
Now that the article is written, craft an image prompt that visually represents its core theme. A good prompt is specific to the article's subject, not generic. It should follow the site's terminal aesthetic:
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: Smoke-Test Your L402 Integration in One Request
3+
description: A free public endpoint that charges 1 sat over L402 and returns a fortune — the quickest way to verify your lightning payment flow is wired up correctly.
4+
date: 2026-04-09
5+
tags: ["402", bitcoin, lightning, l402, agents]
6+
image: /blog/images/2026-04-09-smoke-test-l402-integration.jpg
7+
imageAlt: A glowing cyan fortune cookie cracked open with a lightning bolt emerging from it, connected to a padlock icon via dotted lines on a dark navy background.
8+
---
9+
10+
When you're building an agent that pays for APIs over lightning, there's an awkward gap between "I wrote the code" and "I know it actually works." You need a live L402 endpoint that charges real sats, returns something meaningful, and doesn't require any setup on your side. [@CatalunyaLND](https://x.com/CatalunyaLND) built exactly that: a tiny fortune cookie API that costs 1 sat to call.
11+
12+
## The Simple Way: One Command
13+
14+
If your agent has the Alby payments skill installed, the entire L402 flow collapses to a single command:
15+
16+
```bash
17+
npx skills add getAlby/payments-skill
18+
```
19+
20+
Then fetch the fortune endpoint:
21+
22+
```bash
23+
npx -y @getalby/cli fetch -u https://l402-fortune-cookie.yf-ae7.workers.dev/api/fortune
24+
```
25+
26+
That's it. The CLI detects the 402 response, pays the invoice automatically, and returns the unlocked content:
27+
28+
```json
29+
{
30+
"content": "{\"fortune\": \"The answer you seek is hidden in the next block.\", \"paid\": true, \"sats_paid\": 1}"
31+
}
32+
```
33+
34+
One real payment, end-to-end, no manual steps. If this works, your L402 integration is wired up correctly.
35+
36+
## A Free Sample Too
37+
38+
If you just want to check connectivity without spending sats first, `GET /api/fortune/free` returns a fortune at no cost:
39+
40+
```bash
41+
curl https://l402-fortune-cookie.yf-ae7.workers.dev/api/fortune/free
42+
```
43+
44+
```json
45+
{
46+
"fortune": "Success is a journey, not a destination — but low fees help get there faster.",
47+
"paid": false,
48+
"note": "Free sample 🎁 — pay 1 sat at /api/fortune for the real experience"
49+
}
50+
```
51+
52+
## How L402 Works Under the Hood
53+
54+
For those building their own L402 client, the endpoint exposes the full protocol clearly. A raw request to `/api/fortune` returns HTTP 402 with a `WWW-Authenticate` header:
55+
56+
```bash
57+
curl -i https://l402-fortune-cookie.yf-ae7.workers.dev/api/fortune
58+
```
59+
60+
```http
61+
HTTP/2 402
62+
www-authenticate: L402 macaroon="eyJ...", invoice="lnbc10n1..."
63+
64+
{
65+
"error": "Payment Required",
66+
"message": "Pay 1 sat to unlock your fortune 🥠",
67+
"payment_request": "lnbc10n1...",
68+
"payment_hash": "5ef5d0f0...",
69+
"macaroon": "eyJ...",
70+
"instructions": "After paying, retry with: Authorization: L402 <macaroon>:<preimage>"
71+
}
72+
```
73+
74+
The five-step flow the server documents:
75+
76+
1. `GET /api/fortune` → 402 + `WWW-Authenticate` with macaroon and invoice
77+
2. Pay the lightning invoice → receive preimage
78+
3. Poll `GET /api/fortune/status/:payment_hash` until `paid: true`
79+
4. `GET /api/fortune` with `Authorization: L402 <macaroon>:<preimage>`
80+
5. Receive your fortune
81+
82+
The status polling endpoint lets you confirm payment before retrying — useful if you can't receive a webhook. The Alby CLI's `fetch` command handles all of this automatically.
83+
84+
## Why This Endpoint Is Worth Bookmarking
85+
86+
Most L402 tutorials end with a diagram. This endpoint lets you test the real thing — a live payment gate that responds to correct credentials and rejects bad ones. It's hosted on Cloudflare Workers, so it's fast and available globally.
87+
88+
Use it early in development to confirm your payment flow is wired up. Use it in CI to catch regressions. And if you're building your own L402 server, use it as a reference for what the protocol should look like from the client's perspective.
89+
90+
Thanks to [@CatalunyaLND](https://x.com/CatalunyaLND) for building and hosting it.
91+
92+
## Conclusion
93+
94+
`https://l402-fortune-cookie.yf-ae7.workers.dev` is the quickest smoke-test for L402 available. With the Alby payments skill, one command confirms the full payment flow works — for 1 sat.
95+
96+
---
97+
98+
## Get started
99+
100+
Need a Lightning wallet for your agent? Create one in one command — no sign-up, no KYC:
101+
102+
```bash
103+
curl -X POST https://lncurl.lol
104+
```
105+
106+
You'll get back a Nostr Wallet Connect URI. Fund it with a few sats and your agent can pay for APIs, services, and tools autonomously.
107+
108+
Or give your agent the lncurl skill directly: [https://lncurl.lol/SKILL.md](https://lncurl.lol/SKILL.md)

frontend/public/blog-manifest.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
[
2+
{
3+
"slug": "2026-04-09-smoke-test-l402-integration",
4+
"title": "Smoke-Test Your L402 Integration in One Request",
5+
"description": "A free public endpoint that charges 1 sat over L402 and returns a fortune — the quickest way to verify your lightning payment flow is wired up correctly.",
6+
"date": "2026-04-09",
7+
"isoDate": "2026-04-09T00:00:00Z",
8+
"displayDate": "April 9, 2026",
9+
"tags": [
10+
"402",
11+
"bitcoin",
12+
"lightning",
13+
"l402",
14+
"agents"
15+
],
16+
"image": "/blog/images/2026-04-09-smoke-test-l402-integration.jpg",
17+
"imageAlt": "A glowing cyan fortune cookie cracked open with a lightning bolt emerging from it, connected to a padlock icon via dotted lines on a dark navy background."
18+
},
219
{
320
"slug": "2026-04-08-x402-bitcoin-facilitator",
421
"title": "Pay-Per-Request with Bitcoin: Testing Alby's x402 Facilitator",
34.4 KB
Loading

0 commit comments

Comments
 (0)