# RevRule by Payload - Programmable Revenue Rules EnginePayload — Developer infrastructure for x402, agent payments, and programmable revenue. PAYLOAD → VEYLINE (flagship) → CALLX402 (action layer) → REVRULE (separate) → developer products → free utilities. This repo: RevRule by Payload — programmable revenue rules engine (this repo holds the engine).
RevRule turns any economic event into auditable entitlements: who is owed what, computed by a versioned, stateful rule graph.
A Stripe payment, an x402 settlement, a royalty statement row. RevRule evaluates the event against your revenue graph and returns exact per-party entitlements, conserved to the micro-unit, with an append-only hash-chained ledger entry explaining every line. One engine, no industry branches: creative-economics splits, SaaS marketplace payouts, and machine-commerce micropayments are all configurations of the same generic primitives. It computes who is owed what; regulated partners move the money.
Why it exists: revenue splits live in spreadsheets and memory. When money arrives but nobody agrees on the math, disputes eat the margin. RevRule makes the economics deterministic, explainable, and auditable.
Try it (no signup): run the RevRule Sandbox in your browser, or get a free API key with one curl call and hit the hosted RevRule API at https://payload-rail.fly.dev (quickstart).
Want it hosted? RevRule by Payload is $99 one-time. Found the sandbox useful? Star the repo.
- A deterministic evaluation engine: rules consume from the pool
(
net = amount - processingCost) in priority order;remainderis a validated rule type that conserves the pool exactly. - A stateful rule language: percentage, fixed, per_use, referral,
recoupment (first-class, with defined intra-event step-down semantics),
waterfall composites, capped / time_limited / milestone wrappers,
first/last-touch attribution, remainder, plus the system rules
payload_fee(rail-aware pricing engine v2) andplatform_fee. - An append-only hash-chained ledger with explainable entries (every ENTITLEMENT / FEE / SKIPPED entry links event to graph version to rule, with human-readable reasons).
- Adapters as seams: stripe, x402, and csv adapters translate source-native payloads into the canonical event envelope. Translation only: never evaluation, never money movement.
- A TypeScript SDK:
defineGraphtoactivateGraphtoprocessEventtoreadLedger, plussimulateEvent(dry-run, zero side effects).
- Not a payment processor. It computes who is owed what; regulated partners (Stripe Connect, x402 facilitators) execute payouts.
- Not custody. Distributions are
proposedinstructions only. The engine never holds funds and never controls settlement timing. - No real-money execution in this repo. Adapters run against supplied
payloads; the engine and tests make no live network calls. A live-rail
acceptance run passed 2026-10-03/04: a real $1.00 Stripe charge and two real
0.10-USDC Base Sepolia settlements, each processed by the real adapters
and the RevRule engine with the arithmetic verified to the micro-unit. Full
evidence is in
acceptance/ACCEPTANCE_STRIPE_2026-10-03.mdandacceptance/ACCEPTANCE_X402_2026-10-03.md(not yet pushed to this repo; the published ACCEPTANCE.md covers the pre-live criteria). All distributions remainproposed.
npm install
npm test # full suite (vitest)
npm run build # tsc -> dist/The three falsification walkthroughs (creative economics, SaaS/marketplace, machine commerce) run executable against one shared Rail deployment:
npx vitest run test/validations.test.tsSee ACCEPTANCE.md for the criterion-by-criterion evidence mapping.
All amounts are integer micro-units (1e-6 of the major unit; USD 1.00 =
1,000,000). Percentages are integer basis points. The single rounding step
is round-half-up per computed rule amount, via exact BigInt arithmetic. No
floats anywhere in the money path. remainder takes whatever is left, so
sum(entitlements) + sum(fees) == pool structurally.
| Capability | Label |
|---|---|
| Rule engine, ledger, adapters (stripe/x402/csv), SDK, fee engine v2, simulator, reconciliation | Beta (implemented, validated by tests + live-rail acceptance) |
| Weighted multi-touch attribution, oracle milestones, stablecoin payout rail, LICENSE registry adjudication, contribution-graph verification | Modeled, not executed |
| Tax filing, securities-like revenue interests, dispute arbitration, multi-currency netting | Not yet modeled |
- Problem: revenue splits computed in spreadsheets and memory, then disputed when money arrives. RevRule makes the math deterministic, explainable, and auditable.
- Console: the live console at https://payload-rail.fly.dev/revrule-console/ issues a free self-serve API key and hosts the graph, entitlement, and payout-evidence views.
- Sandbox: https://payloadhq.github.io/revrule-sandbox.html runs the actual engine in your browser, no signup.
- License: the hosted product, RevRule by Payload, is $99 one-time.
- Funds: RevRule never holds funds and never executes payouts. It computes entitlements and records evidence; regulated partners move the money.
- RevRule API quickstart: https://payloadhq.github.io/flow-rail.html
- Browser sandbox (no key needed): https://payloadhq.github.io/flow-sandbox.html
- Human console: https://github.com/Payloadhq/revrule-console
- Telegram: https://t.me/payloadtool
- Patreon: https://patreon.com/PayloadTools
MIT - see LICENSE. Copyright 2026 Payload.
More from Payload · payloadhq.github.io · all Payload repos
Related: revrule-console · revrule-csv-import · n8n-nodes-payload-flow
