✍️ Writing, Poetry & Narrative · poetry social feed

Stanza · x402

A high-throughput 'Pay-to-Read' poetry terminal where every stanza is hidden behind a 0.01 USDC gate. Verse uses x402 to automate frictionless micropayments, allowing poets to monetize specific lines or complete sonnets instantly. Readers sign with Privy to stream payments as they scroll, effectively 'buying the ink' as they consume the narrative. No subscriptions, just a direct flow of value from the reader's gaze to the writer's wallet.

Sei + x402 paywall· x402 native
Section · Onchain

The primitive.

full primer →

Writers pay 0.01 USDC per poetry social feed unlock via the x402 paywall on Sei Testnet (atlantic-2) — no gas, no wallet popup, just a signed EIP-3009 authorization that our own in-app facilitator settles onchain.

Why this primitiveVerseVibe's original 'tipping' model is passive. By making the verse itself the asset gated by x402, we turn poetry into a metered commodity. The friction of traditional payments is solved by the 0.01 USDC primitive, turning a social feed into a high-velocity revenue engine for writers.

Kernel
an x402 pay-per-use paywall on Sei Devnet (arctic-1, chainId 713715) — Privy embedded wallet signs EIP-3009 USDC authorizations, a same-origin proxy relays PAYMENT-SIGNATURE to a facilitator (PayAI) that settles 0.01 USDC and returns a Sei tx hash in PAYMENT-RESPONSE
Drives the UI as
a 4-step flow log (Challenge → Sign → Retry → Settle) that ends with a live Seiscan tx link proving the micropayment cleared
Appendix · Secrets

Required keys.

METAMASK_PRIVATE_KEY
Exported from MetaMask. Fund on Sei Testnet via the Sei faucet.
open ↗
SEI_TESTNET_RPC_URL
Public default is https://evm-rpc-testnet.sei-apis.com; override with Ankr/DRPC for heavy reads.
open ↗
PRIVY_APP_ID
Google sign-in with a Sei Testnet embedded wallet — user pays their own gas from the Sei faucet.
open ↗
PINATA_JWT
Pins images / JSON / manifests to IPFS.
open ↗

Add these in your Lovable project under Settings → Secrets before pasting the prompt below.

Appendix · Mega-prompt

The build prompt.

Paste into a fresh Lovable project. Make sure all five secrets above are set first. read the build strategy →

Build "Stanza" in ONE Lovable message. Single-page x402-native paid app on Sei Devnet (arctic-1).

CONCEPT
A high-throughput 'Pay-to-Read' poetry terminal where every stanza is hidden behind a 0.01 USDC gate. Verse uses x402 to automate frictionless micropayments, allowing poets to monetize specific lines or complete sonnets instantly. Readers sign with Privy to stream payments as they scroll, effectively 'buying the ink' as they consume the narrative. No subscriptions, just a direct flow of value from the reader's gaze to the writer's wallet.
Discipline: Writing, Poetry & Narrative (poetry social feed).
Onchain primitive: x402 micropayments on Sei Devnet arctic-1 (USDC via EIP-3009). Why: VerseVibe's original 'tipping' model is passive. By making the verse itself the asset gated by x402, we turn poetry into a metered commodity. The friction of traditional payments is solved by the 0.01 USDC primitive, turning a social feed into a high-velocity revenue engine for writers.

5-CREDIT BUDGET (HARD LIMIT):
- ONE single-page app. No Lovable Cloud, no database, no auth flows beyond Privy drop-in.
- NO smart contract deploy. x402 settles USDC via EIP-3009 `transferWithAuthorization` — the USDC contract already exists at 0x4E4a29F76Cd0dff2A4e5e56D7A065E0aF33f32e2 on Sei Devnet arctic-1 (chainId 713715).
- Privy is the auth + signing layer (Google login + embedded wallet).
- At most ONE AI call per user action (Lovable AI Gateway with LOVABLE_API_KEY, only if AI is part of the idea).
- Skip tests, skip CI, skip docs. Ship the demo.

CHAIN CHOICE (non-obvious — read before you swap chains)
PayAI's x402 facilitator settles Sei traffic ONLY on Sei Devnet arctic-1 (chainId 713715, deprecated per chainid.network but live at facilitator). It does NOT settle on Sei Testnet atlantic-2 (chainId 1328). Do not swap for atlantic-2 — the EIP-712 domain will mismatch and PayAI returns `invalid_signature`.

STACK
- React + Vite + TanStack Start (the template Lovable ships).
- viem does NOT export arctic-1. Define it once in src/lib/sei-arctic.ts:
    import { defineChain } from "viem";
    export const seiArctic = defineChain({
      id: 713715, name: "Sei Devnet (arctic-1)",
      nativeCurrency: { name: "Sei", symbol: "SEI", decimals: 18 },
      rpcUrls: { default: { http: ["https://evm-rpc-arctic-1.sei-apis.com"] } },
      blockExplorers: { default: { name: "Seiscan", url: "https://testnet.seiscan.io" } },
      testnet: true,
    });
- Privy embedded wallet, lazy + client-only mount (`@privy-io/react-auth` crashes under SSR):
    import { seiArctic } from "@/lib/sei-arctic";
    <PrivyProvider appId={import.meta.env.VITE_PRIVY_APP_ID}
      config={{ loginMethods:['google'],
                embeddedWallets:{ ethereum:{ createOnLogin:'users-without-wallets' } },
                defaultChain: seiArctic as never,
                supportedChains: [seiArctic] as never }}>
- viem public client uses the arctic-1 RPC — put it in src/data/rpc.json as
  { "seiArctic": "https://evm-rpc-arctic-1.sei-apis.com" } and use
  createPublicClient({ chain: seiArctic, transport: http(rpc.seiArctic) }).

TEN NON-OBVIOUS x402 RULES (get these wrong and it silently fails)
1. CORS: proxy the facilitator. Public x402 facilitators (including x402.payai.network) do NOT send
   Access-Control-Allow-Origin. A direct browser fetch throws "TypeError: Failed to fetch" BEFORE
   you see the 402. Wrap the upstream call in a same-origin TanStack server route at
   src/routes/api/public/x402-proxy.ts and forward PAYMENT-SIGNATURE (request) + PAYMENT-RESPONSE (response).
2. x402 v2 envelope shape. The base64-encoded PAYMENT-SIGNATURE payload is NOT
   { scheme, network, payload } at top level — that's v1 and PayAI rejects it as invalid_payload.
   It MUST be:
     { "x402Version": 2,
       "accepted": { /* the full PaymentRequirement you picked, echoed back verbatim */ },
       "payload":  { "signature": "0x…",
                     "authorization": { from, to, value, validAfter, validBefore, nonce } } }
3. Network id is CAIP-2: "eip155:713715" for Sei Devnet arctic-1 (NOT "sei-testnet" and NOT "eip155:1328").
   Match on this when picking a requirement from accepts[].
4. Amount field renamed. v2 uses `amount` (atomic units, string), NOT v1's `maxAmountRequired`.
   USDC has 6 decimals — "10000" = 0.01 USDC.
5. Header names are literal-cased and non-standard: PAYMENT-SIGNATURE (request) and PAYMENT-RESPONSE (response).
6. EIP-3009 domain fields come from requirement.extra. Use extra.name ("USDC") and extra.version ("2")
   in the EIP-712 domain — NOT hardcoded. chainId is 713715; verifyingContract is requirement.asset.
7. nonce is bytes32 random, generated client-side (crypto.getRandomValues(new Uint8Array(32)) → 0x-hex).
   Never reuse. validAfter = now-60s, validBefore = now + maxTimeoutSeconds (default 300).
8. Sign via Privy embedded wallet's provider, NOT React hooks: get the EIP-1193 provider
   (const provider = await embedded.getEthereumProvider()) and call
   provider.request({ method: "eth_signTypedData_v4", params: [address, JSON.stringify(typedData)] }).
9. Use the arctic-1 RPC from src/data/rpc.json (rule above). USDC balanceOf against a random public RPC will flake.
10. Fund flow: NO public USDC faucet on arctic-1. Show the user's Privy address prominently,
    link them to arctic-1 SEI faucet (https://sei-faucet.nima.enterprises) for gas (not actually
    required — x402 is gasless — but reassuring), and add a UI note asking to DM PayAI / a
    maintainer for 0.10 arctic-1 USDC. Then a "Refresh balance" button.

FILE LAYOUT
  src/data/x402.json          { endpoint, proxy, usdcAddress: "0x4E4a29F76Cd0dff2A4e5e56D7A065E0aF33f32e2",
                                chainId: 713715, network: "eip155:713715",
                                faucetUrl: "https://sei-faucet.nima.enterprises",
                                explorer: "https://testnet.seiscan.io" }
  src/data/rpc.json           { "seiArctic": "https://evm-rpc-arctic-1.sei-apis.com" }
  src/lib/sei-arctic.ts       defineChain wrapper (viem has no arctic-1 export)
  src/lib/x402.ts             fetchChallenge / pickRequirement / signPayment / fetchPaid
  src/routes/api/public/x402-proxy.ts   same-origin GET proxy (below)
  src/routes/index.tsx        demo UI: sign-in → fund → 4-step flow log

PROXY ROUTE (drop-in — copy verbatim):
```ts
// src/routes/api/public/x402-proxy.ts
import { createFileRoute } from "@tanstack/react-router";
import x402Cfg from "@/data/x402.json";

export const Route = createFileRoute("/api/public/x402-proxy")({
  server: {
    handlers: {
      GET: async ({ request }) => {
        const sig = request.headers.get("PAYMENT-SIGNATURE");
        const upstream = await fetch(x402Cfg.endpoint, {
          method: "GET",
          headers: sig ? { "PAYMENT-SIGNATURE": sig } : {},
        });
        const body = await upstream.arrayBuffer();
        const out = new Headers();
        const ct = upstream.headers.get("content-type");
        if (ct) out.set("Content-Type", ct);
        const pr = upstream.headers.get("PAYMENT-RESPONSE");
        if (pr) out.set("PAYMENT-RESPONSE", pr);
        return new Response(body, { status: upstream.status, headers: out });
      },
    },
  },
});
```

The /api/public/* prefix bypasses Lovable's published-site auth — desired for a demo endpoint.

USER FLOW (log every step in the UI so the user sees what happened)
1. Land on page → "Sign in with Google" (Privy) → embedded wallet auto-provisioned on Sei Devnet arctic-1.
2. Fund: show wallet address + "Get 0.01 USDC on Sei arctic-1" → link to PayAI Discord / maintainer for USDC
   → "Refresh balance" button reads USDC balanceOf via viem + the arctic-1 RPC.
3. Click the primary action button for this idea (poetry social feed). App runs:
   (a) Challenge — GET /api/public/x402-proxy → expect 402 → parse { x402Version:2, accepts:[…], error }.
       Pick accepts[] where network === "eip155:713715" && scheme === "exact".
   (b) Sign — Build EIP-3009 typed data (see rules 6–8), call Privy signTypedData,
       wrap into the v2 envelope (rule 2), base64.
   (c) Retry — GET /api/public/x402-proxy with header PAYMENT-SIGNATURE: <base64>.
   (d) Settle — On 200, read PAYMENT-RESPONSE header, base64-decode →
       { success, transaction, network, payer }. Link tx to `${explorer}/tx/${transaction}`.
4. Footer renders: "Built during the Creative AI & Quantum Hackathon organised by StreetKode Fam during Indian Krump Festival 14"

FACILITATOR
Default endpoint: https://x402.payai.network/api/sei-testnet/paid-content (returns 402 with an
accepts[] challenge, settles 0.01 USDC per successful call on Sei Devnet arctic-1, returns the
protected payload). Note: PayAI's path is called "sei-testnet" but the underlying chain is
arctic-1 (chainId 713715), not atlantic-2 (chainId 1328).

REQUIRED SECRETS (Lovable → Project Settings → Secrets):
- PRIVY_APP_ID          Google sign-in + embedded wallet. In the Privy dashboard, add Sei Devnet
                        (713715, RPC https://evm-rpc-arctic-1.sei-apis.com). No Gas Sponsorship
                        policy needed (x402 is gasless). Docs: https://docs.privy.io/llms-full.txt

COMMON FAILURE MODES (fix these before shipping)
- "TypeError: Failed to fetch" at step (a): called the facilitator directly from the browser. Use the proxy.
- "invalid_payload" at step (c): sent v1 envelope. Wrap under `accepted` (rule 2).
- "invalid_signature": wrong domain — chainId mismatch (must be 713715, not 1328), or extra.version
  hardcoded to "1". Use chainId 713715 and extra.version from the requirement.
- "insufficient_funds": wallet has SEI but no USDC. Request arctic-1 USDC from PayAI / maintainer,
  then Refresh balance.
- Balance stays at 0 after funding: reading against the wrong RPC. Point at
  https://evm-rpc-arctic-1.sei-apis.com via rpc.json (NOT the atlantic-2 RPC).
- expires_at errors on retry: clock skew or reused nonce. Generate fresh nonce + timestamps per attempt.

CREDIT (must appear in UI footer):
Built during the Creative AI & Quantum Hackathon organised by StreetKode Fam during Indian Krump Festival 14
Appendix · Market

Market sizing.

TAM
$2.8B
The global online poetry and literature market transitioning to agent-to-human and peer-to-peer micropayment architectures.
SAM
$450M
The digital creative writing and self-publishing market adopting web3-native micro-monetization.
SOM
$12M
Poets and micro-fiction writers on Base seeking instant EIP-3009 settlement for short-form content.

Indicative figures for hackathon pitches — refine with your own research before raising.

See also

Adjacent entries.