@mnemopay/sdk · v1.11.0

The TypeScript SDK.

Apache-2.0. 14 modules. Hash-chained ledger. Charter / FiscalGate / Article 12 audit bundles. 6 payment rails. 200K-operation stress tested. Free forever for builders. Managed rails / hosted score storage / enterprise SLAs are how we make money.

Install

npm i @mnemopay/sdk
# or
pnpm add @mnemopay/sdk
yarn add @mnemopay/sdk

Quick start — sign an agent action

import { Identity } from "@mnemopay/sdk/identity";

const agent = await Identity.create({ agent_id: "billing-bot-01" });
const action = { tool: "stripe.charge", amount_cents: 4900, currency: "usd" };

const signed = await agent.sign(action);
//   { ...action, sig: "...", pubkey: "ed25519:...", ts: "2026-..." }

// Counter-party verifies offline:
const ok = await Identity.verify(signed);  // → true

Persistent agent memory

import { Recall } from "@mnemopay/sdk/recall";

const mem = await Recall.open({ agent_id: "billing-bot-01" });

await mem.write({ kind: "customer_pref", text: "ACME wants Net-30 invoices" });
await mem.write({ kind: "policy", text: "Refund anything under $50 without escalation" });

// Cosine search at retrieval time
const hits = await mem.query("how do I bill ACME?", { topk: 3 });
//   [{ score: 0.82, text: "ACME wants Net-30 invoices", ... }]

FiscalGate — enforce budgets pre-call

import { Charter, FiscalGate } from "@mnemopay/sdk/fiscal";

const charter = await Charter.create({
  agent_id: "billing-bot-01",
  budget_cents: 50_000,            // $500/mo cap
  allowed_rails: ["stripe", "paystack"],
  allowed_tools: ["stripe.charge", "paystack.charge"],
  expires_at: "2026-06-01T00:00:00Z",
});

const ok = await FiscalGate.preflight({ charter, action: signed });
if (!ok.allowed) {
  // Refused — over budget, wrong rail, expired charter, etc.
  // Refusal itself is signed + audited (Article 12).
  throw new Error(ok.reason);
}

Payment rails

Six rails ship in the box. Same interface across all of them — switch rails by changing one config field.

import { Rails } from "@mnemopay/sdk/rails";

// Stripe
await Rails.charge({ rail: "stripe", amount_cents: 4900, currency: "usd", customer: "cus_..." });

// Paystack (Nigeria + Africa)
await Rails.charge({ rail: "paystack", amount_cents: 49000, currency: "ngn", customer: "..." });

// Lightning (Bitcoin)
await Rails.charge({ rail: "lightning", amount_sats: 50_000, invoice: "lnbc..." });

// Stripe MPP (Managed Payments Platform, agent-native)
await Rails.charge({ rail: "stripe-mpp", ... });

// x402 (USDC on Base)
await Rails.charge({ rail: "x402", amount_usdc: 49, recipient: "0x..." });

// Google AP2
await Rails.charge({ rail: "ap2", ... });

Agent Credit Score

FICO-scaled 300-850 score derived from payment history (35%), behavioral stability (30%), memory integrity (15%), identity stability (10%), anomaly signals (10%). Read it cheap; counter-parties price risk against it.

import { Score } from "@mnemopay/sdk/score";

const score = await Score.get({ agent_id: "billing-bot-01" });
//   { score: 738, band: "good", factors: { payment_history: 0.91, behavior: 0.85, ... } }

Article 12 audit bundles

Every signed action, every refusal, every memory write rolls into a Merkle-chained, time-anchored audit bundle. EU AI Act compliance is a side effect of doing this correctly anyway.

import { Audit } from "@mnemopay/sdk/audit";

const bundle = await Audit.bundle({ agent_id: "billing-bot-01", since: "2026-05-01" });
//   { merkle_root: "...", events: [...], anchor_chain: "ethereum" | "bitcoin", proofs: [...] }

Middleware

Drop-in wrappers for the major LLM SDKs. Same memory-injection + audit-write contract for OpenAI, Anthropic, and Gemini.

import { OpenAIMiddleware } from "@mnemopay/sdk/middleware/openai";
import { AnthropicMiddleware } from "@mnemopay/sdk/middleware/anthropic";
import { GeminiMiddleware } from "@mnemopay/sdk/middleware/gemini";

const mw = new OpenAIMiddleware({ agent_id: "billing-bot-01" });
const client = mw.wrap(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }));

// Every client.chat.completions.create() now:
//   1. Pulls top-k recall hits into the prompt automatically
//   2. Logs the request + response to Article 12 audit
//   3. Updates the credit score signal (latency, token usage, refusal rate)

What is NOT in the SDK (use the gateway instead)

Hosted score storage. Cross-platform credit-score lookup that travels across integrators — paid Pro / Enterprise. api.mcp.mnemopay.com.

Managed rails. We aggregate Stripe / Paystack / Lightning / x402 under one webhook. Self-hosting is free but not free of work. Pro tier is for teams who want it managed.

Enterprise SLA + multi-region recall storage. Custom contracts.

Where it is built in public

Repo: github.com/mnemopay/mnemopay-sdk · Discussions: open · Changelog: CHANGELOG.md