OMPX JavaScript SDK
    Preparing search index...

    Class Ompx

    OMPX server class with Hono-specific middleware generation.

    import { Hono } from 'hono'
    import { Ompx } from '@ompx/hono'
    import { tempo } from '@ompx/tempo'

    type Env = { Variables: OmpxVariables }
    const app = new Hono<Env>()

    const ompx = Ompx.create({
    methods: [tempo({ recipient: '0x...', currency: '0x20c0...' })],
    })

    app.get('/api/search',
    ompx.charge({ amount: '0.01' }),
    (c) => {
    const settlement = c.get('ompxSettlement')
    return c.json({ results: [], payer: settlement.payer })
    }
    )
    Index

    Methods

    Methods

    • Returns a Hono middleware that enforces payment for the route.

      The middleware:

      1. Returns 402 with dual-protocol challenges if no payment is present
      2. Verifies and settles the payment
      3. Injects ompxSettlement and ompxProtocol into Hono context
      4. Attaches receipt headers to the response

      Parameters

      Returns MiddlewareHandler<HonoEnvWithOmpx>