arc-honest-money
v0.1.0
Published
Four dependency-light primitives for verifiable agent money on Arc: prove an x402 payment, cap agent spend in code, cross-check a price against a second venue, and pay with an on-chain reconcilable memo.
Maintainers
Readme
arc-honest-money
Four dependency-light primitives for verifiable agent money on Arc, extracted from Cronus Capital. MIT. Fork freely.
npm i arc-honest-moneyImporting this package pulls in zero runtime dependencies, reads no environment
variables and has no side effects. viem is an optional peer dependency, loaded
lazily only by the one function that signs a transaction.
verifyX402Payment - prove you were paid
A seller must be able to prove payment, not assume it. Given a tx hash, confirm an
on-chain USDC Transfer of at least minAmount to your payTo. Raw JSON-RPC, no SDK.
Works for plain transfers and memo-wrapped ones, because the inner USDC Transfer is
still emitted.
const r = await verifyX402Payment({ txHash, payTo, minAmount: "20000" })
// { paid: true, payer: "0x...", amount: "20000", block: "0x2a" }
// underpaid -> { paid: false, reason: "underpaid: ...", amount, minAmount }decideSpend - cap agent spend in code, not in the prompt
Money safety belongs in code. A pure, deterministic gate over atomic units: a model may propose a number, but the caller enforces the hard cap, so a hallucinated or adversarial amount can never overspend. Fails closed on malformed input, exact at any magnitude.
decideSpend({ spentAtomic: "900000", amountAtomic: "200000", capAtomic: "1000000" })
// { allowed: false, reason: "exceeds remaining budget", remainingAtomic: "100000" }
const breaker = createBreaker("1000000") // in-process; back it with Redis in prodcrossCheck - corroborate a price against a second venue
A single venue can glitch or be manipulated. Compare a primary price against an
independent public spot and report the spread. Advisory and fail-open: on any failure
agree stays null - it annotates, it never fabricates a price.
await crossCheck("BTC-USDC", 64000, { tolPct: 0.5 })
// { source: "coinbase", altPrice: 64100, spreadPct: 0.1563, agree: true }payWithMemo - pay with an on-chain reconcilable reference
Pay any x402 resource through Arc's memo wrapper, attaching an indexed reference to the transfer while keeping your own wallet as msg.sender. The same topic always hashes to the same memoId, so payments are groupable on-chain. Requires viem.
const { payment, unlocked } = await payX402WithMemo({
url: "https://your-endpoint/api/signal?topic=BTC-USDC%20momentum",
privateKey: process.env.BUYER_PRIVATE_KEY,
topic: "BTC-USDC momentum",
})Why these four
Arc's value is verifiable money. These are the pieces of an honest x402 economy: a seller can prove it was paid, a buyer can pay with context, an agent can cap its own spend, and a signal can be cross-checked before it is trusted.
Design rules
- Fail closed on money, fail open on data. A spend decision denies on malformed input;
a price cross-check returns
agree: nullrather than inventing a number. - Injectable I/O. Every network call accepts a
fetchImpl, so the whole surface is testable without a network and without mocking globals. - Atomic units everywhere. No floats in money paths.
- Importable from a serverless handler. No top-level env reads, no top-level signing.
Status
v0.1.0. Extracted from the Cronus Capital codebase and published so the primitives can be forked and imported on their own. Cronus is migrating its own call sites onto this package module by module, starting with the price cross-check.
Tests
npm test # 42 tests, no network
npm run selftestCLI
node src/verify-x402-payment.mjs <txHash> <payTo> <minAmount>
node src/spend-breaker.mjs selftest
node src/price-crosscheck.mjs BTC-USDC 64000 0.5
node src/pay-with-memo.mjs "BTC-USDC momentum"License
MIT (c) Cronus Capital
