Zero-fee micropayments for AI agents and APIs using HBD on the Hive blockchain.
This facilitator verifies and settles HBD payments following the x402 standard. API servers use it to gate endpoints behind micropayments.
The API server returns HTTP 402 with payment requirements in the x-payment header.
The client constructs and signs a Hive transaction (without broadcasting) and retries with the x-payment header.
Recovers the public key from the secp256k1 signature and checks it against the sender's on-chain active key.
The signed transaction is broadcast to the Hive network. The HBD arrives in the recipient's account with zero fees.
Every micropayment arrives in full. No gas costs eating into small payments. HBD is Hive's algorithmic stablecoin pegged to the US dollar.
This facilitator exposes the following endpoints:
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", }), (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", }, 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 const res = await client.fetch( "https://api.example.com/premium" ); const data = await res.json();