Skip to main content

Installation

Quick Start

Every request to /api/* is evaluated. Wallets that fail the standard policy get a 402 challenge response. Wallets that pass get the trust result on c.get('credTrust').

Configuration

Wallet Address Extraction

By default the middleware checks (in order):
  1. X-Wallet-Address request header
  2. ?wallet= query parameter
If neither is present, it returns a 400. Override with extractWallet:

Response Headers

When headers: true (default), every response includes:

Failure Modes

on402: ‘challenge’ (default)

When gates fail, returns a 402 with a machine-readable challenge body:

on402: ‘deny’

Returns a simple 403:

on402: ‘pass’

Allows the request through with trust headers set. Use this for logging/monitoring without blocking.

Dynamic Pricing Example

Gate your API with trust-based pricing — trusted wallets pay less:

Accessing Trust Data in Handlers

The trust result is stored via c.set('credTrust', result) and accessible in any downstream handler: