Skip to content

Install: Node.js middleware ​

The Node middleware drops into any Express/Connect app — or plain node:http. It's the smallest form factor and the easiest to reason about.

When to use

You run a Node or Express backend. Works with Express, Connect, and plain node:http; no hard framework dependency.

1. Install ​

bash
npm install ./mothershy-wall-0.1.0.tgz   # from the dashboard download, or:
# npm install @mothershy/wall

2. Mount it ​

js
import { mothershy } from '@mothershy/wall'

app.use(mothershy({
  siteId: 'example.com',
  rootPub: 'OINUtFdXQHzeGJrrGFSwTm3DRG0D/KPlY9sYgJfMkS8=',  // pinned Mother root
  priceMicroUsd: 250,     // 0 = free, >0 = x402 gate
  payTo: '0x…',           // payout address (Base Sepolia USDC)
}))

The middleware runs before your routes. A verified agent passes through with req.mothershy = { agent, site, amt_microusd, cap } so you can credit them downstream.

3. Verify ​

bash
node server.js   # start your app
# human → 200, agent → 402, Googlebot → 200 (see quickstart for exact curls)

Options ​

OptionDefaultMeaning
siteId—Your verified domain (required)
rootPub—Pinned Mother public root, base64 (required)
priceMicroUsd0>0 enables the x402 price gate
gateMode'agents-only''all' gates everything without a valid header
payTo—On-chain payout address

Behavior ​

  • Header present → parse + offline verify() → must be for this site → next().
  • No header → classify by User-Agent → human/free-bot next(), agent 402 (or x402 when priced).
  • Malformed / tampered / cross-site → 400 / 401 / 403.

Next ​

MotherShy — the economic operating layer for AI agents and publishers.