Trust-minimized, Programmable, Pay-per-use data APIs
x402f extends the x402 protocol to invert the trust model entirely: the server never holds plaintext, never handles payments, and cannot withhold data — even if it goes offline.
Built on Fangorn threshold encryption, x402f enables intent-bound data delivery: content encrypted under publicly verifiable conditions, decrypted locally by the buyer only after payment is confirmed on-chain.
- Seller registers a datasource and uploads encrypted content via Fangorn — no dedicated infra needed.
- Buyer receives a ciphertext before payment. They can verify what they're purchasing against chain state.
- Payment is made via x402. The facilitator verifies it and issues a decryption share.
- Decryption happens locally. The server never sees plaintext, and can never withhold data post-purchase.
- Programmable pricing — dynamic, verifiable pricing through Fangorn, no code changes required
- Zero seller infrastructure — anyone can sell data without running their own server
- Trust-minimized — buyers start with the ciphertext; payment and ownership are verifiable on-chain
- Censorship-resistant — data cannot be withheld after purchase, even if the server goes offline
x402f consists of two services:
| Service | Description | Default Port |
|---|---|---|
| Facilitator | Verifies payments and issues decryption shares | 30333 |
| Resource Server | Serves encrypted data and coordinates with the facilitator | 4021 |
Both services are stateless and can be run by anyone. See the Fangorn docs to register datasources and upload content.
- Node.js 22+
- pnpm
# Clone and install
git clone https://github.com/fangorn-network/x402f
cd x402f
pnpm install
# Configure environment
cp .env.local .env
# Fill in your details in .env# Start the facilitator (runs on :30333)
pnpm run facilitator
# In a separate terminal, start the resource server (runs on :4021)
pnpm run serverdocker compose up --buildpnpm run client:nodeSee the full node client example.
- You receive the ciphertext before payment — verify what you're buying before spending anything
- Decryption happens locally after payment — the server cannot withhold your data
- Pricing and ownership are verifiable against finalized chain state
- No infrastructure required — the shared resource server handles delivery
- Dynamic pricing — update prices through Fangorn without touching code or redeploying
- Optionally run a dedicated resource server for more control (but you don't have to)
| Variable | Description |
|---|---|
FACILITATOR_DOMAIN |
Hostname of the facilitator (e.g. http://facilitator in Docker, or https://facilitator.example.com in prod) |
FACILITATOR_PORT |
Port the facilitator listens on (default: 30333) |
MIT
