Skip to content

betterclever/zimppy

Repository files navigation

zimppy

crates.io npm npm License: MIT

The privacy stack for MPP. Zcash shielded transactions today, more privacy rails coming.

zimppy.xyz

Install

npm install zimppy          # CLI + wallet
npm install zimppy-ts       # TypeScript SDK
[dependencies]
zimppy-core = "0.3"         # Rust verification engine
zimppy-rs = "0.3"           # Rust SDK (charge, session, axum)

What's included

  • Charge — one shielded payment per request (HTTP 402)
  • Sessions — deposit once, instant bearer requests, close with refund
  • Streaming — pay-per-token metered content over SSE
  • CLInpx zimppy request with automatic payment handling
  • Dual SDK — TypeScript and Rust
  • Spec-compliant — HMAC-SHA256 challenges, RFC 9457 errors, /.well-known/payment discovery

Why

Public chains zimppy
Sender Visible Encrypted
Receiver Visible Encrypted
Amount Visible Encrypted
Memo Visible Encrypted

How it works

Charge

Single shielded payment per request. Standard HTTP 402 flow.

Agent  ->  GET /api/fortune
Server ->  402 + challenge (amount, recipient, memo)
Agent  ->  shielded ZEC with memo "zimppy:{challenge_id}"
Agent  ->  GET /api/fortune + Authorization: Payment {txid}
Server ->  decrypt with Orchard IVK, verify amount + memo
Server ->  200 OK + Payment-Receipt

Session

Deposit once on-chain, then instant bearer requests with no chain interaction.

Agent  ->  deposit 100,000 zat           (on-chain)
Agent  ->  open session                  (bearer token)
Agent  ->  request, request, request     (instant)
Agent  ->  close session                 (refund unused balance)

Streaming

Pay-per-token over SSE. Server deducts from session balance per word streamed.

Agent  ->  open session with deposit
Agent  ->  GET /api/stream (SSE)
Server ->  stream word by word, deducting per token
Agent  ->  close session, refund remaining

Server

TypeScript

import { Mppx } from 'mppx/server'
import { zcash } from 'zimppy-ts/server'

const mppx = Mppx.create({
  methods: [await zcash({ wallet: 'server' })],
  realm: 'my-api',
  secretKey: process.env.MPP_SECRET_KEY,
})

const result = await mppx.charge({
  amount: '42000',
  currency: 'zec',
})(request)

if (result.status === 402) return result.challenge
return result.withReceipt(Response.json({ data }))

Rust (axum)

use mpp::server::axum::*;
use zimppy_rs::ZcashChallenger;

struct Price;
impl ChargeConfig for Price {
    fn amount() -> &'static str { "42000" }
}

async fn handler(charge: MppCharge<Price>) -> WithReceipt<Json<Value>> {
    WithReceipt { receipt: charge.receipt, body: Json(data) }
}

Client

TypeScript

import { Mppx } from 'mppx/client'
import { zcash } from 'zimppy-ts/client'

const mppx = Mppx.create({ methods: [zcash({ wallet: 'default' })] })

// 402 -> pay -> retry handled automatically
const res = await mppx.fetch('https://api.example.com/resource')

Rust

use mpp::client::Fetch;
use zimppy_rs::ZcashPaymentProvider;

let provider = ZcashPaymentProvider::new(wallet_config, &rpc);

let resp = client
    .get("https://api.example.com/resource")
    .send_with_payment(&provider)
    .await?;

CLI

npx zimppy wallet create              # generate keys, show seed phrase
npx zimppy wallet whoami              # address, balance, network
npx zimppy request <url>              # auto 402 -> pay -> retry
npx zimppy wallet send <addr> 42000   # shielded transfer
npx zimppy wallet use work            # switch wallet identity

Architecture

crates/
  zimppy-core/       Zcash verification engine (Orchard decryption, replay protection)
  zimppy-wallet/     Native Zcash wallet (zingolib)
  zimppy-rs/         Rust SDK (ChargeMethod, SessionMethod, PaymentProvider, axum extractors)
  zimppy-napi/       Node.js native bindings (NAPI-RS)
packages/
  zimppy-ts/         TypeScript SDK (charge, session, SSE)
  zimppy-cli/        CLI with auto-pay and session management
examples/
  fortune-teller/    Charge, session, and streaming demos (Rust server + client)
  llm-summarizer/    Pay-per-token LLM demo
  mcp-server/        MCP tool server with paid AI tools
  ts-server/         TypeScript MPP server

Packages

Package Description Registry
zimppy-core Zcash verification engine crates.io
zimppy-wallet Native Zcash wallet (zingolib)
zimppy-rs Rust SDK: charge, session, axum extractors
zimppy-ts TypeScript SDK npm
zimppy CLI with auto-pay npm
@zimppy/core-napi Node.js native bindings (darwin-arm64, linux-x64) npm

License

MIT

About

Zcash Machine Payments Protocol — private payments for AI agents

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors