Skip to content
ALFA117Public

About

git squash, but for money: provably minimal multilateral netting, settled atomically on Hedera with Scheduled Transactions and metered per obligation over x402.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Squash logo: an eye inside a network of nodes

Squash

git squash, but for money.

A multilateral netting engine: give it N obligations between N parties and it returns the provably minimum set of transfers — then settles them atomically on Hedera, so nobody pays until everybody has signed.

Live demo Sample trip ETHOnline 2026

Hedera x402 Next.js React TypeScript Supabase Privy World ID Vitest


Squash on a laptop (landing page with a 4-person dinner example) and on a phone (the settlement plan: 15 debts become 3 transfers)

▶ Open the app · Sample trip · How it works · Proof on HashScan · Honest status

Warning

Status, November 2026: live bills (/nuevo, /g/…) are offline because the Supabase project behind them can't be reached — the site says so before anyone fills in a form. The sample trip (/join) still settles end to end on Hedera testnet, x402 payment for the plan included. Nothing runs on mainnet.


🎯 The problem

Six friends on a trip pay for different things, and soon everyone owes everyone: 15 debts. Settling them one by one means 15 payments, 15 fees, and somebody always pays before somebody else backs out.

💡 The solution

Squash nets the whole graph to the minimum number of transfers and settles them as one all-or-nothing Hedera Scheduled Transaction that executes on the last signature.

15 obligations between 6 people  →  3 transfers  ·  80% fewer, 80% less in fees
  You   → Rosa     $2,040.00 MXN
  Diego → Mariana  $1,110.00 MXN
  Luis  → Ana        $570.00 MXN

At a table it's three steps: whoever paid shows a QR, everyone scans in and sees their share live (equal parts, amounts set by the payer, or each enters their own), and everyone taps yes. Pesos are converted at today's rate and settle as tUSD, a Hedera testnet dollar token.

The expense-splitting app is the demo; the engine is the product, and it's metered: any app or agent can call it and pay per obligation over x402 — no API key, no subscription.

Three phones: the Valle de Bravo sample trip, the settlement plan graph, and the confirmation screen waiting for everyone
Sample trip · the settlement plan (bought from the engine over x402) · waiting for every signature.

✨ Features

Three steps: scan the QR, pick the split, everyone says yes
Four pieces: Hedera scheduled transactions, x402 metering, Privy wallets and World ID

Four pieces, one promise — Scheduled Transactions, x402 metering, Privy payouts and World ID seats.

Landing page in dark mode

English / Spanish, light and dark.

Three phones: split a bill form, the group balance screen, and the landing page
Split a bill (currently offline, and it says so) · the group balance · the landing on a phone.
Feature State
Netting engine with an exact minimum solver done
POST /api/v1/net, priced per obligation, gated by x402 (Hedera exact scheme via Blocky402, fee sponsored) done, live
Each bill buys its plan from the engine over x402; receipt shown at the table done, paid on testnet
Pesos → dollars at today's rate, settled as tUSD (HTS, 1 unit = 1 cent) done
HCS proof-of-run audit trail for every netting run done, published on testnet
Scheduled Transaction atomic settlement — executes on the last signature done
Privy — the payer is paid into their own embedded wallet and can send it on done (chain side proven by scripts/test-payout.mjs)
World Selfie Check — one human per seat, seat recovery built; the live demo runs a clearly-labelled simulation of the World App step
Split a bill at a real table, live across phones built; offline while the Supabase project is unreachable

The full ledger of what works, what's written but never executed, and what hasn't started is in STATUS.md.

🧠 How it works

flowchart LR
    T["Bill or trip: expenses"] --> E["Expand to obligations, integer cents"]
    E --> N["Net per pair, then globally"]
    N --> S["Exact solver: bitmask DP"]
    S --> P["Minimum transfer plan"]
    A["App or agent"] -->|402 then PAYMENT-SIGNATURE| X["x402 gate: POST /api/v1/net"]
    X --> F["Blocky402 facilitator"]
    X --> S
    P --> H["HCS: proof of run"]
    P --> SC["Hedera Scheduled Transaction"]
    SC -->|last signature| U["tUSD settled"]
Loading

Why the plan is minimal, not just small: every settlement plan splits into groups that sum to zero, and a group of size k costs k − 1 transfers. So

minimum transfers = n − max(disjoint zero-sum subsets)

The engine finds that maximum exactly with a bitmask DP over subsets; above 15 non-zero balances it falls back to greedy and says so in optimal. Greedy alone isn't enough: on {a:−100, b:+100, c:−250, d:+250} it chains three transfers where two suffice — there's a test for exactly that. Everything is integer cents; no floats touch money.

The API and its pricing
POST /api/v1/net
{ "expenses":    [{ "id", "label", "payer", "cents", "among": [...] }] }
{ "obligations": [{ "from", "to", "cents" }] }

Returns balances, pairwise edges, the transfer plan, whether it's proven optimal, the compression ratio and the price. With X402_ENABLED=true an unpaid call gets 402 with the requirements in the PAYMENT-REQUIRED header; the caller retries with PAYMENT-SIGNATURE, verified and settled through Blocky402 before any work is done. Build the payment with the official @x402/hedera client.

Obligations Price each
1–10 0.00040 ℏ
11–50 0.00035 ℏ
51–200 0.00028 ℏ
201+ 0.00021 ℏ

🔎 Proof

Not a claim — go and look. One netting run, paid for and published on Hedera testnet:

  • The payment — 0.0.7162784@1789008230.889484170: the agent paid 0.00525 ℏ for the work and nothing for gas — the facilitator sponsored the fee.
  • The proof of the run — HCS topic 0.0.10452145, message 1: input hash, 15 obligations → 3 transfers, optimal: true, and the plan. Hash the same obligations yourself and check it matches.
  • A real split — a $1,500 MXN bill, US$88.40 moved as tUSD.

🛠️ Stack

Layer Technology
Web Next.js 16 · React 19 · TypeScript · Motion · CSS 3D background · QR codes
Ledger Hedera testnet via @hashgraph/sdk: HTS (tUSD), HCS (audit), Scheduled Transactions
Payments x402 (@x402/core, @x402/fetch, @x402/hedera) via the Blocky402 facilitator
Identity & wallets Privy embedded wallets (Hedera EVM relay, viem) · World ID IDKit (Selfie Check)
Data Supabase (shared state for live bills)
Tests Vitest — 47 tests: solver, split rules, currency conversion, input validation
Deploy Vercel

🚀 Run it locally

npm install
npm test        # 47 tests, no network, no credentials
npm run dev

The sample trip needs no configuration: with no .env.local the engine answers for free. Live bills need Supabase and a pool of testnet accounts; the paid path needs Hedera credentials (see .env.local.example). CONTRIBUTING.md walks through getting your own in about five minutes.

Scripts
Script What it does
node scripts/test-dinner.mjs <url> A whole dinner plus five attacks against any server
node scripts/test-payout.mjs <url> A secp256k1 wallet becomes a Hedera account, receives the settlement and sends it on
node scripts/test-world-demo.mjs The seat rules around the simulated World step
node scripts/agent.mjs The paying agent
scripts/create-*.mjs One-time setup: HCS topic, agent account, demo accounts, account pool, dollar token

📂 Docs

Document What's in it
STATUS.md The honest ledger: what runs, what is demo-shaped, what hasn't started
ARCHITECTURE.md How the pieces fit
SUBMISSION.md Hackathon submission and proof links
CONTRIBUTING.md Get running in a minute, no credentials
docs/OVERVIEW.md The previous long-form README: sponsor tracks, engine, API, layout, design notes
docs/WORLD_FEEDBACK.md Feedback for the World team

🏆 Hackathon

Built for ETHOnline 2026, for the Hedera (AI & Agentic Payments, x402), Privy (best financial flow) and World (Selfie Check) tracks. Track-by-track details in docs/OVERVIEW.md.

📄 License

MIT.


Fifteen debts, three transfers, one yes from everyone.

About

git squash, but for money: provably minimal multilateral netting, settled atomically on Hedera with Scheduled Transactions and metered per obligation over x402.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages