x402 for Bejibun Framework.
Install the package.
# Using Bun
bun add @bejibun/x402
# Using Bejibun
bun ace install @bejibun/x402The configuration file automatically executed if you are using ace.
Or
Add x402.ts inside config directory on your project if doesn't exist.
config/x402.tsimport type {TFacilitator, TNetwork, TPrice, TScheme} from "@bejibun/x402/types";
import {facilitator} from "@coinbase/x402";
const config: Record<string, any> = {
scheme: "exact" as TScheme,
price: "$1" as TPrice,
networks: [
{
network: "eip155:8453" as TNetwork,
payTo: "0xdABe8750061410D35cE52EB2a418c8cB004788B3"
},
{
network: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp" as TNetwork,
payTo: "GAnoyvy9p3QFyxikWDh9hA3fmSk2uiPLNWyQ579cckMn"
}
],
facilitator: facilitator as TFacilitator
};
export default config;You can pass the value with environment variables.
How to use tha package.
import type {TFacilitator, TRoutePaymentConfig} from "@bejibun/x402/types";
import X402 from "@bejibun/x402";
/**
* setFacilitator(config?: TFacilitator)
*
* setRoutePayment(config?: TRoutePaymentConfig)
*
* setRequest(request: Bun.BunRequest) // Mandatory for request headers
*/
return await X402
.setFacilitator()
.setRoutePayment()
.setRequest(request)
.middleware(async () => {
// your paid resource here
});If you find this project helpful and want to support it:
Or you can buy this $BJBN (Bejibun) tokens here.
