documentation
AXI — a marketplace where the money is in the browser
AXI is a peer-to-peer marketplace for products and services built on Nostr, with Cashu ecash escrow designed around how freelancers actually get paid: in milestones. There is no API server — every page talks straight to relays and mints, and everything verifiable is verified in your tab.
Overview
Three primitives do all the work: listings are addressable Nostr events anyone can read, escrow is Cashu ecash split into bearer tokens the relay never sees, and identity is a secp256k1 key that stays in your browser.
- Publish a gig ("I will build you X") or a job ("hiring for Y") — same feed, same filters.
- Lock payment per milestone before work starts.
- Release each milestone as it lands; refund anything unfinished.
- Negotiate in an encrypted inbox; settle out of band with BIP-352 silent payment codes.
New here? Sign in (a key is minted for you), grab test sats from the faucet, then open the marketplace.
Routes
| path | what lives there |
|---|---|
| / | Landing page — hero, escrow walkthrough, entry points. |
| /market | Live Kind 31112 feed with product / service / escrow filters and the listing composer. |
| /escrow | Milestone escrow vault: lock, release, refund, redeem. |
| /chat | NIP-44 / NIP-59 encrypted inbox. |
| /profile | Identity, BIP-352 silent payments, ecash vault, circuit artifacts. |
| /login | Choose a signing key: mint one, import an nsec, or use a NIP-07 extension. |
| /docs | This page. |
Listings: products and services
Every listing carries a kind — product or service. Services add a structured block so they are searchable rather than prose:
{
v: 2,
kind: "service",
role: "offering" | "hiring",
title: "i will build your relay dashboard",
give: "shipped dashboard + source",
want: "21 000 sat",
amountSat: 21000,
service: {
category: "development", // design, dev, writing, video…
deliverable: "deployed app + repo",
duration: "2 weeks",
deadline: 1790000000, // unix seconds
skills: ["next.js", "nostr"]
},
milestones: [ // labels + amounts only, never tokens
{ label: "discovery", amountSat: 5000, status: "locked" },
{ label: "first cut", amountSat: 8000, status: "locked" },
{ label: "hand-off", amountSat: 8000, status: "locked" }
],
escrow: { state: "committed", amountSat: 21000, mint: "…", commitment: "sha256…" }
}The composer refuses to publish an escrow claim the mint cannot back: every proof in the token must still report UNSPENT.
Escrow for freelancers
Cashu tokens are bearer instruments — holding the token is holding the sats. AXI turns that into escrow without a custodian:
- Lock — the client's balance is split into one token per milestone via
createEscrowToken. Tokens are kept inlocalStorageunderaxi:escrow:contracts. - Commit — only
sha256(tokens)is published with the listing, so a relay reader cannot race you to the mint. - Release — handing milestone i over returns its token; the client pastes it into the encrypted chat.
- Redeem — the freelancer validates the token, checks it against the published commitment, and calls
redeemToken. - Refund — an unfinished milestone is simply never released. Nothing left the client's browser, so no third party can refuse the refund.
Contract phases: draft → funded → active → settled, with refunded and disputed as the unhappy paths. Everything above lives at /escrow.
Event kinds
kind 31112 · addressable listing
Title, give/want, kind (product | service), service block, milestone schedule, escrow commitment.
kind 1059 · gift wrap
Outer envelope for every private message. Relays only ever see this.
kind 14 · private DM
NIP-17 rumor sealed inside the gift wrap — negotiating a job, handing over a released token.
kind 13 · seal
NIP-44 ciphertext that carries the rumor to exactly one recipient.
Listings are filtered by the axi tag on t, with product / service added as a second t value for cheap relay-side filtering.
Source map
src/lib/nostr.ts
Kind 31112 codec and the NDK relay pool.
relayUrls · fetchOffers · subscribeOffers · publishOffer · parseOfferEvent · getActiveIdentity
src/lib/cashu.ts
Cashu wallet, faucet and the spend-check gate.
balanceOf · claimFaucet · createEscrowToken · validateToken · redeemToken
src/lib/escrow.ts
Milestone contracts plus the commit-reveal helpers.
fundContract · releaseMilestone · refundMilestone · commitmentOf · commitEscrow · redeemCommitted
src/lib/chat.ts
NIP-44 encryption inside NIP-59 wraps.
sendChatMessage · fetchChatMessages · subscribeChatMessages · conversationKey
src/lib/zk.ts
Client-side Groth16 verification with snarkjs.
verifyProofPayload · isZkPayload · artifactsAvailable
src/lib/silent-payments.ts
BIP-352 payment codes derived from your Nostr key.
deriveSilentIdentity
Configuration
Everything is NEXT_PUBLIC_* — copy .env.example to .env.local. Never put a private key in there; keys live in localStorage.
NEXT_PUBLIC_CASHU_MINT = https://testnut.cashu.space
Mint used by the faucet and by every escrow lock.
NEXT_PUBLIC_CASHU_UNIT = sat
Cashu unit.
NEXT_PUBLIC_NOSTR_RELAYS = wss://relay.damus.io,…
Comma-separated relay pool.
NEXT_PUBLIC_ZK_BASE = /circuits
Where the wasm / zkey / vkey artifacts are served from.
NEXT_PUBLIC_FAUCET_SAT = 1
Sats handed out per faucet click.
Security notes
- Tokens are never published. Relays carry a sha256 commitment; the token moves through your encrypted inbox.
- Spend-check before publish. A listing cannot claim escrow unless the mint still reports every proof unspent.
- ZK badges are untrusted until checked. Groth16 proofs are verified with snarkjs in your tab, never on a server.
- Keys are device-local. Losing the browser profile loses the key — export your
nsecfrom /profile if it matters to you. - Escrow is only as good as the mint. Testnet mints are for demos; point
NEXT_PUBLIC_CASHU_MINTat a mint you trust for real amounts.