Created
June 28, 2025 11:25
-
-
Save ukstv/913a0752075dd9d3e84263c47cd0ded0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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