@moltrust/x402

March 9, 2026 · View on GitHub

MolTrust trust verification middleware for x402 payments. Checks the paying agent's MoltGuard reputation score before allowing payment flow.

Install

npm install @moltrust/x402

Hono

import { Hono } from "hono";
import { moltrustGuard } from "@moltrust/x402";

const app = new Hono();
app.use(moltrustGuard({ minScore: 50 }));

Express

import express from "express";
import { moltrustGuard } from "@moltrust/x402/express";

const app = express();
app.use(moltrustGuard({ minScore: 50 }));

How it works

  1. Extracts wallet address from the X-PAYMENT header
  2. Calls MoltGuard's free agent scoring endpoint
  3. Returns 403 if score is below minScore
  4. Passes through if score is OK
  5. Fails open if MoltGuard is unreachable (never blocks payments on downtime)

Options

OptionTypeDefaultDescription
minScorenumber50Minimum score (0–100) to allow
apiUrlstringhttps://api.moltrust.ch/guardMoltGuard API base URL
timeoutnumber3000Timeout in ms

License

MIT — moltrust.ch