Skip to content

Instantly share code, notes, and snippets.

@ukstv
Created June 28, 2025 11:25
Show Gist options
  • Save ukstv/913a0752075dd9d3e84263c47cd0ded0 to your computer and use it in GitHub Desktop.
Save ukstv/913a0752075dd9d3e84263c47cd0ded0 to your computer and use it in GitHub Desktop.
import { Hono } from "hono";
import { serve } from "@hono/node-server";
import { paymentMiddleware } from "x402-hono";
const app = new Hono();
// Configure the payment middleware
app.use(
paymentMiddleware(
"0xBAc675C310721717Cd4A37F6cbeA1F081b1C2a07",
{
"/protected-route": {
price: "$0.001",
network: "base-sepolia",
config: {
description: "Access to premium content",
},
},
},
{
url: "https://facilitator.x402.rs",
},
),
);
// Implement your route
app.get("/protected-route", (c) => {
return c.text("This content is behind a paywall");
});
serve({
fetch: app.fetch,
port: 3000,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment