Operational

x402 Payment Facilitator

Zero-fee micropayments for AI agents and APIs using HBD on the Hive blockchain.

Network: hive:mainnet Asset: HBD Fees: $0 Finality: 3s

How it works

This facilitator verifies and settles HBD payments following the x402 standard. API servers use it to gate endpoints behind micropayments.

1

Client requests a paywalled endpoint

The API server returns HTTP 402 with payment requirements in the x-payment header.

2

Client signs an HBD transfer

The client constructs and signs a Hive transaction (without broadcasting) and retries with the x-payment header.

3

Facilitator verifies the signature

Recovers the public key from the secp256k1 signature and checks it against the sender's on-chain active key.

4

Facilitator broadcasts and settles

The signed transaction is broadcast to the Hive network. The HBD arrives in the recipient's account with zero fees.

Why Hive + HBD

$0
Transaction fees
3s
Block finality
$1
HBD peg (USD)

Every micropayment arrives in full. No gas costs eating into small payments. HBD is Hive's algorithmic stablecoin pegged to the US dollar.

API Endpoints

This facilitator exposes the following endpoints:

GET /health Health check
GET /supported-networks Returns supported networks
POST /verify Verify a signed payment
POST /settle Verify + broadcast + mark nonce spent
GET /metrics JSON metrics
GET /stats Live HTML dashboard

Integrate

Install the package:

npm install @hiveio/x402
import express from "express";
import { paywall } from "@hiveio/x402/middleware";

const app = express();

app.get("/api/premium", paywall({
  amount: "0.050 HBD",
  receivingAccount: "your-hive-account",
  facilitatorUrl: "https://x402.ecency.com",
  // x402Version: 1,  // optional: default is 2
}), (req, res) => {
  res.json({ data: "premium content" });
});
// app/api/premium/route.ts
import { withPaywall } from "@hiveio/x402/middleware/nextjs";

async function handler(req, ctx) {
  return Response.json({
    data: "premium content",
    payer: ctx.payer
  });
}

export const GET = withPaywall({
  amount: "0.050 HBD",
  receivingAccount: "your-hive-account",
  facilitatorUrl: "https://x402.ecency.com",
  // x402Version: 1,  // optional: default is 2
}, handler);
import { HiveX402Client } from "@hiveio/x402/client";

const client = new HiveX402Client({
  account: "alice",
  activeKey: "5K...",   // Hive active key (WIF)
  maxPayment: 0.1,       // max HBD per request
});

// Transparently handles 402 → sign → retry
// Auto-detects v1/v2 from the 402 response
const res = await client.fetch(
  "https://api.example.com/premium"
);
const data = await res.json();
import { createFacilitator } from "@hiveio/x402/facilitator";

// Metrics enabled by default at /metrics and /stats
const app = createFacilitator();

app.listen(4020);